Skip to content

Commit

Permalink
[MRG] Fix builds on Python < 3.12 (#583)
Browse files Browse the repository at this point in the history
* Force stdlib distuils

* I guess these don't stack

* Fix sdist?

* Conditionally set SETUPTOOLS_USE_DISTUTILS

* Fix falsey value

* fix circleci?

* Just do equality check

* Remove fail-fast

* Add comment
  • Loading branch information
aaronreidsmith authored Nov 7, 2024
1 parent 11e5708 commit 22cb5ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
env:
PYTHON_VERSION: ${{ format('3.{0}', matrix.python3-minor-version) }}
PYTHON_EXECUTABLE: ${{ format('cp3{0}', matrix.python3-minor-version) }}
SETUPTOOLS_USE_DISTUTILS: ${{ matrix.python3-minor-version == 12 && 'local' || 'stdlib' }}

runs-on: ${{ matrix.os }}
name: Build and Deploy (${{ matrix.os }}, 3.${{ matrix.python3-minor-version }})
Expand Down Expand Up @@ -73,8 +74,8 @@ jobs:
pip install -r build_tools/build_requirements.txt &&
pip install -r requirements.txt
CIBW_BUILD: "${{ env.PYTHON_EXECUTABLE }}-*"
CIBW_ENVIRONMENT: CC=gcc
CIBW_ENVIRONMENT_MACOS: PMD_MPL_BACKEND=TkAgg PYTHON_CROSSENV=true
CIBW_ENVIRONMENT: CC=gcc SETUPTOOLS_USE_DISTUTILS=${{ env.SETUPTOOLS_USE_DISTUTILS }}
CIBW_ENVIRONMENT_MACOS: PMD_MPL_BACKEND=TkAgg PYTHON_CROSSENV=true SETUPTOOLS_USE_DISTUTILS=${{ env.SETUPTOOLS_USE_DISTUTILS }}
CIBW_ENVIRONMENT_PASS_LINUX: GITHUB_REF
# No support for pypy or musl
CIBW_SKIP: "pp* *-musllinux_*"
Expand Down
8 changes: 8 additions & 0 deletions build_tools/circle/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ function build_wheel {
ucs_tag="${ucs_tag}u"
fi

distutils_version=""
if [ "$pyver" = "3.12" ]; then
distutils_version="local"
else
distutils_version="stdlib"
fi

ML_PYTHON_VERSION=$(python -c \
"print('cp{maj}{min}-cp{maj}{min}{ucs}'.format( \
maj='${pyver}'.split('.')[0], \
Expand All @@ -33,6 +40,7 @@ function build_wheel {
-v `pwd`:/io \
-e "PYTHON_VERSION=${ML_PYTHON_VERSION}" \
-e "PMDARIMA_VERSION=${PMDARIMA_VERSION}" \
-e "SETUPTOOLS_USE_DISTUTILS=${distutils_version}" \
"${ML_IMAGE}" "/io/build_tools/circle/dind/build_manylinux_wheel.sh"
sudo docker cp "${DOCKER_CONTAINER_NAME}:/io/dist/." "${_root}/dist/"
docker rm $(docker ps -a -f status=exited -q)
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ def do_setup():
from setuptools import setup
print("Setting up with setuptools")

# Needs to be unset when building sdist
os.environ.pop("SETUPTOOLS_USE_DISTUTILS", None)

# TODO: distutils is removed in Python 3.12+, so this should probably be the default
if IS_PYTHON_312:
from setuptools import Extension
Expand Down

0 comments on commit 22cb5ce

Please sign in to comment.