pyproj4 / pyproj

Python interface to PROJ (cartographic projections and coordinate transformations library)
https://pyproj4.github.io/pyproj
MIT License
1.05k stars 212 forks source link

BUG: Cython 3 Compatibility #1321

Closed snowman2 closed 1 year ago

snowman2 commented 1 year ago
Error compiling Cython file:
------------------------------------------------------------
...

cdef void pyproj_context_initialize(PJ_CONTEXT* context) except *:
    """
    Setup the context for pyproj
    """
    proj_log_func(context, NULL, pyproj_log_function)
                                 ^
------------------------------------------------------------

pyproj/_datadir.pyx:148:33: Cannot assign type 'void (void *, int, const char *) except * nogil' to 'PJ_LOG_FUNCTION'
snowman2 commented 1 year ago

https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html#exception-values-and-noexcept

snowman2 commented 1 year ago

I believe this should work for current versions of pyproj:

python -m pip install 'cython<3'
python -m pip install --no-use-pep517 pyproj

To install the version with the fix implemented:

python -m pip install pyproj@git+https://github.com/pyproj4/pyproj.git@main
pritish-ranjan01 commented 1 year ago

Same problem with our docker build.

BASE_IMAGE=python:3.9-alpine3.16 pyproj = "~=2.6.1"

poetry = 1.2.2

Error:-

at /usr/local/lib/python3.9/site-packages/poetry/utils/pip.py:51 in pip_install 47│ 48│ try: 49│ return environment.run_pip(*args) 50│ except EnvCommandError as e: → 51│ raise PoetryException(f"Failed to install {path.as_posix()}") from e 52│

snowman2 commented 1 year ago

Does this work: https://github.com/python-poetry/poetry/issues/3433#issuecomment-840509576

poetry run python -m pip install 'cython<3'
poetry run python -m pip install --no-use-pep517 pyproj
poetry install
richieho-chownow commented 1 year ago

It does not work for projects that still use setup.py.

ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of setuptools.build_meta in pyproject.toml

Seems like you have the fix in v3.6.1. If so, when will will it be released? @snowman2

snowman2 commented 1 year ago

Seems like you have the fix in v3.6.1. If so, when will will it be released?

Here is the 3.6.1 milestone: https://github.com/pyproj4/pyproj/milestone/11. With current dependencies, it is expected to arrive sometime at the end of September or beginning of October.

richieho-chownow commented 1 year ago

I see Python 3.12 as a dep. Will projects that use pyproj also need to be on Python 3.12?

snowman2 commented 1 year ago

Will projects that use pyproj also need to be on Python 3.12?

Python 3.12 support will be added (i.e. wheels) in addition to currently supported Python versions.

snowman2 commented 1 year ago

https://pypi.org/project/pyproj/3.6.1/