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

Poetry fails when path depedency (PEP 517 build) depends on binary #8749

Closed
4 tasks done
konstin opened this issue Dec 5, 2023 · 5 comments · Fixed by #8827
Closed
4 tasks done

Poetry fails when path depedency (PEP 517 build) depends on binary #8749

konstin opened this issue Dec 5, 2023 · 5 comments · Fixed by #8827
Labels
kind/bug Something isn't working as expected

Comments

@konstin
Copy link

konstin commented Dec 5, 2023

Summary

Poetry fails to build a path depends on a binary that a build requirement installed to its venv's bin/Scripts directory.

Minimal reproduction repo: https://github.com/konstin/poetry-maturin-error. In the repo, there is a main project and a path dependency using maturin. maturin installs its main binary into the bin or Scripts directory, so the directory needs to be in PATH. pip and build handle this, poetry currently doesn't:

This works ...

virtualenv -p 3.10 --clear .venv
.venv/bin/pip install ./maturin-dep

... while this fails:

virtualenv -p 3.10 --clear .venv
poetry update # maturin_dep = { path = "maturin-dep" }

Error messages

Updating dependencies
Resolving dependencies... (3.1s)

Unable to determine package info for path: /home/konsti/projects/poetry-maturin-error/maturin-dep

Command ['/tmp/tmphtmahv10/.venv/bin/python', '-I', '-W', 'ignore', '-c', "import build\nimport build.env\nimport pyproject_hooks\n\nsource = '/home/konsti/projects/poetry-maturin-error/maturin-dep'\ndest = '/tmp/tmphtmahv10/dist'\n\nwith build.env.DefaultIsolatedEnv() as env:\n    builder = build.ProjectBuilder(\n        source_dir=source,\n        python_executable=env.python_executable,\n        runner=pyproject_hooks.quiet_subprocess_runner,\n    )\n    env.install(builder.build_system_requires)\n    env.install(builder.get_requires_for_build('wheel'))\n    builder.metadata_path(dest)\n"] errored with the following return code 1

Error output:
Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "/tmp/tmphtmahv10/.venv/lib/python3.10/site-packages/build/__init__.py", line 311, in metadata_path
    metadata = self.prepare('wheel', output_directory)
  File "/tmp/tmphtmahv10/.venv/lib/python3.10/site-packages/build/__init__.py", line 268, in prepare
    return self._call_backend(
  File "/tmp/tmphtmahv10/.venv/lib/python3.10/site-packages/build/__init__.py", line 344, in _call_backend
    with self._handle_backend(hook_name):
  File "/home/konsti/.pyenv/versions/3.10.13/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/tmp/tmphtmahv10/.venv/lib/python3.10/site-packages/build/__init__.py", line 360, in _handle_backend
    raise BuildBackendException(exception, f'Backend subprocess exited when trying to invoke {hook}') from None
build._exceptions.BuildBackendException: Backend subprocess exited when trying to invoke prepare_metadata_for_build_wheel

No fallback setup.py file was found to generate egg_info.

Running with -vvv prints a stacktrace but it isn't more informative. I had to hack

    try:
        builder.metadata_path(dest)
    except Exception as e:
        print(e.exception.stdout.decode())
        raise

into PEP517_META_BUILD to get the proper error message:

Traceback (most recent call last):
  File "/tmp/tmp9lrchenf/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
    main()
  File "/tmp/tmp9lrchenf/.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 "/tmp/tmp9lrchenf/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
    return hook(metadata_directory, config_settings)
  File "/tmp/build-env-vtzlnykm/lib/python3.10/site-packages/maturin/__init__.py", line 187, in prepare_metadata_for_build_wheel
    _output = subprocess.check_output(command)
  File "/home/konsti/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/konsti/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/konsti/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/konsti/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'maturin'

Other tools

Putting maturin in path manually works:

virtualenv -p 3.10 --clear .venv
.venv/bin/pip install maturin
poetry update

Running build manually works:

virtualenv -p 3.10 --clear .venv
.venv/bin/pip install build
python -m build

System information

  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate: I tried, but it's kinda hard
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below: -vvv didn't help, i had to patch poetry
@konstin konstin added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 5, 2023
@dimbleby
Copy link
Contributor

dimbleby commented Dec 5, 2023

repro does not exist or is private

perhaps you forgot to declare a build requirement

@dimbleby
Copy link
Contributor

dimbleby commented Dec 5, 2023

Probably the fix of #8630 wants repeating inside PEP517_META_BUILD - pull request welcome no doubt

@konstin
Copy link
Author

konstin commented Dec 5, 2023

Sorry, didn't realize the repo was private, fixed.

@dimbleby
Copy link
Contributor

dimbleby commented Dec 5, 2023

do you want to verify the proposed fix and submit a merge request?

Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
@abn abn removed the status/triage This issue needs to be triaged label Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants