Skip to content

Commit dc03503

Browse files
authored
Build wheels with cibuildwheel action (#698)
* shouldn't need to patch CFLAGS any more * duplicate from mt2, restrict python versions * start the pyproject.toml * we should be able to build for python 3.13 too * start thinning * thin * shouldn't need `wheel` now * no linting here * dev dependencies * improve * src layout * update for src layout * don't gitignore hypervolume.cpp * remove executable bit * standardise MANIFEST.in, fix for src/ layout * tweak * fix deprecation warnings * cleaner * just test importable * pymoo doesn't support freethreaded python * dead block * remove maxfail * bump lowest nump * fast test for now * actually, use nsga2 test * delete old workflows * suggest simplification * require sufficiently recent uv * not much luck with matplotlib, so drop 32-bit builds * cibuildwheel only has uv 0.6.9 * move out of src/ again * no src/ * cleanup * back to src/ layout * update email address * put back * simplify * merge * include lock file for reproducibility * include the Makefile * idea * specify packages * escape differently * moo * moo * hmm * single line * debug sys.path * we need to dedent * dent * maybe now?! * blank * give up * better discovery * cwd * more * more debug * oops * aha * more minimal * oops * don't add lock file * propose replacement * don't need to change Makefile * don't _need_ a uv bound * recursive * one clean, no clean-pyc * closer * moo * remove unused import * newer setuptools for testing * newest setuptools * pip.... * try harder
1 parent a802b64 commit dc03503

File tree

9 files changed

+144
-274
lines changed

9 files changed

+144
-274
lines changed

.github/workflows/build.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
tags: ["*"]
8+
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
15+
jobs:
16+
build_wheels:
17+
name: Build wheel for ${{ matrix.os }}-${{ matrix.build }}${{ matrix.python }}-${{ matrix.arch }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
# Ensure that a wheel builder finishes even if another fails
21+
fail-fast: false
22+
matrix:
23+
os: [windows-latest, ubuntu-latest, macos-latest]
24+
python: [39, 310, 311, 312, 313]
25+
arch: [auto64, universal2]
26+
build: ["cp"]
27+
exclude:
28+
- os: ubuntu-latest
29+
arch: universal2
30+
- os: windows-latest
31+
arch: universal2
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: astral-sh/setup-uv@v5
35+
- uses: pypa/[email protected]
36+
env:
37+
CIBW_BUILD_FRONTEND: "build[uv]"
38+
CIBW_BUILD: "${{ matrix.build }}${{ matrix.python }}*"
39+
CIBW_ARCHS: ${{ matrix.arch }}
40+
CIBW_TEST_COMMAND: >
41+
uv run python -c "import sys; import pymoo; print(pymoo); from pymoo.util.function_loader import is_compiled; sys.exit(0 if is_compiled() else 42)"
42+
43+
- uses: actions/upload-artifact@v4
44+
with:
45+
name: "artifact-${{ matrix.os }}-${{ matrix.build }}-${{ matrix.python }}-${{ matrix.arch }}"
46+
path: ./wheelhouse/*.whl
47+
48+
build_sdist:
49+
name: Build source distribution
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: astral-sh/setup-uv@v5
54+
- run: uv build --sdist
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: artifact-source
58+
path: dist/*.tar.gz
59+
60+
merge:
61+
name: Merge sdist and wheel artifacts
62+
needs: [build_wheels, build_sdist]
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/upload-artifact/merge@v4
66+
with:
67+
name: pymoo
68+
delete-merged: true
69+

.github/workflows/deploy.yml

-74
This file was deleted.

.github/workflows/testing.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
python-version: '3.10'
2020
- name: Install Dependencies
2121
run: |
22+
pip install --no-cache-dir --upgrade setuptools>=77.0
2223
pip install numpy Cython scipy
2324
pip install -r tests/requirements.txt
2425
- name: Install pymoo (DEBUG)

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**/*.npy
55
**/*.png
66
**/*.gif
7-
**/*.cpp
7+
pymoo/cython/*.cpp
88
**/nohup.out
99
benchmark
1010
wheelhouse
@@ -141,3 +141,6 @@ ENV/
141141

142142
# mypy
143143
.mypy_cache/
144+
145+
# Package manager lock files
146+
uv.lock

MANIFEST.in

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
prune .
2-
recursive-include pymoo *.py *.pyx *.pxd
3-
recursive-include pymoo/cython/vendor *.cpp *.h *.py
4-
include LICENSE Makefile pyproject.toml
1+
exclude tests/*
2+
recursive-include pymoo *.pyx *.pxd
3+
recursive-include pymoo/cython/vendor *.cpp *.h
4+
include Makefile

Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
.PHONY: clean
12
clean:
23
rm -rf build dist pymoo.egg-info
34

5+
.PHONY: clean-ext
46
clean-ext:
57
rm -f pymoo/cython/*.c
68
rm -f pymoo/cython/*.so
79
rm -f pymoo/cython/*.cpp
810
rm -f pymoo/cython/*.html
911

12+
.PHONY: compile
1013
compile:
1114
python setup.py build_ext --inplace
1215

13-
compile-without-cython:
14-
python setup.py build_ext --inplace --no-cython
15-
16+
.PHONY: dist
1617
dist:
1718
python setup.py sdist
1819

20+
.PHONY: install
1921
install:
2022
python setup.py install
2123

pymoo/cython/calc_perpendicular_distance.pyx

100755100644
File mode changed.

pyproject.toml

+55-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,59 @@
1-
[build-system]
2-
requires = ["setuptools<72.2", "wheel", "numpy>=1.15", "Cython>=0.29"]
1+
[project]
2+
name = "pymoo"
3+
description = "Multi-Objective Optimization in Python"
4+
authors = [{ name = "Julian Blank", email = "[email protected]" }]
5+
readme = "README.rst"
6+
license = "Apache-2.0"
7+
classifiers = [
8+
'Intended Audience :: Developers',
9+
'Intended Audience :: Science/Research',
10+
'Operating System :: OS Independent',
11+
'Programming Language :: Python',
12+
'Programming Language :: Python :: 3',
13+
'Programming Language :: Python :: 3.9',
14+
'Programming Language :: Python :: 3.10',
15+
'Programming Language :: Python :: 3.11',
16+
'Programming Language :: Python :: 3.12',
17+
'Programming Language :: Python :: 3.13',
18+
'Topic :: Scientific/Engineering',
19+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
20+
'Topic :: Scientific/Engineering :: Mathematics',
21+
]
22+
keywords = ["optimization"]
23+
dynamic = ["version"]
24+
urls = { homepage = "https://pymoo.org" }
25+
requires-python = ">= 3.9"
26+
dependencies = [
27+
"numpy>=1.19.3",
28+
"scipy>=1.1",
29+
"matplotlib>=3",
30+
"autograd>=1.4",
31+
"cma>=3.2.2",
32+
"alive-progress",
33+
"dill",
34+
"Deprecated",
35+
]
336

4-
[tool.cibuildwheel]
5-
build-verbosity = 1
6-
before-all = "uname -a"
37+
[build-system]
38+
requires = ["setuptools>=77", "numpy", "Cython>=0.29"]
39+
build-backend = "setuptools.build_meta"
740

8-
[tool.cibuildwheel.linux]
9-
archs = ["x86_64"]
41+
[tool.setuptools.dynamic]
42+
version = { attr = "pymoo.version.__version__" }
1043

11-
[tool.cibuildwheel.windows]
12-
archs = ["x86", "AMD64"]
44+
[tool.setuptools.packages.find]
45+
where = ["."]
46+
include = ["pymoo*"]
1347

14-
[tool.cibuildwheel.macos]
15-
archs = ["arm64"]
48+
[dependency-groups]
49+
dev = [
50+
"numba",
51+
"pytest",
52+
"nbformat",
53+
"jupyter",
54+
"pyrecorder",
55+
"optproblems",
56+
"pandas",
57+
"ipython",
58+
"ipykernel",
59+
]

0 commit comments

Comments
 (0)