Skip to content

Commit

Permalink
Merge pull request #3355 from mrmundt/release-no-cython
Browse files Browse the repository at this point in the history
Update Release Process Workflow for changes to `pip`
  • Loading branch information
mrmundt authored Aug 20, 2024
2 parents dc6eccd + cee756c commit 9b7c132
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 26 deletions.
59 changes: 50 additions & 9 deletions .github/workflows/release_wheel_creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
PYOMO_SETUP_ARGS: "--with-cython --with-distributable-extensions"

jobs:

native_wheels:
name: Build wheels (${{ matrix.wheel-version }}) on ${{ matrix.os }} for native and cross-compiled architecture
runs-on: ${{ matrix.os }}
Expand All @@ -31,14 +29,26 @@ jobs:
include:
- wheel-version: 'cp38*'
TARGET: 'py38'
GLOBAL_OPTIONS: "--with-cython --with-distributable-extensions"
- wheel-version: 'cp39*'
TARGET: 'py39'
GLOBAL_OPTIONS: "--with-cython --with-distributable-extensions"
- wheel-version: 'cp310*'
TARGET: 'py310'
GLOBAL_OPTIONS: "--with-cython --with-distributable-extensions"
- wheel-version: 'cp311*'
TARGET: 'py311'
GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions"
- wheel-version: 'cp312*'
TARGET: 'py312'
GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions"

exclude:
- wheel-version: 'cp311*'
os: windows-latest
- wheel-version: 'cp312*'
os: windows-latest

steps:
- uses: actions/checkout@v4
- name: Build wheels
Expand All @@ -47,13 +57,13 @@ jobs:
output-dir: dist
env:
CIBW_ARCHS_LINUX: "native"
CIBW_ARCHS_MACOS: "native arm64"
CIBW_ARCHS_WINDOWS: "native ARM64"
CIBW_SKIP: "*-musllinux*"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_WINDOWS: "AMD64 ARM64"
CIBW_BUILD: ${{ matrix.wheel-version }}
CIBW_SKIP: "*-musllinux*"
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_BUILD: pip install cython pybind11
CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
CIBW_ENVIRONMENT: PYOMO_SETUP_ARGS="${{ matrix.GLOBAL_OPTIONS }}"
- uses: actions/upload-artifact@v4
with:
name: native_wheels-${{ matrix.os }}-${{ matrix.TARGET }}
Expand All @@ -72,14 +82,19 @@ jobs:
include:
- wheel-version: 'cp38*'
TARGET: 'py38'
GLOBAL_OPTIONS: "--with-cython --with-distributable-extensions"
- wheel-version: 'cp39*'
TARGET: 'py39'
GLOBAL_OPTIONS: "--with-cython --with-distributable-extensions"
- wheel-version: 'cp310*'
TARGET: 'py310'
GLOBAL_OPTIONS: "--with-cython --with-distributable-extensions"
- wheel-version: 'cp311*'
TARGET: 'py311'
GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions"
- wheel-version: 'cp312*'
TARGET: 'py312'
GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions"
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
Expand All @@ -93,17 +108,43 @@ jobs:
output-dir: dist
env:
CIBW_ARCHS_LINUX: "aarch64"
CIBW_SKIP: "*-musllinux*"
CIBW_BUILD: ${{ matrix.wheel-version }}
CIBW_SKIP: "*-musllinux*"
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_BUILD: pip install cython pybind11
CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
CIBW_ENVIRONMENT: PYOMO_SETUP_ARGS="${{ matrix.GLOBAL_OPTIONS }}"
- uses: actions/upload-artifact@v4
with:
name: alt_wheels-${{ matrix.os }}-${{ matrix.TARGET }}
path: dist/*.whl
overwrite: true

pure_python:
name: pure_python_wheel
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel setuptools pybind11
- name: Build pure python wheel
run: |
python setup.py --without-cython sdist --format=gztar bdist_wheel
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: purepythonwheel
path: dist/*.whl
overwrite: true

generictarball:
name: ${{ matrix.TARGET }}
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[metadata]
license_files = LICENSE.md

[bdist_wheel]
universal=1

[tool:pytest]
filterwarnings = ignore::RuntimeWarning
junit_family = xunit2
Expand Down
32 changes: 18 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,30 @@ def get_version():
return import_pyomo_module('pyomo', 'version', 'info.py')['__version__']


def check_config_arg(name):
if name in sys.argv:
sys.argv.remove(name)
return True
if name in os.getenv('PYOMO_SETUP_ARGS', '').split():
return True
return False


CYTHON_REQUIRED = "required"
if not any(
arg.startswith(cmd) for cmd in ('build', 'install', 'bdist') for arg in sys.argv
arg.startswith(cmd)
for cmd in ('build', 'install', 'bdist', 'wheel')
for arg in sys.argv
):
using_cython = False
else:
elif sys.version_info[:2] < (3, 11):
using_cython = "automatic"
if '--with-cython' in sys.argv:
else:
using_cython = False
if check_config_arg('--with-cython'):
using_cython = CYTHON_REQUIRED
sys.argv.remove('--with-cython')
if '--without-cython' in sys.argv:
if check_config_arg('--without-cython'):
using_cython = False
sys.argv.remove('--without-cython')

ext_modules = []
if using_cython:
Expand Down Expand Up @@ -107,14 +118,7 @@ def get_version():
raise
using_cython = False

if ('--with-distributable-extensions' in sys.argv) or (
os.getenv('PYOMO_SETUP_ARGS') is not None
and '--with-distributable-extensions' in os.getenv('PYOMO_SETUP_ARGS')
):
try:
sys.argv.remove('--with-distributable-extensions')
except:
pass
if check_config_arg('--with-distributable-extensions'):
#
# Import the APPSI extension builder
# NOTE: There is inconsistent behavior in Windows for APPSI.
Expand Down

0 comments on commit 9b7c132

Please sign in to comment.