pantry/projects/python.org/package.yml

309 lines
10 KiB
YAML
Raw Normal View History

2022-08-02 14:03:17 +03:00
distributable:
url: https://www.python.org/ftp/python/{{ version.raw }}/Python-{{ version.raw }}.tar.xz
2022-08-02 14:03:17 +03:00
strip-components: 1
versions:
github: python/cpython/tags
ignore:
2023-07-08 21:22:04 +03:00
# FIXME maybe? linux+aarch64 doesn't build before 3.4.2,
# except 3.3.0, oddly.
- 3.4.[0-1]
- 3.3.[1-7]
2023-07-08 15:19:47 +03:00
- 3.[0-2].x
# We only currently have patches for 2.7.18 (EOL)
- 2.7.1[0-7]
- 2.7.[0-9]
- 2.[0-6].x
2022-08-02 14:03:17 +03:00
2022-10-30 17:32:32 +03:00
companions:
pip.pypa.io: '*'
unpackaged:
- version: ^2
platform: darwin
arch: aarc64
reason: help-wanted
2022-09-08 23:40:35 +03:00
provides:
- bin/python
- bin/python{{ version.major }}
- bin/python{{ version.marketing }}
2022-09-08 23:40:35 +03:00
interprets:
extensions: py
args: python
2022-08-02 14:03:17 +03:00
dependencies:
zlib.net: 1
2022-08-05 04:19:01 +03:00
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
2023-10-10 19:37:04 +03:00
tcl-lang.org: 8
2023-03-27 18:57:59 +03:00
# linux:
# oracle.com/berkeley-db: 18
2022-08-02 14:03:17 +03:00
build:
dependencies:
2022-08-05 04:19:01 +03:00
freedesktop.org/pkg-config: ^0.29
gnu.org/patch: '*'
curl.se: '*'
2023-05-08 21:51:47 +03:00
script:
# MacPorts has a series of patches to keep python2 working
- run: |
for PATCH in $PYTHON2PATCHES; do
curl -sSL $PATCH | patch -p0
done
if: ^2
2023-05-08 21:51:47 +03:00
# fixes the build scripts so they use the standard environment variables we set
2023-10-02 19:39:24 +03:00
- run: |
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
if: <3.12
2023-05-08 21:51:47 +03:00
# older versions use a different config dir
- run: |
confdir="$libdir/config"
# aarch64 not happy with this
ARGS=${ARGS/--with-ensurepip/--without-ensurepip}
if: ^2
# 3.7 and older use `3.7m` for config dir
- run: |
2023-05-08 21:51:47 +03:00
confdir=$(echo $confdir | sed -e 's/\(config-{{ version.marketing }}\)/\1m/')
# 3.7 and older use `python3.7m` for include dir
SUFFIX=m
# 3.7 aborts on linux+aarch64 with this
ARGS=${ARGS/--with-ensurepip/--without-ensurepip}
if: '>=3<3.8'
2023-04-21 10:30:10 +03:00
# 3.5 and older don't append the platform to confdir
- run: confdir="$libdir/config-{{version.marketing}}m"
if: '>=3<3.6'
# Older patches have configure issues that aren't present in newer patches
- run: |
if test "{{hw.platform}}" = "darwin"; then
sed -i.bak \
-e 's/ppc)/arm64)/g' \
-e 's/MACOSX_DEFAULT_ARCH="ppc.*$/MACOSX_DEFAULT_ARCH="arm64"/g' \
configure
rm configure.bak
fi
if: '>=3<3.9.1'
- run: |
if test "{{hw.platform}}" = "darwin"; then
sed -i.bak -e 's/^MULTIARCH=.*$/MULTIARCH=""/' configure
rm configure.bak
fi
if: '>=3<3.10.1'
# Some old versions don't support macOS 11 and greater in their configures
- run: |
if test "{{hw.platform}}" = "darwin"; then
curl -L https://github.com/python/cpython/commit/8ea6353.patch | patch -p1
fi
if: '>=3.8<3.8.4 || >=3<3.7.8'
# Versions older than 3.5.3 have an include issue on darwin
- run: patch -p1 < props/patch3.5.diff
if: '>=3.5<3.5.3'
# Whitespace difference in 3.4...
- run: patch -p1 < props/patch3.4.diff
if: '~3.4.1'
2023-10-02 19:39:24 +03:00
# 3.12.0 needs help with mpdecimal
- run: |
sed -i.bak 's/libmpdec_machine=universal/libmpdec_machine=x64/' configure
rm configure.bak
if: darwin/x86-64
- run: |
sed -i.bak 's/libmpdec_machine=universal/libmpdec_machine=uint128/' configure
rm configure.bak
if: darwin/aarch64
2023-05-08 21:51:47 +03:00
- ./configure $ARGS
- make --jobs {{ hw.concurrency }}
- make install
# customize `pip install` locations to tea defaults
2023-05-08 21:51:47 +03:00
- cp props/sitecustomize.py {{prefix}}/lib/python{{version.marketing}}
2022-09-08 23:40:35 +03:00
# provide unversioned symlinks
2023-05-08 21:51:47 +03:00
- run: |
for x in python idle pydoc; do
ln -sf ${x}{{ version.marketing }} $x
done
ln -sf python{{ version.marketing }}-config python-config
working-directory: ${{prefix}}/bin
2022-09-08 23:40:35 +03:00
# we provide the binaries in a separate package
# but we dont use --without-ensurepip because stuff expects python to
# come bundled with setuptools
2023-05-08 21:51:47 +03:00
- run: find . -mindepth 1 -maxdepth 1 -type f -name 'pip*' -exec rm {} \;
working-directory: ${{prefix}}/bin
2023-03-14 02:58:22 +03:00
2022-09-08 23:40:35 +03:00
# make relocatable
2023-05-08 21:51:47 +03:00
- run: |
for binfile in $shebangs $confdir/python-config.py; do
if ! test -f $binfile; then
binfile=${binfile/{{version.marketing}}/{{version.marketing}}$SUFFIX}
fi
if ! test -f $binfile; then
continue
fi
binfile=$(readlink -f $binfile)
sed -i.bak -e 's|#!{{ prefix }}/bin/|#!/usr/bin/env |g' $binfile
rm $binfile.bak
done
2023-10-02 17:17:26 +03:00
sed -i.bak -e 's|{{ prefix }}|\\$(or $(PKGX_DIR),$(HOME)/.pkgx)/python.org/v{{version.major}}|g' $confdir/Makefile
2023-05-08 21:51:47 +03:00
rm $confdir/Makefile.bak
working-directory: ${{prefix}}
- run: cat $PROP >> _sysconfigdata__*.py
working-directory: ${{prefix}}/lib/python{{version.marketing}}
2023-05-08 21:51:47 +03:00
prop: |
import os
import re
pkgx_prefix = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../../../'))
2023-05-08 21:51:47 +03:00
for key in build_time_vars:
if isinstance(build_time_vars[key], str):
build_time_vars[key] = re.sub(r'(\s|^)/opt/', r'\g<1>{}/'.format(pkgx_prefix), build_time_vars[key])
2022-08-02 14:03:17 +03:00
2023-03-20 16:10:55 +03:00
# force pip to user-install mode without sudo
2023-05-08 21:51:47 +03:00
- ln -s /dev {{prefix}}/lib/python{{version.marketing}}/site-packages
2023-03-20 16:10:55 +03:00
# ^^ probs nuts lol, but the below has repurcussions
# chmod -w {{prefix}}/lib/python{{version.marketing}}
# ^^ makes rm -rf ~/.tea/python.org on macOS fail
# some stuff expects python includes to be accessible without the prefix
2023-05-08 21:51:47 +03:00
- run: |
mv python{{version.marketing}}$SUFFIX/* .
rmdir python{{version.marketing}}$SUFFIX
ln -s . python{{version.marketing}}
# Keep the suffixed version if we started with one
if test -n "$SUFFIX"; then
ln -s . python{{version.marketing}}$SUFFIX
fi
working-directory: ${{prefix}}/include
2022-08-02 14:03:17 +03:00
env:
ARGS:
- --prefix="{{ prefix }}"
2023-03-20 16:10:55 +03:00
- --with-ensurepip
2022-08-02 14:03:17 +03:00
- --enable-ipv6
- --disable-loadable-sqlite-extensions
- --with-system-expat
- --with-system-ffi
- --with-system-libmpdec
# - --enable-optimizations # fails due to clang/llvm pkging bug on Linux
# - --with-lto # fails on linux/aarch64
2022-08-02 14:03:17 +03:00
- --enable-shared
libdir: lib/python{{version.marketing}}
2022-09-08 23:40:35 +03:00
darwin:
confdir: $libdir/config-{{version.marketing}}-darwin
PYTHON2PATCHES:
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-getpath.diff
2022-09-08 23:40:35 +03:00
linux:
2023-03-27 18:57:59 +03:00
# ARGS:
# - --with-dbmliborder=bdb
2022-09-08 23:40:35 +03:00
ARCH: ${{hw.arch}}
confdir: $libdir/config-{{version.marketing}}-${ARCH/-/_}-linux-gnu
2022-09-08 23:40:35 +03:00
shebangs:
- bin/2to3-{{version.marketing}}
- bin/idle{{version.marketing}}
- bin/pydoc{{version.marketing}}
- bin/python{{version.marketing}}-config
2022-08-10 21:58:22 +03:00
CPPFLAGS: ${CPPFLAGS:+$CPPFLAGS }-I{{ deps.zlib.net.prefix }}/include
LDFLAGS: ${LDFLAGS:+$LDFLAGS }-L{{ deps.zlib.net.prefix }}/lib
2022-09-25 16:06:15 +03:00
OPENSSL_INCLUDES: ${{ deps.openssl.org.prefix }}/include
OPENSSL_LDFLAGS: -L{{ deps.openssl.org.prefix }}/lib
PYTHON2PATCHES:
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-Makefile.pre.in.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-setup.py.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-Lib-cgi.py.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-Lib-ctypes-macholib-dyld.py.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-configure.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-libedit.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/enable-loadable-sqlite-extensions.patch
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/patch-_osx_support.py.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/darwin20.diff
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/arm.patch
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/implicit.patch
- https://raw.githubusercontent.com/macports/macports-ports/master/lang/python27/files/openssl_ver.patch
2022-08-10 21:58:22 +03:00
2022-08-02 14:03:17 +03:00
test:
dependencies:
crates.io/semverator: '*'
2023-05-08 21:51:47 +03:00
script:
# Check if sqlite is ok, because we build with --enable-loadable-sqlite-extensions
# and it can occur that building sqlite silently fails if OSX's sqlite is used.
- run: python -c "import sqlite3"
# FIXME: v2, <v3.7
if: ^3.7
# check to see if we can create a venv
2023-04-21 10:30:10 +03:00
# we can't ensurepip on 3.7 so, this won't work
- run: python -m venv myvenv
if: ^3.8
# Check if some other modules import. Then the linked libs are working.
- python -c "import zlib"
- python -c "import pyexpat"
# - python -c "import _decimal" # FIXME
# FIXME: darwin <3.6.4 fails
- run: |
if test "{{hw.platform}}" = "linux"; then
python -v -c "import _ctypes"
elif semverator gt {{version}} 3.6.3; then
python -v -c "import _ctypes"
fi
# Verify that the selected DBM interface works
2023-03-27 18:57:59 +03:00
# FIXME: doen't work
2023-05-08 21:51:47 +03:00
# - run:
# python $FIXTURE
# fixture: |
# import dbm
# with dbm.ndbm.open("test", "c") as db:
# db[b"foo \\xbd"] = b"bar \\xbd"
# with dbm.ndbm.open("test", "r") as db:
# assert list(db.keys()) == [b"foo \\xbd"]
# assert b"foo \\xbd" in db
# assert db[b"foo \\xbd"] == b"bar \\xbd"
- |
if which -a pip | grep '{{ prefix }}'; then
exit 1
fi
- run: |
mv $FIXTURE b.c
cc -c b.c
fixture: |
#include <Python.h>
#include <python{{version.major}}.{{version.minor}}/Python.h>
- run: SUFFIX=m
if: '>=3<3.8'
- run: test $(python $FIXTURE) = {{prefix}}/include/python{{version.marketing}}$SUFFIX
2023-05-08 21:51:47 +03:00
fixture: |
import sysconfig
include_path = sysconfig.get_paths()['include']
print(include_path)