Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add building wheels using cibuildwheel #1155

Merged
merged 235 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
235 commits
Select commit Hold shift + click to select a range
3dcb268
WIP on using pyproject.toml
JCGoran Feb 5, 2024
b2939d2
Use `pip wheel` instead of `setup.py bdist_wheel`
JCGoran Feb 5, 2024
66da08d
Fix formatting
JCGoran Feb 5, 2024
8ac280e
Do not use `-r reqs` when building wheel
JCGoran Feb 5, 2024
5246907
Wrong flag for `pip wheel`
JCGoran Feb 5, 2024
dc494a2
Fix tabs
JCGoran Feb 5, 2024
3904905
Specify exact wheel we will use in CI
JCGoran Feb 5, 2024
e2ba8bd
Update runtime dependencies
JCGoran Feb 5, 2024
6e4c626
Only repair the NMODL wheel
JCGoran Feb 5, 2024
58be003
Revert "Specify exact wheel we will use in CI"
JCGoran Feb 6, 2024
f373d31
Use `python -m build` instead of `pip wheel`
JCGoran Feb 6, 2024
97774cb
Add workaround for PEP 621 not allowing a dynamic `name`
JCGoran Feb 6, 2024
3595c04
Use `scikit-build-core` as the build backend
JCGoran Feb 7, 2024
5dfab36
Add missing packages to wheel
JCGoran Feb 7, 2024
3e62103
Use cmake.define key instead of cmake.args
JCGoran Feb 7, 2024
8c45d57
Refactor the nmodl wrapper
JCGoran Feb 7, 2024
2a221a1
Added optional dependencies
JCGoran Feb 7, 2024
c558e80
Remove unused script in setup.py
JCGoran Feb 8, 2024
6870fe0
Workaround for wheel build failure on MacOS
JCGoran Feb 8, 2024
60d845d
Change mode of `change_name.py`
JCGoran Feb 11, 2024
4c9cae7
Add file for showing dependencies
JCGoran Feb 11, 2024
aa533ac
Use `show_deps.py` to get requirements in CI
JCGoran Feb 11, 2024
8c0181f
Fix typo in docs CI
JCGoran Feb 11, 2024
3686a04
Add numpy to test deps
JCGoran Feb 12, 2024
0c72f23
Remove setup.py
JCGoran Feb 12, 2024
5af5354
Add min cmake version
JCGoran Feb 12, 2024
f7e08da
Reorder items in pyproject.toml
JCGoran Feb 12, 2024
1b3562e
Enable debug logging when building wheel
JCGoran Feb 12, 2024
a6f3d57
Remove explicit build dir on MacOS
JCGoran Feb 12, 2024
991d3e5
Fix condition in packaging script
JCGoran Feb 12, 2024
9b34ba1
Fix script for testing wheels
JCGoran Feb 12, 2024
0301ef7
Add workaround for symlinked /tmp on MacOS
JCGoran Feb 12, 2024
c22b23d
Relax build and runtime reqs
JCGoran Feb 15, 2024
7cfc27c
Remove textwrap dependency
JCGoran Feb 15, 2024
e18e851
Rearrange cmake options
JCGoran Feb 15, 2024
5e51d2a
Be explicit about Python version in pyproject
JCGoran Feb 15, 2024
bcabef3
Add GHA for building wheels using cibuildwheel
JCGoran Feb 15, 2024
f298692
Add flex and bison to CI
JCGoran Feb 15, 2024
f0cac17
Use GHA if to be platform independent
JCGoran Feb 15, 2024
de1ce19
Use winflexbison3 on Windows
JCGoran Feb 15, 2024
9c84c5e
Skip PyPy builds
JCGoran Feb 15, 2024
d126b62
Don't build on ubuntu just yet
JCGoran Feb 15, 2024
944993e
Fix homebrewed bison and flex paths
JCGoran Feb 15, 2024
f515a75
Workaround for that stupid cmake symlink bug
JCGoran Feb 15, 2024
c9e5379
Workaround for filesystem path on MacOS
JCGoran Feb 15, 2024
12888dc
Workaround for homebrew path
JCGoran Feb 15, 2024
c7b1e35
Remove POSIX-specific headers
JCGoran Feb 15, 2024
3f4edd9
Rename `parser.py` to `language_parser.py`
JCGoran Feb 15, 2024
f7479b4
Disable Windows build for now
JCGoran Feb 15, 2024
7a0066c
Use custom manylinux image for x86 and arm64
JCGoran Feb 15, 2024
e4e3be1
Use `CIBW_BEFORE_BUILD_LINUX` to install bison/flex
JCGoran Feb 15, 2024
79835d9
Add custom deps on Linux CI
JCGoran Feb 15, 2024
0ff22e9
Skip 32-bit builds for now
JCGoran Feb 15, 2024
544d5e0
TEMP remove x86 so arm can actually try to build
JCGoran Feb 15, 2024
8dc35b9
TEMP also remove musllinux stuff so we can actually build arm
JCGoran Feb 15, 2024
c4a1ffe
TEMP typo
JCGoran Feb 15, 2024
33ff2e8
TEMP Only build arm?
JCGoran Feb 15, 2024
4c0ec4e
TEMP maybe it works now?
JCGoran Feb 15, 2024
237ea12
The one that more or less works (minus Windows)
JCGoran Feb 15, 2024
d4bf54a
TEMP windows debug
JCGoran Feb 15, 2024
7409319
Add circleCI for aarch64 Linux builds
JCGoran Feb 15, 2024
f71b07c
Add installation of flex and bison before
JCGoran Feb 15, 2024
e989378
Fix custom paths to flex and bison
JCGoran Feb 15, 2024
c593efc
Try a fix for jinja and paths
JCGoran Feb 15, 2024
ee3a095
Revert "Try a fix for jinja and paths"
JCGoran Feb 15, 2024
2ac0152
Skip pypy wheels on circleCI
JCGoran Feb 15, 2024
290a608
Also don't build musllinux for now
JCGoran Feb 15, 2024
ce6f645
Be more strict about resolving paths maybe?
JCGoran Feb 15, 2024
32a67ba
Update .circleci/config.yml
JCGoran Feb 15, 2024
5225ea4
TEMP Try the main jinja branch?
JCGoran Feb 16, 2024
6258e34
Revert "TEMP Try the main jinja branch?"
JCGoran Feb 16, 2024
16c5076
TEMP only build on Python 3.11 on Windows
JCGoran Feb 16, 2024
17aa9d1
Fix for fmt installation
JCGoran Feb 16, 2024
2bd0b5c
Fix for fmt installation
JCGoran Feb 16, 2024
1807b97
Make formatter happt
JCGoran Feb 16, 2024
af7b123
Make formatter happy
JCGoran Feb 16, 2024
0613b01
Merge branch 'master' into jelic/pyproject
JCGoran Feb 16, 2024
74052a5
Move custom cibuildwheel config to pyproject.toml
JCGoran Feb 16, 2024
8683762
Use `before-all` instead of `before-build` for ext
JCGoran Feb 16, 2024
5b3dbfd
Add testing using cibuildwheel
JCGoran Feb 17, 2024
b12a862
Remove script for building wheels
JCGoran Feb 17, 2024
4900d16
Remove wheel building on Azure
JCGoran Feb 17, 2024
b0e4b35
Simplify tests even more
JCGoran Feb 17, 2024
3da19ca
Add pytest tests
JCGoran Feb 17, 2024
814a203
TEMP try to install libpython?
JCGoran Feb 17, 2024
8ccbbd0
Remove tests for cli for now
JCGoran Feb 17, 2024
f1f1f4a
Add setuptools to runtime deps
JCGoran Feb 17, 2024
5265c42
Add setuptools to runtime deps
JCGoran Feb 17, 2024
3e7cc6a
Move all setup.cfg settings to pyproject.toml
JCGoran Feb 18, 2024
eba6c6b
Working copy (without Windows)
JCGoran Feb 18, 2024
a54c558
For real this time
JCGoran Feb 18, 2024
db9054e
Greatly simplify the wheel testing
JCGoran Feb 18, 2024
5ff006d
Revert "Be more strict about resolving paths maybe?"
JCGoran Feb 19, 2024
51f7610
Move some setup.cfg settings to pyproject.toml
JCGoran Feb 18, 2024
8e79c27
Move some setup.cfg settings to pyproject.toml
JCGoran Feb 18, 2024
8d67f69
Remove `show_deps.py` in favor of `pip-tools`
JCGoran Feb 19, 2024
e36e0e7
Replace `pkg_resources` with `importlib`
JCGoran Feb 19, 2024
4873e76
Replace `pkg_resources` with `importlib`
JCGoran Feb 19, 2024
824a63c
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Feb 19, 2024
4128b68
Forgot one pip-compile
JCGoran Feb 19, 2024
c3ceca3
Fix typo
JCGoran Feb 19, 2024
36750f0
Replace `pkg_resources` with `importlib`
JCGoran Feb 19, 2024
652a985
Fix CI
JCGoran Feb 19, 2024
53a1456
Replace `pkg_resources` with `importlib`
JCGoran Feb 19, 2024
43cccf2
Fix bug in setting path
JCGoran Feb 19, 2024
cf5b9ff
Fix bug in setting path
JCGoran Feb 19, 2024
8cc5723
Be more specific about error raised
JCGoran Feb 19, 2024
9fabd81
Be more specific about error raised
JCGoran Feb 19, 2024
932d062
Add tests for CLI in CI
JCGoran Feb 19, 2024
94a2a72
Fix for NMODL sympy visitor
JCGoran Feb 20, 2024
63382d6
Refactor generation of docs
JCGoran Feb 20, 2024
02191de
Fix for NMODL sympy visitor
JCGoran Feb 20, 2024
8073f4b
WIP on using azure for CI
JCGoran Feb 21, 2024
6a6433b
Do not redefine `LINK_AGAINST_PYTHON`
JCGoran Feb 21, 2024
b8f793b
Define skip builds in pyproject.toml
JCGoran Feb 21, 2024
6f83d3b
Remove `env` from wheel CI jobs
JCGoran Feb 21, 2024
e54ee01
WIP on azure pipeline Linux testing
JCGoran Feb 22, 2024
dc1d5cd
Maybe fix azure?
JCGoran Feb 22, 2024
7787169
Fix ordering in azure
JCGoran Feb 22, 2024
bc7aa9b
Maybe now
JCGoran Feb 22, 2024
dc60c56
Okay for real this time
JCGoran Feb 22, 2024
ab8f364
Change name to please CI overlord
JCGoran Feb 22, 2024
37aff68
TEMP only build cp311 so we can debug azure faster
JCGoran Feb 22, 2024
f3f49ea
Forgot the base image, thanks azure
JCGoran Feb 22, 2024
c759aa3
Depend on manylinux wheel first
JCGoran Feb 22, 2024
b978878
SETUPTOOLS_PRETEND_VERSION is better
JCGoran Feb 22, 2024
81c27bb
DEBUG remove python
JCGoran Feb 22, 2024
7eded52
Revert "DEBUG remove python"
JCGoran Feb 22, 2024
8cae14b
Do not use python.version for uploading wheels
JCGoran Feb 22, 2024
99b3eed
WIP on venv in azure
JCGoran Feb 22, 2024
dc24684
Debug azure
JCGoran Feb 22, 2024
f0c0a3e
Download artifacts before testing wheels
JCGoran Feb 22, 2024
6c04eec
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Feb 22, 2024
793e27f
Merge branch 'master' into jelic/pyproject
JCGoran Feb 22, 2024
1ca8144
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Feb 22, 2024
339ee23
Use pip for building wheels
JCGoran Feb 22, 2024
c6657c8
Correctly pass env variables for manylinux wheel
JCGoran Feb 24, 2024
cdf8eab
Merge branch 'master' into jelic/pyproject
JCGoran Feb 26, 2024
b6e3165
Fix test script
JCGoran Feb 26, 2024
9b262a6
Merge branch 'master' into jelic/cibw
JCGoran Feb 26, 2024
1c87a1a
Debug linux version
JCGoran Feb 26, 2024
b396385
Fix version
JCGoran Feb 26, 2024
ca9d55a
Merge branch 'master' into jelic/pyproject
JCGoran Feb 26, 2024
8839976
Merge branch 'master' into jelic/cibw
JCGoran Feb 26, 2024
1248829
Revert "Do not redefine `LINK_AGAINST_PYTHON`"
JCGoran Feb 26, 2024
8051d50
Revert "Do not redefine `LINK_AGAINST_PYTHON`"
JCGoran Feb 26, 2024
812a5fd
Update test-command and test script
JCGoran Feb 26, 2024
b0cec6d
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Feb 26, 2024
ab4d2e8
Fix unbound variable
JCGoran Feb 26, 2024
ade464f
Fix getting dir on macOS
JCGoran Feb 26, 2024
9fbcf43
Merge branch 'master' into jelic/pyproject
JCGoran Feb 26, 2024
144b579
Do not install headers when building wheel
JCGoran Feb 26, 2024
870eab4
Merge branch 'master' into jelic/pyproject
JCGoran Feb 27, 2024
a47e449
Be more general about the test requirements for wheel
JCGoran Feb 27, 2024
1ead3a4
Move nmodl Python bindings to `python/nmodl`
JCGoran Feb 27, 2024
4dd0cde
Minor fixes for testing
JCGoran Feb 27, 2024
a75d656
Fix wheel.packages
JCGoran Feb 27, 2024
3a8640e
Copy also files from build dir
JCGoran Feb 27, 2024
6453a1e
Revert "Copy also files from build dir"
JCGoran Feb 27, 2024
8eb4c84
Fix for cmake build
JCGoran Feb 27, 2024
8a34ab1
Merge branch 'master' into jelic/pyproject
JCGoran Feb 27, 2024
c4ede53
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Feb 28, 2024
9853a29
Build wheels for all Python versions
JCGoran Feb 28, 2024
15d94b5
Fix azure pipeline searching for wheels
JCGoran Feb 28, 2024
6f1cc38
Merge branch 'master' into jelic/pyproject
JCGoran Feb 28, 2024
1872bcb
Merge branch 'master' into jelic/pyproject
JCGoran Feb 28, 2024
2a45fec
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Feb 28, 2024
729a306
Merge branch 'jelic/pyproject' into jelic/move_python_dir
JCGoran Feb 28, 2024
dfde76a
Update docs
JCGoran Feb 28, 2024
7128f08
Revert "Build wheels for all Python versions"
JCGoran Feb 28, 2024
57b6001
Update azure testing again
JCGoran Feb 28, 2024
e8abe2a
Update docs/generate_docs.sh
JCGoran Feb 28, 2024
9f4e0a2
Yes fine it was an unbound variable
JCGoran Feb 28, 2024
c142b94
I hate CI
JCGoran Feb 28, 2024
b1afcd0
Fix doxygen issues when building docs
JCGoran Feb 28, 2024
f44ffbb
Allow setting a custom build directory for docs
JCGoran Feb 29, 2024
bc6d692
Minor updates to docs
JCGoran Feb 29, 2024
9257890
Fix for azure testing manylinux
JCGoran Feb 29, 2024
f8a43d9
Maybe now azure?
JCGoran Feb 29, 2024
a689939
Fix docs building again (and maybe for all)
JCGoran Feb 29, 2024
44a0514
Forgot to actually install Python
JCGoran Feb 29, 2024
7c5be89
Fix docs CI to match changes
JCGoran Feb 29, 2024
f2fbb2e
Fix no effect statement in docs gen
JCGoran Feb 29, 2024
9373afb
Fix `change_name.py` script
JCGoran Feb 29, 2024
23bee89
Leave in the `nmodl.hpp` header
JCGoran Feb 29, 2024
c15cbbc
Build everything
JCGoran Feb 29, 2024
1ef357f
Refactor generation of docs
JCGoran Mar 1, 2024
2335403
Update docs CI
JCGoran Mar 1, 2024
5931038
Put back the version
JCGoran Mar 1, 2024
859ee44
Update INSTALL.rst
JCGoran Mar 1, 2024
8ad9f0f
Save valuable time and keystrokes by not using underscores
JCGoran Mar 1, 2024
2cc7733
Remove comment
JCGoran Mar 1, 2024
66b342a
Use two azure runners to build wheels on MacOS
JCGoran Mar 1, 2024
e07a6d2
Update docgen
JCGoran Mar 1, 2024
d93760e
Update dosc
JCGoran Mar 1, 2024
c21722c
Update CI
JCGoran Mar 1, 2024
506b4b7
Merge branch 'master' into jelic/pyproject
JCGoran Mar 1, 2024
713e32e
Remove useless flags
JCGoran Mar 1, 2024
5c67ac7
Remove useless CI job
JCGoran Mar 1, 2024
ce03dd8
Merge branch 'jelic/move_python_dir' into jelic/pyproject
JCGoran Mar 1, 2024
62fd8a7
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Mar 1, 2024
ce0fabf
Remove MacOS 14 runner on azure as its unavailable
JCGoran Mar 1, 2024
c806063
Build and test all wheels on GHA
JCGoran Mar 1, 2024
1af5ec4
Enable non-master CI for now
JCGoran Mar 1, 2024
b1ee0c7
Maybe now?
JCGoran Mar 1, 2024
e43d04c
Fix typo
JCGoran Mar 1, 2024
959b0d5
Update nmodl-wheel.yml
JCGoran Mar 1, 2024
fe06639
Download artifact v4 maybe?
JCGoran Mar 4, 2024
ff34fec
Merge remote-tracking branch 'origin/jelic/cibw' into jelic/cibw
JCGoran Mar 4, 2024
1930073
Revert "Build everything"
JCGoran Mar 4, 2024
85c76b9
Cmon github expand the damn variable!
JCGoran Mar 4, 2024
73ab250
Final touches for CI
JCGoran Mar 4, 2024
bd87326
Last touches in CI
JCGoran Mar 4, 2024
1a367f3
WIP test circle CI wheels
JCGoran Mar 4, 2024
93fcef3
Fix useless imports in init
JCGoran Mar 4, 2024
26e6193
Raise an error if NMODL is not available
JCGoran Mar 4, 2024
5e4f395
Fix CIRCLECI
JCGoran Mar 4, 2024
b18576b
WIP on circleCI
JCGoran Mar 4, 2024
58582c7
Remove all ARM stuff for now
JCGoran Mar 4, 2024
71b58fa
Put back empty circleCI config
JCGoran Mar 4, 2024
a74c76c
Add requirements.txt
JCGoran Mar 4, 2024
747053b
Put back requirements in CI
JCGoran Mar 4, 2024
62612cc
Remove checking python dependencies in cmake
JCGoran Mar 4, 2024
5eae4cb
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Mar 4, 2024
031dfdb
Put back the init try so CI passes
JCGoran Mar 4, 2024
dc747e4
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Mar 4, 2024
6cbcdec
Change back name of wheel
JCGoran Mar 4, 2024
2450a2b
Add minor fixes to script for building wheels
JCGoran Mar 5, 2024
dd2d11f
WIP try to use newer docker NMODL image to build wheels
JCGoran Mar 5, 2024
674f466
Merge branch 'jelic/pyproject' into jelic/cibw
JCGoran Mar 5, 2024
c96495e
Build all wheels again
JCGoran Mar 5, 2024
800714a
Use primary Docker image when building Linux wheels
JCGoran Mar 5, 2024
482d6c6
Merge branch 'master' into jelic/cibw
JCGoran Mar 6, 2024
d4c8d35
Remove useless echo in CI
JCGoran Mar 6, 2024
08d67fa
Update docs
JCGoran Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2

