malcolmw / pykonal

Travel-time calculator based on the fast-marching method solution to the Eikonal equation.
https://malcolmw.github.io/pykonal-docs/
GNU General Public License v3.0
154 stars 55 forks source link

Poetry add error #42

Closed PveOnly closed 8 months ago

PveOnly commented 9 months ago

Hi, I'm trying to install your package on my conda environnement using poetry. I have my own pyproject.toml with my dependencies and other configuration parameter.

It seems that I cannot add your package on my poetry env, i'm getting the error below :

(acouspack_py310_v5)[dev_PVE]$ poetry add pykonal
Using version ^0.4.0 for pykonal

Updating dependencies
Resolving dependencies... (3.8s)

Package operations: 2 installs, 0 updates, 0 removals

  • Installing cython (3.0.7)
  • Installing pykonal (0.4.0): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel

  Compiling pykonal/constants.pyx because it changed.
  Compiling pykonal/fields.pyx because it changed.
  Compiling pykonal/heapq.pyx because it changed.
  Compiling pykonal/locate.pyx because it changed.
  Compiling pykonal/solver.pyx because it changed.
  Compiling pykonal/stats.pyx because it changed.
  [1/6] Cythonizing pykonal/constants.pyx
  [2/6] Cythonizing pykonal/fields.pyx
  [3/6] Cythonizing pykonal/heapq.pyx
  [4/6] Cythonizing pykonal/locate.pyx
  [5/6] Cythonizing pykonal/solver.pyx
  [6/6] Cythonizing pykonal/stats.pyx
  /tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `license` defined outside of `pyproject.toml` is ignored.
  !!

          ********************************************************************************
          The following seems to be defined outside of `pyproject.toml`:

          `license = 'GNU GPLv3'`

          According to the spec (see the link below), however, setuptools CANNOT
          consider this value unless `license` is listed as `dynamic`.

          https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

          To prevent this problem, you can list `license` under `dynamic` or alternatively
          remove the `[project]` table from your file and rely entirely on other means of
          configuration.
          ********************************************************************************

  !!
    _handle_missing_dynamic(dist, project_table)
  /tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `dependencies` defined outside of `pyproject.toml` is ignored.
  !!

          ********************************************************************************
          The following seems to be defined outside of `pyproject.toml`:

          `dependencies = ['cython>=0.29.14', 'h5py', 'numpy', 'scipy']`

          According to the spec (see the link below), however, setuptools CANNOT
          consider this value unless `dependencies` is listed as `dynamic`.

          https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

          To prevent this problem, you can list `dependencies` under `dynamic` or alternatively
          remove the `[project]` table from your file and rely entirely on other means of
          configuration.
          ********************************************************************************

  !!
    _handle_missing_dynamic(dist, project_table)
  /tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `optional-dependencies` defined outside of `pyproject.toml` is ignored.
  !!

          ********************************************************************************
          The following seems to be defined outside of `pyproject.toml`:

          `optional-dependencies = {'tests': ['nose']}`

          According to the spec (see the link below), however, setuptools CANNOT
          consider this value unless `optional-dependencies` is listed as `dynamic`.

          https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

          To prevent this problem, you can list `optional-dependencies` under `dynamic` or alternatively
          remove the `[project]` table from your file and rely entirely on other means of
          configuration.
          ********************************************************************************

  !!
    _handle_missing_dynamic(dist, project_table)
  Traceback (most recent call last):
    File "/projects/nactools/TOOLS/ACOUSPACK/DEV/dev_NF_pycharm/accouspack_pycharm/unpack_conda_env/acouspack_py310_v5/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/projects/nactools/TOOLS/ACOUSPACK/DEV/dev_NF_pycharm/accouspack_pycharm/unpack_conda_env/acouspack_py310_v5/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/projects/nactools/TOOLS/ACOUSPACK/DEV/dev_NF_pycharm/accouspack_pycharm/unpack_conda_env/acouspack_py310_v5/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
      self.run_setup()
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 61, in <module>
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup
      return distutils.core.setup(**attrs)
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 159, in setup
      dist.parse_config_files()
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/_virtualenv.py", line 23, in parse_config_files
      result = old_parse_config_files(self, *args, **kwargs)
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/dist.py", line 627, in parse_config_files
      pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 67, in apply_configuration
      return _apply(dist, config, filepath)
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 56, in apply
      _apply_project_table(dist, config, root_dir)
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 82, in _apply_project_table
      corresp(dist, value, root_dir)
    File "/tmp/tmp1_lydcwk/.venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 183, in _license
      _set_config(dist, "license", val["text"])
  KeyError: 'text'

  at lib/python3.10/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 pykonal (0.4.0) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "pykonal (==0.4.0)"'.

Do you know how I could fix that ?

jobh commented 9 months ago

Same here... the root cause is probably that setuptools has become more strict: https://stackoverflow.com/questions/77523055/missingdynamic-license-defined-outside-of-pyproject-toml-is-ignored

jobh commented 9 months ago

As an emergency fix, you can replace the pykonal dependency with

"pykonal @ git+https://github.com/jobh/pykonal.git@e7969bc41adbc2828716e5b1e1cef72eb20be085"

which just pins the setuptools build dependency to an older one. I'll create a PR to replace the PyPi version.

PveOnly commented 9 months ago

Hi thanks for finding where the problem was, indeed it's working now ! I can't use github on my environement so I did :

poetry add 'setuptools==68.2.2 <- downgrade my setuptools to this version
cloned pykonal repo and copied your pyproject.toml at "https://github.com/jobh/pykonal/blob/master/pyproject.toml"
poetry add /local/path/to/pykonal-repo

And it installed without any poetry error.

Still interested by the pypi package though to have a more proper installation with last setuptools version, do you know when you will be able to upload the new package to pypi ? (it's not an emergency, but just to have an horizon of time to know if I wait for the pypi package of if I ship with the fix)

jobh commented 9 months ago

@PveOnly The PR is #43, but I don't have information about when it's going to be merged or uploaded to pypi. @malcolmw? With Christmas coming up, I wouldn't be surprised if there is a delay.

Minor note: I think your first line (downgrade setuptools) is unnecessary, since the build of pykonal happens in an isolated environment.

PveOnly commented 9 months ago

Yeah the line was maybe not needed indeed, just wanted to dry-run first the downgrade of setuptools to see if it affected other things but it was fine. And ok noted, I will wait thanks !

malcolmw commented 8 months ago

I uploaded a new version of pykonal (0.4.1) to pypi that implements the fix to this problem submitted by @jobh and @dominik-strutz. Closing this issue as complete.