pantry/projects/python.org/package.yml
2022-09-25 09:35:32 -04:00

131 lines
4.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

distributable:
url: https://www.python.org/ftp/python/{{ version }}/Python-{{ version }}.tar.xz
strip-components: 1
versions:
github: python/cpython/tags
provides:
- bin/python
- bin/python3
- bin/pip
- bin/pip3
dependencies:
# recommended but none are actually required
zlib.net: 1
sourceware.org/bzip2: 1
openssl.org: ^1.1
sourceware.org/libffi: 3
libexpat.github.io: 2
bytereef.org/mpdecimal: 2
tukaani.org/xz: 5
sqlite.org: 3
gnu.org/readline: 8
invisible-island.net/ncurses: 6
#TODO pip should be python.org/pip and installed by default (as a recommended dependent) with python
#RATIONALE it is independently versioned
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
freedesktop.org/pkg-config: ^0.29
#TODO use the diff
#TODO $libdir/_sysconfigdata__darwin_darwin.py contains non-relocatable paths
script: |
sed -i.bak -e 's|system_lib_dirs = .*|system_lib_dirs = os.getenv("LIBRARY_PATH").split(":")|' ./setup.py
sed -i.bak -e 's|system_include_dirs = .*|system_include_dirs = os.getenv("CPATH").split(":")|' ./setup.py
./configure $ARGS
make --jobs {{ hw.concurrency }}
make install
# provide unversioned symlinks
cd {{prefix}}/bin
for x in python pip idle pydoc; do
ln -sf ${x}{{ version.marketing }} $x
done
ln -sf python{{ version.marketing }}-config python-config
# strangely pip3 is a copy of pip3.10
if test ! -L pip{{version.major}}; then
rm pip{{version.major}}
ln -s pip{{version.marketing}} pip{{version.major}}
fi
# make relocatable
cd {{prefix}}
for binfile in $shebangs $confdir/python-config.py; do
sed -i.bak -e 's|#!{{ prefix }}/bin/|#!/usr/bin/env |g' $binfile
rm $binfile.bak
done
sed -i.bak -e 's|{{ prefix }}|\\$(shell tea --prefix)/python.org/v{{version.major}}|g' $confdir/Makefile
rm $confdir/Makefile.bak
env:
ARGS:
- --prefix="{{ prefix }}"
# its 202x
- --enable-ipv6
# prevent auto updates -> we control that
# - --without-ensurepip
- --disable-loadable-sqlite-extensions
# use our libraries not the bundled ones
- --with-system-expat
- --with-system-ffi
- --with-system-libmpdec
# these two make our binary not portable
#- --enable-optimizations
#- --with-lto
# on macOS we want an option that is instead --enable-framework
- --enable-shared
libdir:
lib/python{{version.marketing}}
darwin:
confdir:
$libdir/config-{{version.marketing}}-darwin
linux:
ARCH: ${{hw.arch}}
confdir:
$libdir/config-{{version.marketing}}-${ARCH/-/_}-linux-gnu
shebangs:
- bin/2to3-{{version.marketing}}
- bin/idle{{version.marketing}}
- bin/pip{{version.marketing}}
- bin/pydoc{{version.marketing}}
- bin/python{{version.marketing}}-config
OPENSSL_INCLUDES: ${{ deps.openssl.org.prefix }}/include
OPENSSL_LDFLAGS: -L{{ deps.openssl.org.prefix }}/lib
#FIXME we should get the include path from the ncurses `.pc` files
CPATH: ${{ deps.invisible-island.net/ncurses.prefix }}/include/ncursesw:$CPATH
# required for `setup.py` which is used to detect the libs for pythons modules
diff: |
diff --git a/setup.py b/setup.py
index 85a2b26..4f2f742 100644
--- a/setup.py
+++ b/setup.py
@@ -847,8 +847,8 @@ class PyBuildExt(build_ext):
add_dir_to_list(self.compiler.include_dirs,
sysconfig.get_config_var("INCLUDEDIR"))
- system_lib_dirs = ['/lib64', '/usr/lib64', '/lib', '/usr/lib']
- system_include_dirs = ['/usr/include']
+ system_lib_dirs = os.getenv("LIBRARY_PATH").split(":")
+ system_include_dirs = os.getenv("CPATH").split(":")
# lib_dirs and inc_dirs are used to search for files;
# if a file is found in one of those directories, it can
# be assumed that no additional -I,-L directives are needed.
test:
#TODO test all modules eg zlib module
script: |
python --version
pip --version