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

Do not add local package to lockfile #1481

Merged
merged 7 commits into from
Nov 3, 2022

Conversation

tgolsson
Copy link
Contributor

Replaces #1470

Pull Request Check List

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

If you have a pyproject where you depend on yourself using the pattern described in #1441, with a config such as this:

[project]
name = "pkg"
version = "0.2.0"
dependencies = []

requires-python = ">=3.8"
license = {text = "MIT"}

[project.optional-dependencies]
foobar = ["pyyaml"]
ci = ["pkg[foobar]"]

The project will appear multiple times in the lockfile. Changing the version or name of the local package will desync from the lockfile; leading to pdm sync failing. This PR removes the local package from the lockfile, and instead adds a generator for it when running from a LockedRepository.

This works and all tests pass. I did however notice that when using this pattern the local package gets installed twice; but that happens on main as well:

$ pdm --version
PDM, version 2.2.0
$ pdm install -G ci
Synchronizing working set with lock file: 2 to add, 0 to update, 0 to remove

  ✔ Install pkg 0.2.0 successful
  ✔ Install pyyaml 6.0 successful
Installing the project as an editable package...
  ✔ Install pkg 0.2.0 successful

🎉 All complete!

Not sure if there's a good opportunity to fix that here as well.

@frostming
Copy link
Collaborator

I did however notice that when using this pattern the local package gets installed twice; but that happens on main as well:

It can be fixed by dropping the self-package from the resolution result. Then no need to skip it in format_lockfile anymore.

@@ -2,7 +2,9 @@

from typing import TYPE_CHECKING, Dict, cast

from pdm.cli.utils import normalize_name, strip_extras
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong import path, please fix it

@frostming
Copy link
Collaborator

It seems the latest ubuntu runner has some issues with setup-python 3.6. But I can't find a bug report about this.

@frostming frostming merged commit 760cb66 into pdm-project:main Nov 3, 2022
@j178 j178 mentioned this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants