poetry icon indicating copy to clipboard operation
poetry copied to clipboard

new installer does not respect get_requires_for_build_editable

Open onerandomusername opened this issue 1 year ago • 1 comments

  • Poetry version: 1.4.0
  • Python version: 3.10.10
  • OS version and name: fedora 37
  • pyproject.toml: https://gist.github.com/onerandomusername/a9b67be9494a717c945f3194bbb5b72a -- that local dependency needs to be checked out to the feat/build-with-pdm-backend branch (or the master branch if it has been merged)
  • [x] I am on the latest stable Poetry version, installed using a recommended method.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

Simply put, the new installer never calls get_requires_for_build_editable.

That's an issue with this code: https://github.com/python-poetry/poetry/blob/0e72a55c43a993ec0258facec23416c9212964ba/src/poetry/installation/chef.py#L128-L137

I've fixed it by changing it to the following snippet, and I'm willing to make a pr after this gets triaged 😄

                    dist_format = "wheel" if not editable else "editable"
                    env.install(
                        builder.build_system_requires
                        | builder.get_requires_for_build(dist_format)
                    )
                    path = Path(
                        builder.build(
                            dist_format,
                            destination.as_posix(),
                        )
                    )

This was tested by running poetry install with the dependency from the above pyproject.toml

The full traceback for completeness, but I'm afraid this may not be helpful.

  Stack trace:

  7  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:271 in _execute_operation
      269│ 
      270│             try:
    → 271│                 result = self._do_execute_operation(operation)
      272│             except EnvCommandError as e:
      273│                 if e.e.returncode == -2:

  6  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:357 in _do_execute_operation
      355│             return 0
      356│ 
    → 357│         result: int = getattr(self, f"_execute_{method}")(operation)
      358│ 
      359│         if result != 0:

  5  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:477 in _execute_install
      475│ 
      476│     def _execute_install(self, operation: Install | Update) -> int:
    → 477│         status_code = self._install(operation)
      478│ 
      479│         self._save_url_reference(operation)

  4  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:509 in _install
      507│             archive = self._prepare_archive(operation)
      508│         elif package.source_type == "directory":
    → 509│             archive = self._prepare_directory_archive(operation)
      510│             cleanup_archive = True
      511│         elif package.source_type == "url":

  3  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:598 in _prepare_directory_archive
      596│             req /= package.source_subdirectory
      597│ 
    → 598│         return self._prepare_archive(operation)
      599│ 
      600│     def _prepare_git_archive(self, operation: Install | Update) -> Path:

  2  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:577 in _prepare_archive
      575│         self._populate_hashes_dict(archive, package)
      576│ 
    → 577│         return self._chef.prepare(archive, editable=package.develop)
      578│ 
      579│     def _prepare_directory_archive(self, operation: Install | Update) -> Path:

  1  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/chef.py:105 in prepare
      103│             tmp_dir = tempfile.mkdtemp(prefix="poetry-chef-")
      104│ 
    → 105│             return self._prepare(archive, Path(tmp_dir), editable=editable)
      106│ 
      107│         return self._prepare_sdist(archive, destination=output_dir)

  ChefBuildError

  Backend subprocess exited when trying to invoke build_editable
  
  Traceback (most recent call last):
    File "/home/xxx/.local/share/pypoetry/venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/xxx/.local/share/pypoetry/venv/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 "/home/xxx/.local/share/pypoetry/venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 273, in build_editable
      return hook(wheel_directory, config_settings, metadata_directory)
    File "/tmp/tmpjpmsdln2/.venv/lib/python3.8/site-packages/pdm/backend/__init__.py", line 97, in build_editable
      from pdm.backend.editable import EditableBuilder
    File "/tmp/tmpjpmsdln2/.venv/lib/python3.8/site-packages/pdm/backend/editable.py", line 7, in <module>
      from editables import EditableProject
  ModuleNotFoundError: No module named 'editables'
  

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/chef.py:152 in _prepare
      148│ 
      149│                 error = ChefBuildError("\n\n".join(message_parts))
      150│ 
      151│             if error is not None:
    → 152│                 raise error from None
      153│ 
      154│             return path
      155│ 
      156│     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 disnake (2.9.0a4522+g8a2a4ef7 /home/xxx/gh/disnake/disnake) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "disnake @ file:///home/xxx/gh/disnake/disnake ; python_version >= "3.8""'.

onerandomusername avatar Feb 28 '23 06:02 onerandomusername

LGTM, PR welcome. 😄

radoering avatar Feb 28 '23 15:02 radoering

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Feb 29 '24 18:02 github-actions[bot]