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

Support Cython 3.0 #593

Merged
merged 7 commits into from
Nov 5, 2023
Merged
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 .github/workflows/basemap-for-manylinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
export NUMPY_INCLUDE_PATH=${sitepkgdir}/numpy/core/include
if [ "${{ matrix.python-version }}" = "3.11" ]; then
kwds="--no-build-isolation"
pip install setuptools wheel "cython >= 0.29, < 3.0"
pip install setuptools wheel "cython >= 0.29, < 3.1"
fi
cd ${{ env.PKGDIR }}
python setup.py sdist
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ https://semver.org/spec/v2.0.0.html

### Changed
- Upgrade bundled GEOS library to 3.6.5.
- Update build dependencies:
- Upgrade `Cython` upper pin to 3.1.

### Fixed
- Set MSVC 14.0 (VS2015) to build the `_geoslib` module in the
precompiled Windows wheels (PR [#565]).
- Reimplement `matplotlib` version checks without using `distutils` and
remove old switches related to unsupported `matplotlib` versions.
- Fix `_geoslib.pyx` compilation with Cython 3.0+ using the compiler
directive "legacy_implicit_noexcept" (PR [#593] by @musicinmybrain).

### Removed
- Attribute `__version__` in `basemap.proj` module.
Expand Down Expand Up @@ -999,6 +1003,8 @@ https://semver.org/spec/v2.0.0.html
- Fix glitches in drawing of parallels and meridians.


[#593]:
https://github.com/matplotlib/basemap/pull/593
[#583]:
https://github.com/matplotlib/basemap/issues/583
[#582]:
Expand Down
2 changes: 1 addition & 1 deletion packages/basemap/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requires = [
'numpy == 1.16.6; sys_platform != "darwin" and (python_version >= "3.7" and python_version <= "3.9")',
'numpy == 1.16.6; python_version == "2.7" or (python_version >= "3.4" and python_version <= "3.6")',
'numpy == 1.11.3; python_version == "2.6" or (python_version >= "3.2" and python_version <= "3.3")',
'cython >= 0.29, < 3.0; python_version >= "3.3" or python_version < "3.0"',
'cython >= 0.29, < 3.1; python_version >= "3.3" or python_version < "3.0"',
'cython >= 0.26, < 0.27; python_version == "3.2"'
]
build-backend = "setuptools.build_meta"
4 changes: 1 addition & 3 deletions packages/basemap/requirements-setup.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
cython >= 0.29, < 3.0; python_version == "2.6"
cython >= 0.29, < 3.0; python_version == "2.7"
cython >= 0.29, < 3.1; python_version >= "3.3" or python_version < "3.0"
cython >= 0.26, < 0.27; python_version == "3.2"
cython >= 0.29, < 3.0; python_version >= "3.3"
9 changes: 8 additions & 1 deletion packages/basemap/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
from setuptools.dist import Distribution
from setuptools.extension import Extension

try:
import Cython
cython_major_version = int(Cython.__version__.split(".")[0])
except ImportError:
cython_major_version = 0


def get_content(name, splitlines=False):
"""Return the file contents with project root as root folder."""
Expand Down Expand Up @@ -157,7 +163,8 @@ def run(self):
for ext in ext_modules:
ext.cython_directives = [
("language_level", str(sys.version_info[0])),
]
("legacy_implicit_noexcept", True),
][:1 + int(cython_major_version >= 3)]

# Define all the different requirements.
setup_requires = get_content("requirements-setup.txt", splitlines=True)
Expand Down
9 changes: 9 additions & 0 deletions packages/basemap/src/_geoslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ cdef extern from "geos_c.h":
pass
ctypedef struct GEOSCoordSeq:
pass
# Cython 3: Next ctypedef needs "noexcept" declaration unless
# the compiler directive "legacy_implicit_noexcept" is used
# ("noexcept" syntax supported since Cython 0.29.31).
ctypedef void (*GEOSMessageHandler)(char *fmt, char *list)
char *GEOSversion()
void initGEOS(GEOSMessageHandler notice_function, GEOSMessageHandler error_function)
Expand Down Expand Up @@ -105,6 +108,9 @@ cdef extern from "geos_c.h":
GEOSCoordSeq *GEOSGeom_getCoordSeq(GEOSGeom* g)
int GEOSCoordSeq_getSize(GEOSCoordSeq *s, unsigned int *size)

# Cython 3: Next cdef needs "noexcept" declaration unless
# the compiler directive "legacy_implicit_noexcept" is used
# ("noexcept" syntax supported since Cython 0.29.31).
cdef void notice_h(char *fmt, char*msg):
pass
#format = PyBytes_FromString(fmt)
Expand All @@ -115,6 +121,9 @@ cdef void notice_h(char *fmt, char*msg):
# warn_msg = format
#sys.stdout.write('GEOS_NOTICE: %s\n' % warn_msg)

# Cython 3: Next cdef needs "noexcept" declaration unless
# the compiler directive "legacy_implicit_noexcept" is used
# ("noexcept" syntax supported since Cython 0.29.31).
cdef void error_h(char *fmt, char*msg):
format = PyBytes_FromString(fmt)
message = PyBytes_FromString(msg)
Expand Down