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 to Cython 3 #1567

Merged
merged 3 commits into from
May 9, 2024
Merged

update to Cython 3 #1567

merged 3 commits into from
May 9, 2024

Conversation

emlys
Copy link
Member

@emlys emlys commented May 7, 2024

Description

Fixes #556

Checklist

  • Updated HISTORY.rst and link to any relevant issue (if these changes are user-facing)
  • Updated the user's guide (if needed)
  • Tested the Workbench UI (if relevant)

@@ -46,14 +46,14 @@ def run(self):

setup(
install_requires=_REQUIREMENTS,
ext_modules=[
ext_modules=cythonize([
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using cythonize rather than cython's build_ext seems to be more standard nowadays, and lets us set the language level directive.

@@ -129,9 +127,9 @@ cdef class _ManagedRaster:
self.block_xbits = numpy.log2(self.block_xsize)
self.block_ybits = numpy.log2(self.block_ysize)
self.block_nx = (
self.raster_x_size + (self.block_xsize) - 1) / self.block_xsize
self.raster_x_size + (self.block_xsize) - 1) // self.block_xsize
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was relying on python 2 style integer division. Now we need to explicitly use floor division.

@emlys emlys requested a review from dcdenu4 May 7, 2024 22:33
@emlys emlys self-assigned this May 7, 2024
@emlys emlys marked this pull request as ready for review May 7, 2024 22:33
@@ -10,7 +10,6 @@
# scripts/convert-requirements-to-conda-yml.py as though it can only be found
# on pip.

Cython<3.0.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cython doesn't really belong in requirements because it's only needed to build invest, and because it's listed under build-system.requires in pyproject.toml, pip installs it for us in a separate virtual environment at build time.

extra_compile_args=compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language='c++'
language='c++',
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes care of the deprecated numpy API warnings we've had forever.

Copy link
Member

@dcdenu4 dcdenu4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @emlys , this all looks good to me.

@dcdenu4 dcdenu4 merged commit f79d308 into natcap:main May 9, 2024
29 checks passed
@emlys emlys deleted the task/556 branch October 3, 2024 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to Cython 3.0
2 participants