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:
parent
b9eebf1c79
commit
3ff6bdd8ba
1 changed files with 7 additions and 11 deletions
|
|
@ -50,16 +50,6 @@ python -c 'import sys; print(sys.version)' | head -n1 | grep $VERSION
|
||||||
|
|
||||||
# install packages with pip
|
# install packages with pip
|
||||||
python -m pip install pytest
|
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
|
# run tests
|
||||||
cat > test_foo.py << EOF
|
cat > test_foo.py << EOF
|
||||||
|
|
@ -80,6 +70,12 @@ def two():
|
||||||
return add(a, b)
|
return add(a, b)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
cat > pyproject.toml << EOF
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools", "cython"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
EOF
|
||||||
|
|
||||||
cat > setup.py << EOF
|
cat > setup.py << EOF
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from Cython.Build import cythonize
|
from Cython.Build import cythonize
|
||||||
|
|
@ -87,7 +83,7 @@ from Cython.Build import cythonize
|
||||||
setup(ext_modules = cythonize('module.pyx'))
|
setup(ext_modules = cythonize('module.pyx'))
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
python setup.py build_ext --inplace
|
python -m pip install .
|
||||||
|
|
||||||
python -c 'import module; print(module.two())' | grep '^2$'
|
python -c 'import module; print(module.two())' | grep '^2$'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue