Files

265 lines
9.9 KiB
Tcl
Raw Permalink Normal View History

2018-09-19 16:43:02 +08:00
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2019-03-04 08:42:12 -05:00
PortSystem 1.0
2024-10-13 22:06:38 -04:00
PortGroup deprecated 1.0
2018-09-19 16:43:02 +08:00
2019-10-15 12:39:48 +02:00
name python38
2018-09-19 16:43:02 +08:00
epoch 1
2020-07-15 03:42:33 -05:00
# Remember to keep py38-tkinter, py38-htmldocs, and py38-gdbm's versions sync'd with this
2024-09-07 16:32:22 +10:00
version 3.8.20
2024-10-13 22:06:38 -04:00
deprecated.eol_version yes
2019-03-04 08:42:12 -05:00
set major [lindex [split $version .] 0]
set branch [join [lrange [split ${version} .] 0 1] .]
2018-09-19 16:43:02 +08:00
categories lang
license PSF
maintainers nomaintainer
2018-09-19 16:43:02 +08:00
description An interpreted, object-oriented programming language
long_description Python is an interpreted, interactive, object-oriented \
programming language.
homepage https://www.python.org/
2019-10-15 12:39:48 +02:00
master_sites ${homepage}ftp/python/${version}/
2018-09-19 16:43:02 +08:00
2019-03-04 08:42:12 -05:00
distname Python-${version}
use_xz yes
2024-09-07 16:32:22 +10:00
checksums md5 745478c81d6382cf46b5e7ad89e56008 \
rmd160 1d03db4e018f2133f2b279a3a44f0c7c759c50cf \
sha256 6fb89a7124201c61125c0ab4cf7f6894df339a40c02833bfd28ab4d7691fafb4
2018-09-19 16:43:02 +08:00
patchfiles patch-setup.py.diff \
patch-Lib-cgi.py.diff \
patch-configure.diff \
patch-Lib-ctypes-macholib-dyld.py.diff \
patch-libedit.diff \
2020-07-18 14:29:04 -07:00
patch-configure-xcode4bug.diff \
2021-05-08 05:04:35 +10:00
sysconfig.py.diff \
2023-09-16 00:42:26 +10:00
distutils_spawn.py.patch \
2024-09-07 16:32:22 +10:00
libedit-types.patch \
implicit-int.patch
2018-09-19 16:43:02 +08:00
2022-08-20 14:05:16 +10:00
if {${os.platform} eq "darwin" && ${os.major} <= 10} {
2020-04-15 07:01:11 -07:00
# work around no copyfile and/or pthread_threadid_np on older systems
patchfiles-append patch-no-copyfile-on-Tiger.diff \
patch-threadid-older-systems.diff
}
2024-09-07 16:32:22 +10:00
depends_build path:bin/pkg-config:pkgconfig
2018-09-19 16:43:02 +08:00
depends_lib port:bzip2 \
port:expat \
2021-12-26 18:08:36 +11:00
port:gettext-runtime \
2018-09-19 16:43:02 +08:00
port:libedit \
port:libffi \
port:ncurses \
2021-11-13 16:49:52 +11:00
path:lib/libssl.dylib:openssl \
2018-09-19 16:43:02 +08:00
port:sqlite3 \
port:xz \
port:zlib
2024-03-21 01:11:52 +11:00
set pythonVerNoDot [string map {. {}} $branch]
depends_run port:python_select-${pythonVerNoDot} \
port:python3_select-${pythonVerNoDot}
2018-09-19 16:43:02 +08:00
# blacklist llvm-gcc-4.2 compiler known to produce bad code
compiler.blacklist-append *llvm-gcc-4.2
2018-09-19 16:43:02 +08:00
# ensurepip arg may be removed later, now conflicts with pip and setuptools
# packages
configure.args --enable-framework=${frameworks_dir} \
--enable-ipv6 \
--enable-loadable-sqlite-extensions \
--with-computed-gotos \
--with-ensurepip=no \
--with-system-expat \
--with-system-ffi
configure.ccache no
# pkg-config removes -I flags for paths in CPATH, which confuses python.
configure.env PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
SETUPTOOLS_USE_DISTUTILS=stdlib
build.env SETUPTOOLS_USE_DISTUTILS=stdlib
destroot.env SETUPTOOLS_USE_DISTUTILS=stdlib
2018-09-19 16:43:02 +08:00
post-patch {
reinplace "s|@@PREFIX@@|${prefix}|g" \
${worksrcpath}/Lib/cgi.py \
${worksrcpath}/Lib/ctypes/macholib/dyld.py
reinplace "s|/setup.py|/setup.py --no-user-cfg|" ${worksrcpath}/Makefile.pre.in
# replace /Applications with ${applications_dir}
reinplace "s|@@APPLICATIONS_DIR@@|${applications_dir}|" \
${worksrcpath}/configure
}
build.target all
test.run yes
test.target test
destroot.target frameworkinstall maninstall
platform darwin {
2024-09-07 16:32:22 +10:00
set abiflags {}
2018-09-19 16:43:02 +08:00
post-configure {
2019-12-21 14:17:09 -05:00
# poll() misbehaves on 10.8 and older
2018-09-19 16:43:02 +08:00
# See https://trac.macports.org/ticket/18376
2019-12-21 14:17:09 -05:00
if {${os.platform} eq "darwin" && ${os.major} <= 12} {
2022-03-13 21:20:19 +11:00
set oldmtime [file mtime ${worksrcpath}/pyconfig.h]
2019-12-21 14:17:09 -05:00
system -W ${worksrcpath} "ed - pyconfig.h < ${filespath}/pyconfig.ed"
2022-03-13 21:20:19 +11:00
file mtime ${worksrcpath}/pyconfig.h $oldmtime
2019-12-21 14:17:09 -05:00
}
2018-09-19 16:43:02 +08:00
}
post-destroot {
2024-09-07 16:32:22 +10:00
set framewpath ${frameworks_dir}/Python.framework
set framewdir ${framewpath}/Versions/${branch}
set confdir config-${branch}${abiflags}-darwin
2018-09-19 16:43:02 +08:00
foreach dir { Headers Resources Python Versions/Current } {
file delete ${destroot}${framewpath}/${dir}
}
ln -s ${framewdir}/share/man/man1/python${branch}.1 ${destroot}${prefix}/share/man/man1/
ln -s ${framewdir}/lib/pkgconfig/python-${branch}.pc ${destroot}${prefix}/lib/pkgconfig/
ln -s ${framewdir}/lib/pkgconfig/python-${branch}-embed.pc ${destroot}${prefix}/lib/pkgconfig/
2018-09-19 16:43:02 +08:00
set libdir ${destroot}${framewdir}/lib/python${branch}
# Without this, LINKFORSHARED is set to
# ... $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
# (this becomes Python.framework/Versions/3.8/Python) which doesn't
# work for dependents that incorrectly use this variable to find out
# how to link against python (see ticket #15099); instead we mirror
# the behavior of `python-config --ldflags` here.
set lfs_pattern {^([[:space:]]*'LINKFORSHARED':).*}
set lfs_replacement "\\1 '-L${framewdir}/lib/python${branch}/${confdir} -lpython${branch} -ldl -framework CoreFoundation',"
reinplace -E s|${lfs_pattern}|${lfs_replacement}| \
2024-09-07 16:32:22 +10:00
${libdir}/_sysconfigdata_${abiflags}_darwin_darwin.py
# remove -arch flags from the config
reinplace -E {s|-arch [a-z0-9_]+||g} \
2024-09-07 16:32:22 +10:00
${libdir}/_sysconfigdata_${abiflags}_darwin_darwin.py
# also remove gettext overlinking
reinplace "s|-lintl||" \
2024-09-07 16:32:22 +10:00
${libdir}/_sysconfigdata_${abiflags}_darwin_darwin.py
# recompile the modified file
set python_for_build python.exe
# executable differs depending on filesystem case sensitivity
if {![file exists ${worksrcpath}/${python_for_build}]} {
set python_for_build python
}
2024-09-07 16:32:22 +10:00
system -W ${worksrcpath} "env DYLD_FRAMEWORK_PATH=. ./${python_for_build} -E -m compileall -d [shellescape ${framewdir}/lib/python${branch}] [shellescape ${libdir}/_sysconfigdata_${abiflags}_darwin_darwin.py]"
system -W ${worksrcpath} "env DYLD_FRAMEWORK_PATH=. ./${python_for_build} -E -O -m compileall -d [shellescape ${framewdir}/lib/python${branch}] [shellescape ${libdir}/_sysconfigdata_${abiflags}_darwin_darwin.py]"
system -W ${worksrcpath} "env DYLD_FRAMEWORK_PATH=. ./${python_for_build} -E -OO -m compileall -d [shellescape ${framewdir}/lib/python${branch}] [shellescape ${libdir}/_sysconfigdata_${abiflags}_darwin_darwin.py]"
2018-09-19 16:43:02 +08:00
# Also make the sysconfig changes in the Makefile
reinplace {s|^\(LINKFORSHARED=\).*$|\1 -L$(LIBPL) -lpython$(VERSION)$(ABIFLAGS) $(LIBS) $(SYSLIBS)|} \
${libdir}/${confdir}/Makefile
2018-09-19 16:43:02 +08:00
reinplace -E {s|-arch [a-z0-9_]+||g} \
${libdir}/${confdir}/Makefile
2018-09-19 16:43:02 +08:00
reinplace "s|-lintl||" \
${libdir}/${confdir}/Makefile
2018-09-19 16:43:02 +08:00
}
}
post-destroot {
foreach unversioned {2to3 idle3 pydoc3 python3 python3-config} {
2018-09-19 16:43:02 +08:00
delete ${destroot}${prefix}/bin/${unversioned}
}
}
notes "
To make this the default Python or Python 3 (i.e., the version run by\
the 'python' or 'python3' commands), run one or both of:
2024-03-21 01:11:52 +11:00
sudo port select --set python python$pythonVerNoDot
sudo port select --set python3 python$pythonVerNoDot
2018-09-19 16:43:02 +08:00
"
variant universal {
post-patch {
set universal_arch_flags {}
set arch_run_32bit {}
2021-07-03 17:10:15 +10:00
set lipo_32bit_flags {}
set lipo_intel64_flags {}
set any64 no
foreach arch ${configure.universal_archs} {
2018-09-19 16:43:02 +08:00
lappend universal_arch_flags -arch ${arch}
2021-07-03 17:10:15 +10:00
if {${arch} in {i386 ppc}} {
2018-09-19 16:43:02 +08:00
lappend arch_run_32bit -${arch}
2021-07-03 17:10:15 +10:00
lappend lipo_32bit_flags -extract ${arch}
} else {
set any64 yes
2018-09-19 16:43:02 +08:00
}
}
2021-07-03 17:10:15 +10:00
if {$any64} {
if {$arch_run_32bit eq ""} {
set arch_run_32bit true
set lipo_32bit_flags ""
} else {
set arch_run_32bit "/usr/bin/arch $arch_run_32bit"
#lipo_32bit_flags already correct
}
if {"arm64" in $universal_archs && "x86_64" in $universal_archs} {
set lipo_intel64_flags "-extract x86_64"
}
} else {
set arch_run_32bit ""
set lipo_32bit_flags ""
2018-09-19 16:43:02 +08:00
}
2021-07-03 17:10:15 +10:00
reinplace \
"s|@@UNIVERSAL_ARCH_FLAGS@@|${universal_arch_flags}|" \
${worksrcpath}/configure
reinplace \
"s|@@LIPO_32BIT_FLAGS@@|${lipo_32bit_flags}|" \
${worksrcpath}/configure
reinplace \
"s|@@LIPO_INTEL64_FLAGS@@|${lipo_intel64_flags}|" \
${worksrcpath}/configure
reinplace \
"s|@@ARCH_RUN_32BIT@@|${arch_run_32bit}|" \
${worksrcpath}/configure
2018-09-19 16:43:02 +08:00
}
2021-07-03 17:10:15 +10:00
configure.args-append --enable-universalsdk=${configure.sysroot}
2018-09-19 16:43:02 +08:00
post-configure {
2022-03-13 21:20:19 +11:00
set oldmtime [file mtime ${worksrcpath}/pyconfig.h]
2018-09-19 16:43:02 +08:00
system -W ${worksrcpath} "ed - pyconfig.h < ${filespath}/pyconfig.h-universal.ed"
2022-03-13 21:20:19 +11:00
file mtime ${worksrcpath}/pyconfig.h $oldmtime
2018-09-19 16:43:02 +08:00
}
post-destroot {
2021-07-03 17:10:15 +10:00
foreach unversioned {python3-32 python3-intel64} {
2018-09-19 16:43:02 +08:00
delete ${destroot}${prefix}/bin/${unversioned}
}
}
}
variant optimizations description {enable expensive, stable optimizations (including PGO)} {
2018-09-19 16:43:02 +08:00
configure.args-append --enable-optimizations
}
platform darwin {
# Build failures on 10.9 and older
if {${os.major} > 13} {
default_variants +optimizations
}
}
2021-09-07 00:16:39 +00:00
variant dtrace description {enable DTrace support} {
configure.args-append --with-dtrace
}
2019-03-04 08:42:12 -05:00
livecheck.type regex
livecheck.url ${homepage}downloads/source/
2019-10-16 22:10:35 -07:00
livecheck.regex Python (${branch}\[.0-9\]+) -