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

Update builds to use numpy 2.0 #17

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
strategy:
fail-fast: False
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest-large, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
mkl-version: ['2023'] # currently 2024 fails building for some reason...
include:
- os: ubuntu-latest
Expand Down Expand Up @@ -55,15 +55,15 @@ jobs:

- name: Create environment
run: |
mamba install --quiet --yes pip numpy scipy cython mkl=${{ matrix.mkl-version }} pytest \
conda install --quiet --yes pip numpy scipy cython mkl=${{ matrix.mkl-version }} pytest \
mkl-devel pkg-config meson-python meson ninja setuptools_scm \
${{ matrix.coverage && 'coverage' || ''}}

- name: Install Our Package
run: |
python -m pip install --no-build-isolation --verbose --editable . \
--config-setting=compile-args=-v \
${{ matrix.coverage && '--config-settings=setup-args="-Dcy_coverage=true"' || ''}}
${{ matrix.coverage && '--config-settings=setup-args="-Db_coverage=true"' || ''}}
conda list

- name: Run Tests
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:

- name: Create environment
run: |
mamba install --quiet --yes pip numpy scipy cython mkl=2023 \
conda install --quiet --yes pip numpy scipy cython mkl=2023 \
mkl-devel pkg-config meson-python meson ninja setuptools_scm \
python-build

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ print(get_version())'''
).stdout().strip(),

license: 'MIT',
meson_version: '>= 1.1.0',
meson_version: '>= 1.4.0',
default_options: [
'buildtype=debugoptimized',
'b_ndebug=if-release',
Expand Down
2 changes: 0 additions & 2 deletions meson.options
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
option('cy_coverage', type : 'boolean', value : false)

option('use-sdl', type: 'boolean', value: true,
description: 'Use the single dynamic library.')

Expand Down
44 changes: 4 additions & 40 deletions pydiso/meson.build
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
# NumPy include directory
# The try-except is needed because when things are
# split across drives on Windows, there is no relative path and an exception
# gets raised. There may be other such cases, so add a catch-all and switch to
# an absolute path. Relative paths are needed when for example a virtualenv is
# placed inside the source tree; Meson rejects absolute paths to places inside
# the source tree.
# For cross-compilation it is often not possible to run the Python interpreter
# in order to retrieve numpy's include directory. It can be specified in the
# cross file instead:
# [properties]
# numpy-include-dir = /abspath/to/host-pythons/site-packages/numpy/core/include
#
# This uses the path as is, and avoids running the interpreter.
incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
if incdir_numpy == 'not-given'
incdir_numpy = run_command(py,
[
'-c',
'''import os
import numpy as np
try:
incdir = os.path.relpath(np.get_include())
except Exception:
incdir = np.get_include()
print(incdir)
'''
],
check: true
).stdout().strip()
else
_incdir_numpy_abs = incdir_numpy
endif
inc_np = include_directories(incdir_numpy)
np_dep = declare_dependency(include_directories: inc_np)
np_dep = dependency('numpy')

# MKL-specific options
mkl_dep_name = 'mkl-dynamic'
Expand Down Expand Up @@ -87,22 +54,20 @@ else
use_math_defines = []
endif

numpy_nodepr_api = '-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION'
c_undefined_ok = ['-Wno-maybe-uninitialized']

cython_c_args = [numpy_nodepr_api, use_math_defines]\
cython_c_args = [numpy_nodepr_api, use_math_defines, '-DCYTHON_CCOMPLEX=0']

cython_file = 'mkl_solver.pyx'
cython_file_full_path = meson.current_source_dir() / cython_file

if get_option('cy_coverage')
if get_option('b_coverage')
# tell cython to enable linetracing
add_project_arguments(['--directive', 'linetrace=true'], language : 'cython')
# tell the c_compiler to definie the CYTHON_TRACE_NOGIL
add_project_arguments(['-DCYTHON_TRACE_NOGIL=1'], language : 'c')

# compile the .c file from the .pyx file in it's directory.
# These should include the default options passed to the cython compiler
cython_file_full_path = meson.current_source_dir() / cython_file
run_command(cython, '-M', '--fast-fail', '-3', '--directive', 'linetrace=true', cython_file_full_path)
endif

Expand All @@ -111,7 +76,6 @@ module_path = 'pydiso'
py.extension_module(
'mkl_solver',
cython_file,
include_directories: incdir_numpy,
c_args: cython_c_args,
install: true,
subdir: module_path,
Expand Down
27 changes: 3 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,10 @@
[build-system]
build-backend = 'mesonpy'
requires = [
"meson-python>=0.14.0",
"Cython>=0.29.35", # when updating version, also update check in meson.build
"meson-python>=0.15.0",
"Cython>=3.0.8",
"setuptools_scm[toml]>=6.2",

# This package automatically provides all of the numpy pinning for different python
# versions and runtime requirements.
"oldest-supported-numpy",

# The following is taken from scipy's pyproject.toml file to handle
# building against the proper numpy API

# When numpy 2.0.0rc1 comes out, we should update this to build against 2.0,
# and then runtime depend on the range 1.22.X to <2.3. No need to switch to
# 1.25.2 in the meantime (1.25.x is the first version which exports older C
# API versions by default).

# default numpy requirements
# "numpy==1.22.4; python_version<='3.10' and platform_python_implementation != 'PyPy'",
# "numpy==1.23.2; python_version=='3.11' and platform_python_implementation != 'PyPy'",

# For Python versions which aren't yet officially supported, we specify an
# unpinned NumPy which allows source distributions to be used and allows
# wheels to be used as soon as they become available.
# "numpy>=1.26.0b1; python_version>='3.12'",
# "numpy; python_version>='3.8' and platform_python_implementation=='PyPy'",
"numpy>=2.0.0rc1",
]

[project]
Expand Down
Loading