diff --git a/news/3123.bugfix.md b/news/3123.bugfix.md new file mode 100644 index 0000000000..88aa494618 --- /dev/null +++ b/news/3123.bugfix.md @@ -0,0 +1 @@ +Fix a bug of export command that packages with extras are included twice. diff --git a/src/pdm/cli/commands/export.py b/src/pdm/cli/commands/export.py index 4a0f2c198d..6959ab8bc3 100644 --- a/src/pdm/cli/commands/export.py +++ b/src/pdm/cli/commands/export.py @@ -79,7 +79,10 @@ def handle(self, project: Project, options: argparse.Namespace) -> None: raise PdmUsageError( "Can't export a lock file without environment markers, please re-generate the lock file with `inherit_metadata` strategy." ) - candidates = [entry.candidate for entry in project.get_locked_repository().packages.values()] + candidates = sorted( + (entry.candidate for entry in project.get_locked_repository().packages.values()), + key=lambda c: not c.req.extras, + ) groups = set(selection) packages = [] seen_extras: set[str] = set()