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 with Local and Editable Installs #1382

Closed
BrutalSimplicity opened this issue Sep 12, 2022 · 2 comments
Closed

Failure with Local and Editable Installs #1382

BrutalSimplicity opened this issue Sep 12, 2022 · 2 comments
Labels
🐛 bug Something isn't working

Comments

@BrutalSimplicity
Copy link
Contributor

It seems that pdm is unable to manage dependencies installed as an editable and local package.

Given the following project structure:

.
├── package_a
│   └── main.py
|── project-b
└── pyproject.toml
├── pdm.lock
└── pyproject.toml

And a pyproject.toml for project-a:

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

When you then attempt to add as a local package via pdm add ./project-b it fails with:

Adding packages to default dependencies: project-b @ file:///${PROJECT_ROOT}/project-b
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   project-b @ file:///${PROJECT_ROOT}/project-b
pdm.termui:   -e file:///${PROJECT_ROOT}/project-b#egg=project-b
pdm.termui:   python>=3.7
pdm.termui:   Adding requirement project-b @ file:///${PROJECT_ROOT}/project-b
pdm.termui:   Adding requirement -e file:///${PROJECT_ROOT}/project-b#egg=project-b
pdm.termui:   Adding requirement python>=3.7
pdm.termui: ======== Starting round 0 ========
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui: Pinning: project-b 0.0.1
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:      python None
pdm.termui:   project-b file:///${PROJECT_ROOT}/project-b#egg=project-b
🔒 Lock successful
Changes are written to pdm.lock.
Changes are written to pyproject.toml.
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/add.py", line 72, in handle
    hooks=HookManager(project, options.skip),
  File "/Users/maestro/.asdf/installs/python/3.7.13/lib/python3.7/site-packages/pdm/cli/actions.py", line 301, in do_add
    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', False)

Expected behavior

It would be nice if pdm would understand that the project has both a local and editable package of the same name, and dedupe the dependencies to avoid the key error. Perhaps locally installed packages on the file system could be treated as editable installs by default?

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

It also appears that pdm install will not allow you to switch between dependency groups without attempting to resolve all of them first. In general, it doesn't seem like pdm was designed to support local+editable+remote installs of the same package. Is this working as intended, or something pdm might support in the future?

@frostming
Copy link
Collaborator

See #564

@frostming frostming closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2022
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

No branches or pull requests

2 participants