jobs:
linux-aarch64-wheels:
working_directory: ~/linux-aarch64-wheels
machine:
image: ubuntu-2004:2022.04.1
JCGoran marked this conversation as resolved.
Show resolved Hide resolved
# resource_class is what tells CircleCI to use an ARM worker for native arm builds
# https://circleci.com/product/features/resource-classes/
resource_class: arm.medium
steps:
- checkout
- run:
name: Build the Linux aarch64 wheels.
environment:
CIBW_SKIP: "pp* *-musllinux_aarch64"
CIBW_BEFORE_BUILD_LINUX: bash packaging/install_dependencies.sh
JCGoran marked this conversation as resolved.
Show resolved Hide resolved
CIBW_ENVIRONMENT_LINUX: >
PATH=/nmodlwheel/flex/bin:/nmodlwheel/bison/bin:$PATH
command: |
python3 -m pip install --user cibuildwheel==2.16.5
python3 -m cibuildwheel --output-dir wheelhouse
- store_artifacts:
path: wheelhouse/

workflows:
version: 2
all-tests:
jobs:
- linux-aarch64-wheels
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
working-directory: ${{runner.workspace}}/nmodl
run: |
pip3 install -U pip setuptools
pip3 install --user -r requirements.txt
pip3 install --user -r <(packaging/show_deps.py -b -r .)
- name: Restore compiler cache
uses: actions/cache@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nmodl-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
working-directory: ${{runner.workspace}}/nmodl
run: |
python3 -m pip install -U pip setuptools
python3 -m pip install --user -r requirements.txt
python3 -m pip install --user -r <(packaging/show_deps.py -b -r .)

- name: Install neuron-nightly
if: ${{matrix.config.enable_usecases == 'On'}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nmodl-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
working-directory: ${{runner.workspace}}/nmodl
run: |
pip3 install -U pip setuptools
pip3 install --user -r requirements.txt
pip3 install --user -r <(packaging/show_deps.py -r -b .)

# This step will set up an SSH connection on tmate.io for live debugging.
# To trigger it, simply add 'live-debug-docs' to your last pushed commit message.
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/nmodl-wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build wheels

on:
push:
branches:
- master
pull_request:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]

steps:
- name: Setup Flex and Bison
if: runner.os == 'Windows'
run: |
choco install winflexbison3 -y

- name: Setup Flex and Bison
if: runner.os == 'macOS'
run: |
brew install flex bison

# for multi-arch builds
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- uses: actions/checkout@v4

# Used to host cibuildwheel
- uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.5

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
# to supply options, put them in 'env', like:
env:
# we skip PyPy, 32-bit builds, and musllinux builds
CIBW_SKIP: "pp* *-win32 *-manylinux_i686 *-musllinux_i686 *-musllinux_x86_64"
# MacOS-specific setup
CIBW_ENVIRONMENT_MACOS: >
PATH="/opt/homebrew/opt/flex/bin:/opt/homebrew/opt/bison/bin:/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"
MACOSX_DEPLOYMENT_TARGET='10.15'
CIBW_CONFIG_SETTINGS_MACOS: "build-dir=_build"
# Linux-specific setup
CIBW_ENVIRONMENT_LINUX: >
PATH=/nmodlwheel/flex/bin:/nmodlwheel/bison/bin:$PATH
# TODO: replace this with a custom Docker image to speed-up builds
CIBW_BEFORE_BUILD_LINUX: bash packaging/install_dependencies.sh

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
2 changes: 1 addition & 1 deletion .github/workflows/sonarsource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
working-directory: ${{runner.workspace}}/nmodl
run: |
pip3 install -U pip setuptools
pip3 install --user -r requirements.txt
pip3 install --user -r <(packaging/show_deps.py -r -b .)
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Configure project
Expand Down
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ set(NMODL_EXTRA_CXX_FLAGS
""
CACHE STRING "Add extra compile flags for NMODL sources")
separate_arguments(NMODL_EXTRA_CXX_FLAGS)
option(LINK_AGAINST_PYTHON "Should the Python library be linked or not" ON)
option(NMODL_BUILD_WHEEL "Flag to signal we are building a wheel" OFF)
if(NMODL_BUILD_WHEEL)
set(LINK_AGAINST_PYTHON OFF)
set(NMODL_ENABLE_TESTS OFF)
endif()

# =============================================================================
# Settings to enable project as submodule
Expand Down Expand Up @@ -163,9 +169,12 @@ find_package(PythonInterp 3.8 REQUIRED)
cpp_cc_strip_python_shims(EXECUTABLE "${PYTHON_EXECUTABLE}" OUTPUT PYTHON_EXECUTABLE)
include(cmake/hpc-coding-conventions/cpp/cmake/bbp-find-python-module.cmake)
cpp_cc_find_python_module(jinja2 2.9.3 REQUIRED)
cpp_cc_find_python_module(pytest 3.3.0 REQUIRED)
cpp_cc_find_python_module(sympy 1.3 REQUIRED)
cpp_cc_find_python_module(textwrap 0.9 REQUIRED)
if(NMODL_ENABLE_TESTS)
cpp_cc_find_python_module(pytest 3.3.0 REQUIRED)
endif()
if(NOT NMODL_BUILD_WHEEL)
cpp_cc_find_python_module(sympy 1.3 REQUIRED)
endif()
cpp_cc_find_python_module(yaml 3.12 REQUIRED)

# =============================================================================
Expand Down
12 changes: 10 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ stages:
sudo apt-get install -y python3.8 python3.8-dev python3.8-venv ninja-build
sudo apt-get remove -y python3-importlib-metadata
python3.8 -m pip install --upgrade pip setuptools
python3.8 -m pip install --user -r $(Build.Repository.LocalPath)/requirements.txt
python3.8 -m pip install --user -r <($(Build.Repository.LocalPath)/packaging/show_deps.py -r -b $(Build.Repository.LocalPath))
# we manually get version 3.15.0 to make sure that changes in the cmake
# files do not require unsupported versions of cmake in our package.
wget --quiet --output-document=- "https://github.com/Kitware/CMake/releases/download/$CMAKE_VER/$CMAKE_PKG.tar.gz" | tar xzpf -
Expand Down Expand Up @@ -149,7 +149,7 @@ stages:
- script: |
brew install flex bison cmake python@3
python3 -m pip install --upgrade pip setuptools
python3 -m pip install --user -r $(Build.Repository.LocalPath)/requirements.txt
python3 -m pip install --user -r <($(Build.Repository.LocalPath)/packaging/show_deps.py -r -b $(Build.Repository.LocalPath))
displayName: 'Install Dependencies'
- script: |
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH;
Expand Down Expand Up @@ -222,6 +222,10 @@ stages:
else
export TAG=""
fi
# the following 2 lines are a workaround for PEP 621 not allowing a
# dynamic `name` in `pyproject.toml`
python3 -m pip install --user tomli tomli-w
python3 packaging/change_name.py pyproject.toml "NMODL${TAG}"
docker run --rm \
-w /root/nmodl \
-v $PWD:/root/nmodl \
Expand Down Expand Up @@ -295,6 +299,10 @@ stages:
else
export NMODL_NIGHTLY_TAG=""
fi
# the following 2 lines are a workaround for PEP 621 not allowing a
# dynamic `name` in `pyproject.toml`
python3 -m pip install tomli tomli-w
python3 packaging/change_name.py pyproject.toml "NMODL${NMODL_NIGHTLY_TAG}"
packaging/build_wheels.bash osx $(python.version)
condition: succeeded()
displayName: 'Build macos Wheel'
Expand Down
10 changes: 9 additions & 1 deletion nmodl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
try:
# Try importing but catch exception in case bindings are not available
from ._nmodl import NmodlDriver, to_json, to_nmodl # noqa
from ._nmodl import __version__

