From 3ff6bdd8ba4e5d72f20bf0384f754dd1d68f07d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 28 Apr 2023 13:16:42 +0200 Subject: [PATCH] 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. --- smoke/venv.sh | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/smoke/venv.sh b/smoke/venv.sh index d52ce65..8c0d4c9 100755 --- a/smoke/venv.sh +++ b/smoke/venv.sh @@ -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