Repository navigation
Read only the first juliapkg.json for each package on sys.path - #101
Merged
cjdoris merged 1 commit intoSep 28, 2026
Merged
Conversation
Python imports the first copy of a package on sys.path. Merging every copy made find_requirements() fail with non-unique 'path' entries when a source checkout shadowed an installed copy. Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Contributor
|
@cjdoris this fixes an issue I had when trying to ship a julia package saved inside the python source, and reference it via the |
Member
|
Thanks! |
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.
Summary
deps_files()collects<entry>/<package>/juliapkg.jsonfor every entry onsys.path. When a package appears in more than one entry, all copies are merged, although Python imports only the first. This happens when running Python inside a source checkout that is also installed non-editably: the current directory comes first onsys.path, so Python imports the checkout whilesite-packagesholds a second copy.Identical copies merge harmlessly. Copies that set a relative
pathresolve it against their own directories, so they differ andfind_requirements()fails with'path' entries are not unique. Copies at different versions merge their compat bounds even though only one is imported.This change keeps only the first
juliapkg.jsonfor each package name found alongsys.path, matching import order. Top-leveljuliapkg.jsonfiles and editable-install discovery are unchanged.Testing
uv run pytest: 127 passed, 5 skipped (126 passed onmain; the difference is the new test).test_deps_files_skips_shadowed_packageputs two copies of a package onsys.path. It fails onmainand passes with this change.juliapkg.jsonuses a relativepath, installed non-editably and imported from its checkout.find_requirements()fails onmainand succeeds with this branch, selecting the checkout's path, which is the copy Python imports.