Don't execute setup.py directly, always use pip

Since Python 3.12, virtual environments don't have setuptools,
instead, pip will install it to an isolated build environment.
This commit is contained in:
Miro Hrončok 2023-04-28 13:16:42 +02:00
commit 3ff6bdd8ba

View file

@ -50,16 +50,6 @@ python -c 'import sys; print(sys.version)' | head -n1 | grep $VERSION
# install packages with pip
python -m pip install pytest
if [ "$CYTHON" == "true" ]; then
if [ "$VERSION" == "3.12" ]; then
# Cython support for 3.12.0a1+ is not yet released
python -m pip install https://github.com/cython/cython/archive/master.tar.gz --install-option="--no-cython-compile"
else
# We try to fetch a wheel only and if that fails, we disable compilation
# Useful for fresh CPythons, where wheels are not yet ready, but Cython defaults to compiling
python -m pip install Cython --only-binary :all: || python -m pip install Cython --install-option="--no-cython-compile"
fi
fi
# run tests
cat > test_foo.py << EOF
@ -80,6 +70,12 @@ def two():
return add(a, b)
EOF
cat > pyproject.toml << EOF
[build-system]
requires = ["setuptools", "cython"]
build-backend = "setuptools.build_meta"
EOF
cat > setup.py << EOF
from setuptools import setup
from Cython.Build import cythonize
@ -87,7 +83,7 @@ from Cython.Build import cythonize
setup(ext_modules = cythonize('module.pyx'))
EOF
python setup.py build_ext --inplace
python -m pip install .
python -c 'import module; print(module.two())' | grep '^2$'
fi