from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("nmodl")
except PackageNotFoundError:
# package is not installed
pass

__all__ = ["NmodlDriver", "to_json", "to_nmodl"]
except ImportError:
print("[NMODL] [warning] :: Python bindings are not available")
9 changes: 2 additions & 7 deletions pywheel/shim/_binwrapper.py → nmodl/_binwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from find_libpython import find_libpython


def _config_exe(exe_name):
def main():
"""Sets the environment to run the real executable (returned)"""

package_name = "nmodl"
Expand All @@ -37,12 +37,7 @@ def _config_exe(exe_name):
# set PYTHONPATH for embedded python to properly find the nmodl module
os.environ["PYTHONPATH"] = working_set.by_key[package_name].location + ':' + os.environ.get("PYTHONPATH", "")

return os.path.join(NMODL_BIN, exe_name)


if __name__ == "__main__":
"""Set the pointed file as executable"""
exe = _config_exe(os.path.basename(sys.argv[0]))
exe = os.path.join(NMODL_BIN, os.path.basename(sys.argv[0]))
st = os.stat(exe)
os.chmod(exe, st.st_mode | stat.S_IEXEC)
os.execv(exe, sys.argv)
6 changes: 0 additions & 6 deletions packaging/build_requirements.txt

This file was deleted.

15 changes: 8 additions & 7 deletions packaging/build_wheels.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ set -xe
# - python (>=3.8)
# - C/C++ compiler

if [ ! -f setup.py ]; then
echo "Error: setup.py not found. Please launch $0 from the nmodl root dir"
if ! [ -f setup.py ] && ! [ -f pyproject.toml ]; then
echo "Error: setup.py or pyproject.toml not found. Please launch $0 from the nmodl root dir"
exit 1
fi

Expand Down Expand Up @@ -47,14 +47,13 @@ build_wheel_linux() {
(( $skip )) && return 0

echo " - Installing build requirements"
pip install pip auditwheel setuptools
pip install -r packaging/build_requirements.txt
pip install pip auditwheel setuptools build

echo " - Building..."
rm -rf dist _skbuild
# Workaround for https://github.com/pypa/manylinux/issues/1309
git config --global --add safe.directory "*"
python setup.py bdist_wheel
python -m build --wheel -o dist/

echo " - Repairing..."
auditwheel repair dist/*.whl
Expand All @@ -70,11 +69,13 @@ build_wheel_osx() {
(( $skip )) && return 0

echo " - Installing build requirements"
pip install --upgrade delocate -r packaging/build_requirements.txt
pip install --upgrade delocate build

echo " - Building..."
rm -rf dist _skbuild
python setup.py bdist_wheel
# the custom `build-dir` is a workaround for this issue:
# https://gitlab.kitware.com/cmake/cmake/-/issues/20107
python -m build --wheel -o dist/ -C build-dir=_build

echo " - Repairing..."
delocate-wheel -w wheelhouse -v dist/*.whl # we started clean, there's a single wheel
Expand Down
53 changes: 53 additions & 0 deletions packaging/change_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""
Barebones utility for changing the name of the package in `pyproject.toml`.

Usage
-----
[SCRIPT] [PYPROJECT_FILE] [NAME]

Notes
-----
Should only be used by the CI
"""
import re
from argparse import ArgumentParser
from pathlib import Path

import tomli
import tomli_w


def main():
parser = ArgumentParser()
parser.add_argument("pyproject_file", help="The path to the pyproject.toml file")
parser.add_argument("name", help="The new name of the project")
args = parser.parse_args()

if not Path(args.pyproject_file).exists():
raise FileNotFoundError(f"File {args.pyproject_file} not found")

with open(args.pyproject_file, "rb") as f:
toml_dict = tomli.load(f)

# check name is conforms to the naming convention
# see:
# https://packaging.python.org/en/latest/specifications/name-normalization/

if not re.match(
r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",
args.name,
flags=re.IGNORECASE,
):
raise ValueError(
f"The package name {args.name} does not conform to the standard Python package naming convention"
)

toml_dict["project"]["name"] = args.name

with open(args.pyproject_file, "wb") as f:
tomli_w.dump(toml_dict, f)


if __name__ == "__main__":
main()
37 changes: 37 additions & 0 deletions packaging/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

# TODO put all of this inside of a Docker image to save time

set -xe

yum -y install \
git \
wget \
make \
vim \
curl \
unzip \
autoconf \
automake \
make \
openssh-server \
libtool \
&& yum -y clean all \
&& rm -rf /var/cache

curl -L -o flex-2.6.4.tar.gz https://github.com/westes/flex/files/981163/flex-2.6.4.tar.gz \
&& tar -xvzf flex-2.6.4.tar.gz \
&& cd flex-2.6.4 \
&& ./configure --prefix=/nmodlwheel/flex \
&& make -j 3 install \
&& cd .. \
&& rm -rf flex-2.6.4.tar.gz flex-2.6.4
curl -L -o bison-3.7.3.tar.gz https://ftp.gnu.org/gnu/bison/bison-3.7.3.tar.gz \
&& tar -xvzf bison-3.7.3.tar.gz \
&& cd bison-3.7.3 \
&& ./configure --prefix=/nmodlwheel/bison \
&& make -j 3 install \
&& cd .. \
&& rm -rf bison-3.7.3.tar.gz bison-3.7.3

set +xe
Loading
Loading