Skip to content

Commit 20f5725

Browse files
authored
Merge pull request #428 from jacklovell/v081_buildfix
V0.8.1 buildfix
2 parents ea5bc96 + 2b377c4 commit 20f5725

File tree

9 files changed

+113
-61
lines changed

9 files changed

+113
-61
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
tests:
9+
name: Run tests
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
numpy-version: ["oldest-supported-numpy", "numpy"]
15+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install Python dependencies
24+
run: python -m pip install --prefer-binary setuptools "cython>=0.28,<3.0" "matplotlib>=3,<4" ${{ matrix.numpy-version }}
25+
- name: Build and install Raysect
26+
run: dev/build.sh
27+
- name: Run tests
28+
run: dev/test.sh

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

dev/build_wheels.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

dev/build_wheels_manylinux2010.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# To be run from within manylinux2010 docker container.
3+
# Run the command below from the root of the source folder:
4+
# sudo docker run -ti -v $(pwd):/io quay.io/pypa/manylinux2010_x86_64 ./dev/build_wheels_manylinux2010.sh
5+
# Or, to use singularity instead of docker (e.g. on HPC, or where root not available):
6+
# singularity run -B $(pwd):/io -W /tmp -c docker://quay.io/pypa/manylinux2010_x86_64 /io/dev/build_wheels_manylinux2010.sh
7+
8+
set -e
9+
cd /io || exit
10+
VERSION=$(cat raysect/VERSION)
11+
PLAT=manylinux2010_x86_64
12+
13+
# Numpy provides manylinux2010 wheels only for Python up to 3.9.
14+
15+
# python 3.7
16+
/opt/python/cp37-cp37m/bin/python -m build .
17+
auditwheel repair dist/raysect-$VERSION-cp37-cp37m-linux_x86_64.whl --plat $PLAT
18+
19+
# python 3.8
20+
/opt/python/cp38-cp38/bin/python -m build .
21+
auditwheel repair dist/raysect-$VERSION-cp38-cp38-linux_x86_64.whl --plat $PLAT
22+
23+
# python 3.9
24+
/opt/python/cp39-cp39/bin/python -m build .
25+
auditwheel repair dist/raysect-$VERSION-cp39-cp39-linux_x86_64.whl --plat $PLAT

dev/build_wheels_manylinux2014.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# To be run from within manylinux2014 docker container.
3+
# Run the command below from the root of the source folder:
4+
# sudo docker run -ti -v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 ./dev/build_wheels_manylinux2014.sh
5+
# Or, to use singularity instead of docker (e.g. on HPC, or where root not available):
6+
# singularity run -B $(pwd):/io -W /tmp -c docker://quay.io/pypa/manylinux2014_x86_64 /io/dev/build_wheels_manylinux2014.sh
7+
8+
set -e
9+
cd /io || exit
10+
VERSION=$(cat raysect/VERSION)
11+
PLAT=manylinux2014_x86_64
12+
13+
# Numpy provides manylinux2010 wheels for Python up to 3.9. So only need manylinux2014
14+
# wheels for 3.10 onwards
15+
16+
# python 3.10
17+
/opt/python/cp310-cp310/bin/python -m build .
18+
auditwheel repair dist/raysect-$VERSION-cp310-cp310-linux_x86_64.whl --plat $PLAT
19+
20+
# python 3.11
21+
/opt/python/cp311-cp311/bin/python -m build .
22+
auditwheel repair dist/raysect-$VERSION-cp311-cp311-linux_x86_64.whl --plat $PLAT
23+
24+
# python 3.12
25+
/opt/python/cp312-cp312/bin/python -m build .
26+
auditwheel repair dist/raysect-$VERSION-cp312-cp312-linux_x86_64.whl --plat $PLAT

dev/notes/building_bdist_with_manylinux.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,29 @@ Start the manylinux docker container (this will download the container, mount th
1313
This will drop you into the manylinux container terminal. The /opt/python folder in the container holds the various versions of python. This example targets python 3.7. Adjust the paths as appropriate to build bdists for different python versions.
1414

1515
cd io/source
16-
/opt/python/cp37-cp37m/bin/python -m pip install cython numpy==1.14.6
17-
/opt/python/cp37-cp37m/bin/python setup.py bdist_wheel
16+
/opt/python/cp37-cp37m/bin/python -m pip build .
1817
auditwheel repair dist/raysect-0.8.1-cp37-cp37m-linux_x86_64.whl --plat manylinux2010_x86_64
1918

2019
This will compile the wheel and repair any library references to produce the manylinux wheel files in a folder ./wheelhouse. e.g. raysect-0.8.1-cp37-cp37m-manylinux1_x86_64.whl and raysect-0.8.1-cp37-cp37m-manylinux2010_x86_64.whl.
2120

22-
These can then be uploaded to pypi (just the manylinux2010 packages for now).
21+
These can then be uploaded to pypi.
2322

2423
For more info see:
2524
https://realpython.com/python-wheels/#building-a-platform-wheel-macos-and-windows
26-
https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html
25+
https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html
26+
27+
Scripts to semi-automate the wheel building process
28+
===================================================
29+
30+
There are two scripts which automate this for different versions of Python:
31+
- dev/build_wheels_manylinux2010.sh builds manylinux2010 wheels for Python 3.7, 3.8 and 3.9
32+
- dev/build_wheels_manylinux2014.sh builds manylinux2014 wheels for Python 3.10, 3.11 and 3.12
33+
34+
These can be used to produce wheels in a semi-automated fashion:
35+
1. Install docker as above
36+
2. Clone the raysect/source repository
37+
3. Change into the top level of the raysect/source repository.
38+
4. Run `sudo docker run -ti -v $(pwd):/io quay.io/pypa/manylinux2010_x86_64 /io/dev/build_wheels_manylinux2010.sh`
39+
5. Run `sudo docker run -ti -v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 /io/dev/build_wheels_manylinux2014.sh`
40+
6. Upload the wheels in wheelhouse/, and the sdist in dist/, to PyPI using twine.
41+

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools>=42.0", "wheel", "oldest-supported-numpy", "cython>=0.28"]
2+
requires = ["setuptools>=42.0", "wheel", "oldest-supported-numpy", "cython>=0.28,<3.0"]
33
build-backend = "setuptools.build_meta"

raysect/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.1
1+
0.8.1.post1

setup.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from setuptools import setup, find_packages, Extension
2+
from setuptools.command.build_ext import build_ext as _build_ext
23
import sys
34
import numpy
45
import os
@@ -83,6 +84,14 @@
8384
with open(path.join(path.dirname(__file__), 'raysect/VERSION')) as version_file:
8485
version = version_file.read().strip()
8586

87+
# Use multiple processes by default for building extensions
88+
class build_ext(_build_ext):
89+
def finalize_options(self):
90+
super().finalize_options()
91+
if self.parallel is None:
92+
nproc = int(os.getenv("RAYSECT_BUILD_JOBS", str(multiprocessing.cpu_count())))
93+
self.parallel = nproc
94+
8695
setup(
8796
name="raysect",
8897
version=version,
@@ -104,9 +113,10 @@
104113
"Topic :: Multimedia :: Graphics :: 3D Rendering",
105114
"Topic :: Scientific/Engineering :: Physics"
106115
],
107-
install_requires=['numpy>=0.14', 'matplotlib'],
116+
install_requires=['numpy', 'matplotlib'],
108117
packages=find_packages(),
109118
include_package_data=True,
110-
zip_safe=False,
111-
ext_modules=extensions
119+
zip_safe= False,
120+
ext_modules=extensions,
121+
cmdclass={"build_ext": build_ext},
112122
)

0 commit comments

Comments
 (0)