Repository navigation
feat: add --no-deps to mirror only the listed requirements - #125
Merged
Merged
Conversation
A requirement can list its specifiers on continuation lines:
[requirements]
foo =
==2.0
==2.1
configparser returns the value of this key as "\n==2.0\n==2.1", and
splitlines() turns it into ["", "==2.0", "==2.1"]. mirror() called
Mirrorer.mirror() once for each entry, so the empty first entry
mirrored "foo" without a specifier. morgan therefore downloaded the
latest release of foo in addition to 2.0 and 2.1.
Drop empty lines before mirroring. A key without any value, such as
"morgan =", still mirrors the latest version.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
morgan mirrors the dependencies of every requirement, and for each dependency it downloads the latest version that matches the dependency's specifier. This is unwanted when the [requirements] section already is a complete set of pinned versions, for example one generated from a lock file. With "bar = ==1.0" and "foo = ==2.0" in the config, and bar depending on "foo>=2.0", morgan downloads foo 2.0 and also the latest release of foo. Add the --no-deps flag to "morgan mirror". With the flag, Mirrorer._process_file returns no dependencies, so only the packages listed in [requirements] are mirrored. This also leaves out extras and the build requirements of source distributions. The .metadata file next to each downloaded file is still written, so that clients can resolve dependencies without downloading the archive (PEP 658). With --use-pypi-metadata, the request to PyPI's JSON API is skipped, because morgan uses its response only to find dependencies. Mirrorer reads the option with getattr(), because library callers build the argparse.Namespace by hand, and reading a missing attribute directly would raise an AttributeError for them. Suggested-by: shamilbi <shamilbi@gmail.com> Link: #112 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The README describes the mirroring of dependencies as unconditional and does not mention the --no-deps flag. Add the section "Mirroring Only the Listed Requirements". It says when to use the flag. It also says that morgan then does not mirror the build requirements of source distributions, because a lock file usually does not list them and clients that build a package from source fail without them. Mention the flag in the feature list as well. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
grische
force-pushed
the
feature/no-dependencies
branch
from
November 23, 2026 13:24
caeb825 to
408c6bb
Compare
|
Thanks for taking this up! I must admit I totally missed the thumbs-up on my original issue so this fell off my radar. |
Contributor
Author
|
@james-smith-za if you can review the code change and test it, it would be appreciated |
james-smith-za
approved these changes
Nov 24, 2026
james-smith-za
left a comment
There was a problem hiding this comment.
Tested and it's working great.
Thanks again!
philnewm
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an improved version of #116, that doesn't need a configuration change.
@shamilbi what do you think about this approach? Would be great if you can do a review.
Closes #116
Fixes #112