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

Experiment with Python limited API (take 2) #483

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ requires = ["setuptools",
"setuptools_scm",
"extension-helpers==1.*",
"numpy>=2.0.0rc1",
"cython>=3.0,<3.1"]
"cython @ git+https://github.com/da-woods/cython@cpython-library-limited-api"]
build-backend = 'setuptools.build_meta'

[tool.setuptools]
Expand Down
33 changes: 33 additions & 0 deletions reproject/adaptive/setup_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os

import numpy as np
from setuptools import Extension

ADAPTIVE_SUBPKG = os.path.dirname(__file__)

Check warning on line 6 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L6

Added line #L6 was not covered by tests


def get_extensions():
libraries = []

Check warning on line 10 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L9-L10

Added lines #L9 - L10 were not covered by tests

sources = []
sources.append(os.path.join(ADAPTIVE_SUBPKG, "deforest.pyx"))

Check warning on line 13 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L12-L13

Added lines #L12 - L13 were not covered by tests

include_dirs = [np.get_include()]

Check warning on line 15 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L15

Added line #L15 was not covered by tests

define_macros = []

Check warning on line 17 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L17

Added line #L17 was not covered by tests

define_macros.append(("CYTHON_LIMITED_API", "0x030C0000"))
define_macros.append(("Py_LIMITED_API", "0x030C0000"))

Check warning on line 20 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L19-L20

Added lines #L19 - L20 were not covered by tests

extension = Extension(

Check warning on line 22 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L22

Added line #L22 was not covered by tests
name="reproject.adaptive.deforest",
sources=sources,
include_dirs=include_dirs,
libraries=libraries,
language="c",
extra_compile_args=["-O2"],
define_macros=define_macros,
py_limited_api=True,
)

return [extension]

Check warning on line 33 in reproject/adaptive/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/adaptive/setup_package.py#L33

Added line #L33 was not covered by tests
6 changes: 5 additions & 1 deletion reproject/spherical_intersect/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
if int(os.environ.get("DEBUG_OVERLAP_AREA", 0)):
define_macros = [("DEBUG_OVERLAP_AREA", 1)]
else:
define_macros = None
define_macros = []

Check warning on line 26 in reproject/spherical_intersect/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/spherical_intersect/setup_package.py#L26

Added line #L26 was not covered by tests

define_macros.append(('CYTHON_LIMITED_API', '0x030C0000'))
define_macros.append(('Py_LIMITED_API', '0x030C0000'))

Check warning on line 29 in reproject/spherical_intersect/setup_package.py

View check run for this annotation

Codecov / codecov/patch

reproject/spherical_intersect/setup_package.py#L28-L29

Added lines #L28 - L29 were not covered by tests

extension = Extension(
name="reproject.spherical_intersect._overlap",
Expand All @@ -33,6 +36,7 @@
language="c",
extra_compile_args=["-O2"],
define_macros=define_macros,
py_limited_api=True,
)

return [extension]
Loading