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

PEP 517 builds cannot resolve directory dependencies #9716

Closed
1 task done
AndrewGuenther opened this issue Mar 21, 2021 · 1 comment
Closed
1 task done

PEP 517 builds cannot resolve directory dependencies #9716

AndrewGuenther opened this issue Mar 21, 2021 · 1 comment
Labels
resolution: invalid Invalid issue/PR

Comments

@AndrewGuenther
Copy link

pip version

21.0.1

Python version

3.8.5

OS

Linux, Ubuntu 20.04

Additional information

Relevant pyproject.toml bits:

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Poetry is an illustrative example here, but the root cause lies within pip (or possibly even PEP 517)

Description

When performing a PEP 517 build, pip creates an isolated environment for the build to execute in within a temporary directory. No information about the directory the build originated from is shared with the build backend. As a result, any dependencies specified as a relative file/folder path cannot be resolved.

Expected behavior

Relative directory dependencies can be resolved in a PEP 517 build

How to Reproduce

  1. Create a project which specifies a relative directory dependency using a PEP 517 build backend
  2. Run pip install .
  3. Build will fail to resolve directory dependency

Output

Most of this output is from poetry, but including here for completeness

Processing /home/andrew/worksapce/projects/my-project
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/bin/python /home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp0h3jkq4v
         cwd: /tmp/pip-req-build-5e4zvq59
    Complete output (16 lines):
    Traceback (most recent call last):
      File "/home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
        main()
      File "/home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/tmp/pip-build-env-ta34h747/overlay/lib/python3.8/site-packages/poetry/core/masonry/api.py", line 43, in prepare_metadata_for_build_wheel
        poetry = Factory().create_poetry(Path(".").resolve(), with_dev=False)
      File "/tmp/pip-build-env-ta34h747/overlay/lib/python3.8/site-packages/poetry/core/factory.py", line 93, in create_poetry
        self.create_dependency(name, constraint, root_dir=package.root_dir)
      File "/tmp/pip-build-env-ta34h747/overlay/lib/python3.8/site-packages/poetry/core/factory.py", line 244, in create_dependency
        dependency = DirectoryDependency(
      File "/tmp/pip-build-env-ta34h747/overlay/lib/python3.8/site-packages/poetry/core/packages/directory_dependency.py", line 41, in __init__
        raise ValueError("Directory {} does not exist".format(self._path))
    ValueError: Directory ../../lib/my-project-lib does not exist
    ----------------------------------------
WARNING: Discarding file:///home/andrew/worksapce/projects/my-project. Command errored out with exit status 1: /home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/bin/python /home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp0h3jkq4v Check the logs for full command output.
ERROR: Command errored out with exit status 1: /home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/bin/python /home/andrew/.cache/pypoetry/virtualenvs/my-project-JuauOX3v-py3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp0h3jkq4v Check the logs for full command output.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@AndrewGuenther AndrewGuenther added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Mar 21, 2021
@uranusjr
Copy link
Member

uranusjr commented Mar 21, 2021

Relative paths in a package is a non-standard Poetry extension. The build is handled by Poetry, so it should either reject this with a clear message, or somehow support it for you. pip can't do much about this.

@uranusjr uranusjr added resolution: invalid Invalid issue/PR and removed S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Mar 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: invalid Invalid issue/PR
Projects
None yet
Development

No branches or pull requests

2 participants