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

Failure of Editable Installs from Relative Paths outside Project Root #1381

Closed
BrutalSimplicity opened this issue Sep 12, 2022 · 1 comment · Fixed by #1432
Closed

Failure of Editable Installs from Relative Paths outside Project Root #1381

BrutalSimplicity opened this issue Sep 12, 2022 · 1 comment · Fixed by #1432
Labels
🐛 bug Something isn't working

Comments

@BrutalSimplicity
Copy link
Contributor

I see that this has been brought up before in #464, but am not sure what the final conclusion is for pdm 2+. Currently PDM is unable to add editable packages outside of the project's directory (aka ${PROJECT_ROOT}).

This can be reproduced given the following fictitious package structure:

project-a
├── pdm.lock
├── pyproject.toml
project-b
├── pdm.lock
├── pyproject.toml

And the pyproject.toml in project-a includes:

[tool.pdm.dev-dependencies]
dev = [
    "-e file:///${PROJECT_ROOT}/../project-b",
]

This causes a failure similar to below during pdm install, on pdm 2.1.3.

Traceback (most recent call last):
  File "/Users/maestro/.asdf/installs/python/3.7.13/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/core.py", line 254, in main
    return Core().main(args)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/core.py", line 187, in main
    raise cast(Exception, err).with_traceback(traceback)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/core.py", line 182, in main
    f(options.project, options)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/cli/commands/install.py", line 69, in handle
    hooks=hooks,
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/cli/actions.py", line 203, in do_sync
    candidates = resolve_candidates_from_lockfile(project, requirements)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/cli/actions.py", line 150, in resolve_candidates_from_lockfile
    resolve_max_rounds,
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/resolver/core.py", line 30, in resolve
    result = resolver.resolve(requirements, max_rounds)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/resolvelib/resolvers.py", line 373, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/resolvelib/resolvers.py", line 213, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/resolvelib/resolvers.py", line 203, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/resolver/providers.py", line 180, in get_dependencies
    deps, requires_python, _ = self.repository.get_dependencies(candidate)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/models/repositories.py", line 426, in get_dependencies
    reqs, python, summary = super().get_dependencies(candidate)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/models/repositories.py", line 70, in get_dependencies
    requirements, requires_python, summary = getter(candidate)
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/models/repositories.py", line 418, in _get_dependencies_from_lockfile
    return self.candidate_info[self._identify_candidate(candidate)]
KeyError: ('project-b', None, 'file:///${PROJECT_ROOT}/../project-b', True)

Expected behavior

In this case I would expect pdm to properly resolve the relative path without failure.

I understand that you can get around this by using symlinks and possibly other clever file path magic, but it would be nice if relative editable installs worked with pdm by default, as many other project do seem to support this capability (pipenv and poetry AFAIK)

What is the expected behavior here? Is there a suggested way to manage interproject dependencies with PDM that I may have missed?

@BrutalSimplicity BrutalSimplicity added the 🐛 bug Something isn't working label Sep 12, 2022
@JohnHardy
Copy link
Contributor

I also would expect PDM to properly resolve the relative path without failure. Ideally without needing a PROJECT_ROOT.

We use a similar project structure (through submodules here) and have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants