Skip to content

Commit

Permalink
FreeCAD compatible wheels (#154)
Browse files Browse the repository at this point in the history
Some fixes were made so the wheels generates are compatible with the current binary distributions of FreeCAD, so installing the FreeCAD pyoptools workbench is straight forward.
  • Loading branch information
ramezquitao authored Mar 5, 2024
1 parent 5801114 commit 27d6c9e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 32 deletions.
8 changes: 8 additions & 0 deletions .github/scripts/set_cibw_build_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# set_cibw_build_env.py
import os

version = os.environ.get('PYTHON_VERSION').replace('.', '')
env_file = os.environ['GITHUB_ENV']

with open(env_file, 'a') as f:
f.write(f'CIBW_BUILD=cp{version}-*{os.linesep}')
30 changes: 24 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,43 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine
pip install Cython==0.29.32 --config-settings="--install-option=--no-cython-compile"
pip install numpy==1.24.2 cibuildwheel
- name: Build sdist
run: python setup.py sdist --formats=zip
pip install cibuildwheel
python -c "import sys; \
py_ver = sys.version_info; \
numpy_version = 'numpy==1.19.3' if py_ver.minor == 8 else \
'numpy==1.26.2' if py_ver.minor == 9 or py_ver.minor == 10 else \
'numpy==1.24.2' if py_ver.minor == 11 else 'numpy'; \
print(numpy_version); \
" | xargs pip install
# For the moment the sdist build will be disabled.
# - name: Build sdist
# run: python setup.py sdist --formats=zip

# The env variable CIBW_BUILD is set here to be able to format matrix.python-version correctly
- name: Set CIBW_BUILD environment variable using Python
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: python ./.github/scripts/set_cibw_build_env.py

- name: Build wheels
run: |
python -m cibuildwheel --output-dir dist/
env:
CIBW_BUILD: "cp38* cp39* cp310* cp311*"
CIBW_SKIP: "*_i686 *musllinux* pp*"
# CIBW_BUILD: "cp${{ matrix.python-version }}*"
CIBW_SKIP: "*_i686 *musllinux* pp* *win32"

- name: Upload Distributions
uses: actions/upload-artifact@v3
Expand Down
44 changes: 43 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
[build-system]
requires = ["setuptools", "wheel", "numpy==1.24.2", "Cython==0.29.32"]
requires = [
"setuptools>=42",
"wheel",
"Cython",
"numpy"
]

build-backend = "setuptools.build_meta"

[project]
name = "pyoptools"
version = "0.2.3"
description = "Python tools for simulation of optical systems"
authors = [{ name = "Ricardo Amézquita Orozco", email = "ramezquitao@cihologramas.com" }]
license = {file = "LICENSE.txt"}
readme = "README.md"
dependencies = [
# Different numpy versions required for the integration with Freecad
# 0.21.2 in windows and linux using the installer and appimage from the
# FreeCAD website
"numpy==1.19.3; python_version=='3.8'",
"numpy==1.26.2; python_version=='3.9'",
"numpy==1.26.2; python_version=='3.10'",
# So it works directly in Debian 12
"numpy==1.24.2; python_version=='3.11'",
"scipy>=1.5.2",
"imageio>=2.9.0",
"PyYAML>=5.3.1",
"matplotlib>=3.3.1",
"ijson>=3.1.3",
"Pillow>=10.0.1",
"jupyterlab>=3.0.0",
"ipython>=7.19.0",
"pythreejs>=2.2.0",
"pytest>=6.1.1",
"pep8>=1.7.1",
"sphinxcontrib-apidoc>=0.3.0",
"mako>=1.1.3",
"ipykernel>=5.3.4",
"nbformat>=5.0.8",
"sphinx>=3.2.1",
"nbsphinx>=0.8.0",
"importlib-resources>=3.3.0",
]
20 changes: 0 additions & 20 deletions requirements.txt

This file was deleted.

6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def create_extension(template, kwds: dict):


setup(
name="pyoptools",
version="0.2.1",
packages=find_packages(exclude=["tests"]),
scripts=["ipyoptools"],
package_data={
Expand All @@ -40,9 +38,7 @@ def create_extension(template, kwds: dict):
author="Ricardo Amezquita Orozco",
author_email="ramezquitao@cihologramas.com",
description="Optical ray tracing simulation system",
license="GPLv3",
url="https://github.com/cihologramas/pyoptools/",
ext_modules=cythonize("pyoptools/**/*.pyx", language_level="2", create_extension=create_extension),
include_dirs=[numpy.get_include()],
install_requires=['numpy', 'scipy', 'imageio', 'PyYAML', 'matplotlib', 'ijson'],
include_dirs=[numpy.get_include()],
)

0 comments on commit 27d6c9e

Please sign in to comment.