antarctica / PolarRoute

Long-distance maritime polar route planning, taking into account complex changing environmental conditions.
https://antarctica.github.io/PolarRoute/
MIT License
17 stars 3 forks source link

Legacy Editable Install Deprecation #298

Closed gecoombs closed 1 month ago

gecoombs commented 1 month ago

Highlighted by @Ulvetanna on #294, the way we currently package PolarRoute is now deprecated and will stop working from Pip version 25 (early next year).

Screenshot 2024-09-26 at 07 56 41

To fix this we need to include a pyproject.toml file and make sure this works with our existing setup.py file or make any necessary changes to update this.

Useful links:

gecoombs commented 1 month ago

I tried setting up a minimal pyproject.toml file as below and I also spent a bit of time adding extra information following various guides online but so far I keep hitting the same ModuleNotFoundError when I try to install via pip, for which I haven't managed to identify the source. Seems like a this will require a bit more thought.

Build error:

      Traceback (most recent call last):
        File "/home/gecoomb/PycharmProjects/MeshiPhi/venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/gecoomb/PycharmProjects/MeshiPhi/venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/gecoomb/PycharmProjects/MeshiPhi/venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-1m6mimc4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 464, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-1m6mimc4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
        File "/tmp/pip-build-env-1m6mimc4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-1m6mimc4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 3, in <module>
      ModuleNotFoundError: No module named 'polar_route'

pyproject.toml:

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "polar-route"
dynamic = ["version"]

[tool.setuptools.dynamic]
version = {attr = "polar_route.__version__"}

More links:

gecoombs commented 1 month ago

The error above seems to be caused by the import of Polar Route in the setup.py file, after reading more of the documentation it seems possible to just replace setup.py with pyproject.toml and retain all existing functionality. I'm experimenting with this on the linked branch.

Ulvetanna commented 1 month ago

Great fix for this !