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

#599: Add support for python 3.12 continuation #640

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

MRVermeulenDeltares
Copy link
Contributor

@MRVermeulenDeltares MRVermeulenDeltares commented May 3, 2024

Issue information

It appears that numpy dropped support for python 3.8 in numpy 1.25.
In numpy 1.26 support for python 3.12 was added.
https://numpy.org/news/

The pyproject.toml file had the numpy version set to "^1.21".
I expect that it would search from this version upwards for a compatible version for the python version in use.
E.g. python 3.8 would have with a poetry install numpy 1.24, python 3.12 would have with a poetry install numpy 1.26.
However in practice this did not seem the case, when python 3.12 was used it could not find and use numpy 1.26.

Currenlty I update the pyproject.toml to use "^1.21" for python version 3.8 and above and use "^1.26" for python version 3.12 and above.

Issue TODOs

  • Support python 3.12
  • Update pyproject.toml and poetry.lock files
  • Make sure python 3.12 runs on action with no failing test
  • Make sure python 3.8 to 3.11 run on actions with no failing test
  • Dissable actions for python version 3.10 and 3.11 when python actions for version 3.9 and 3.12 are green.
  • Update documentation
  • Update badge (does this automatically update when we release on pypi? --> it looks like when the PyPi version is updated with support for python 3.12, this badge will automatically update to the new version.)

Test notes

When using poetry install in a clean python 3.12 env with numpy="^1.21" and the lock file removed, the following error is encountered:


  • Installing numpy (1.24.4): Failed

  ChefBuildError

  Backend 'setuptools.build_meta:__legacy__' is not available.
  
  Traceback (most recent call last):
    File "C:\Users\Verme_mn\AppData\Local\Programs\Python\Python39\lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
      obj = import_module(mod_path)
            ^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Verme_mn\Miniconda3\envs\HLCpy312\Lib\importlib\__init__.py", line 90, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1304, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 994, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "C:\Users\Verme_mn\AppData\Local\Temp\tmp1e3zr8ai\.venv\Lib\site-packages\setuptools\__init__.py", line 10, in <module>
      import distutils.core
  ModuleNotFoundError: No module named 'distutils'


  at ~\AppData\Local\Programs\Python\Python39\lib\site-packages\poetry\installation\chef.py:164 in _prepare
      160│
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│
      163│             if error is not None:
    → 164│                 raise error from None
      165│
      166│             return path        
      167│
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with numpy (1.24.4) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "numpy (==1.24.4)"'.

One thing to note is that numpy version 1.24.4 is being installed.
This version is available on pypi: https://pypi.org/project/numpy/#history
But when the release documentation of Numpy is checked, none is available for 1.24.4:
https://numpy.org/doc/stable/release/1.24.3-notes.html
https://numpy.org/doc/stable/release/1.24.4-notes.html

It might be that something is wrong with this version, causing the install to break.

Update: I did find release notes for numpy 1.24.4, but they are on the devdocs page, meaning that it appears this version was release, but not as a stable version. This might be related to the issue.
https://numpy.org/devdocs/release/1.24.4-notes.html

When using poetry install in a clean python 3.12 env with numpy="1.*" and the lock file removed, the following error is encountered:

  • Installing numpy (1.24.4): Failed

  ChefBuildError

  Backend 'setuptools.build_meta:__legacy__' is not available.
  
  Traceback (most recent call last):
    File "C:\Users\Verme_mn\AppData\Local\Programs\Python\Python39\lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
      obj = import_module(mod_path)
            ^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Verme_mn\Miniconda3\envs\hlc-py312\Lib\importlib\__init__.py", line 90, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1304, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 994, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "C:\Users\Verme_mn\AppData\Local\Temp\tmpq0vjxcu2\.venv\Lib\site-packages\setuptools\__init__.py", line 10, in <module>
      import distutils.core
  ModuleNotFoundError: No module named 'distutils'


  at ~\AppData\Local\Programs\Python\Python39\lib\site-packages\poetry\installation\chef.py:164 in _prepare
      160│
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│
      163│             if error is not None:
    → 164│                 raise error from None
      165│
      166│             return path
      167│
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with numpy (1.24.4) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "numpy (==1.24.4)"'.

When using poetry install in a clean python 3.12 env with

numpy = [
    { version = "^1.21", python = "^3.8" },
    { version = "^1.26", python = "^3.12" }
]

and the lock file removed, no errors are encountered.

Black

The black version should be updated once it is available for python 3.12, currently it does not seem to be supported.
see: --target-version
https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html

Python 3.8 support

Python 3.8 will be end of life on 2024-10, do we still want to support this python version up to and after this point?
https://devguide.python.org/versions/

@MRVermeulenDeltares MRVermeulenDeltares linked an issue May 3, 2024 that may be closed by this pull request
13 tasks
Copy link

sonarcloud bot commented May 6, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@MRVermeulenDeltares
Copy link
Contributor Author

When this PR is merged and closed, #606 can also be closed as resolved by this PR.

@priscavdsluis priscavdsluis changed the title 599 add support for python 312 continueation #599: Add support for python 3.12 continuation May 7, 2024
Copy link
Contributor

@tim-vd-aardweg tim-vd-aardweg left a comment

Choose a reason for hiding this comment

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

Review OK!

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.

Add support for Python 3.12
4 participants