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

Support locking relative paths #4205

Merged
merged 8 commits into from
Jun 11, 2024
Merged

Conversation

konstin
Copy link
Member

@konstin konstin commented Jun 10, 2024

By splitting path into a lockable, relative (or absolute) and an absolute installable path and by splitting between urls and paths by dist type, we can store relative paths in the lockfile.

@konstin konstin added the preview Experimental behavior label Jun 10, 2024
@@ -173,8 +173,8 @@ fn lock_sdist_registry() -> Result<()> {
[[distribution]]
name = "project"
version = "0.1.0"
source = "editable+file://[TEMP_DIR]/"
sdist = { url = "file://[TEMP_DIR]/" }
source = "editable+"
Copy link
Member Author

Choose a reason for hiding this comment

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

This is ugly, do we know something better?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps just editable? And adjust the parser to make a trailing + as optional (or even an error).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think my preference is not using {}+{} at all (either editable = "." or split this source into two fields), but for now i've added a editable+. as workaround.

Copy link
Member

Choose a reason for hiding this comment

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

Is this tracked somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added an item to #3611, i'm not yet deep enough here though to be clear on what the solution is.

crates/uv/tests/lock.rs Outdated Show resolved Hide resolved
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Nice! This LGTM modulo the quirks you mentioned.

The { path = "" } is unfortunate though. I'm not quite sure what to do about that. Maybe just sdist = {} is okay?

source = "editable+file://[TEMP_DIR]/"
sdist = { url = "file://[TEMP_DIR]/" }
source = "editable+"
sdist = { path = "" }
Copy link
Member

Choose a reason for hiding this comment

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

This is also a little weird too. I'm not quite sure what to do otherwise here. You could skip serializing empty paths, but then you'd wind up with sdist = {}, which is also weird...

@@ -173,8 +173,8 @@ fn lock_sdist_registry() -> Result<()> {
[[distribution]]
name = "project"
version = "0.1.0"
source = "editable+file://[TEMP_DIR]/"
sdist = { url = "file://[TEMP_DIR]/" }
source = "editable+"
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps just editable? And adjust the parser to make a trailing + as optional (or even an error).

@konstin konstin force-pushed the konsti/relative-paths-in-lockfile branch 2 times, most recently from d1f013b to 9d8a49a Compare June 11, 2024 09:05
@konstin konstin marked this pull request as ready for review June 11, 2024 09:19
@konstin konstin requested a review from BurntSushi June 11, 2024 09:19
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Nice!

Registry(Url),
Git(Url, GitSource),
Direct(Url, DirectSource),
Path(PathWire),
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm I wonder if you could use PathBuf directly here and then just use serialize_with/deserialize_with functions: https://serde.rs/field-attrs.html#deserialize_with. That would let you skip defining a new intermediate PathWire type.

(Feel free to get this merged and experiment with it in a follow-up if you want. I'm fine with this as-is.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, this removes a lot of boilerplate

@konstin konstin enabled auto-merge (squash) June 11, 2024 11:37
konstin added 8 commits June 11, 2024 13:50
By splitting `path` into a lockable, relative (or absolute) and an absolute installable path and by splitting between urls and paths by dist type, we can store relative paths in the lockfile.
@konstin konstin force-pushed the konsti/relative-paths-in-lockfile branch from b6ab82b to a95e6fa Compare June 11, 2024 11:53
@konstin konstin merged commit 4483380 into main Jun 11, 2024
46 checks passed
@konstin konstin deleted the konsti/relative-paths-in-lockfile branch June 11, 2024 11:58
SigureMo added a commit to yutto-dev/bilili that referenced this pull request Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants