linkedin / shiv

shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.
BSD 2-Clause "Simplified" License
1.73k stars 94 forks source link

Shiv only calls expanduser() for the default root dir during bootstrapping #205

Closed aradar closed 2 years ago

aradar commented 2 years ago

Hey,

I am planning to use shiv for a project of mine and during my evaluation I noticed that alternative root directories set with --root ... don't get expanded and therefor setting something like --root ~/.foo/ doesn't work as expected. Instead of creating a subdirectory in the home of the current user, it creates a "~" directory in the current working directory.

Would it therefore be possible to change: https://github.com/linkedin/shiv/blob/b7c28694ddb343c5a2c404ac7d73b58b07a456fe/src/shiv/bootstrap/__init__.py#L105

to this:

root = (root_dir or Path("~/.shiv")).expanduser() 

as this would just change the behavior to correctly expand what ever root_dir is at this point or the default ~/.shiv path correctly.

Do you guys think this is possible or has some other implications? As I would like to use the same directory I use for other metadata to make it simpler to clean the current state of my tool.

Thanks in advance, and thanks for this cool tool!

lorencarvalho commented 2 years ago

Hi @aradar, thanks for the report! This is a super easy fix, so I just cut a PR for it.

The only caveat to remember here is that the expanduser behavior happens at runtime and not build time.

I'll cut a release after CI passes :)