Skip to content

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

@konstin

Description

@konstin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions