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

Use `bootstrap_file` for archive bootstrap files #248

Closed cjntaylor closed 4 months ago

cjntaylor commented 8 months ago

Fixes #247

cjntaylor commented 6 months ago

I've updated this PR to reflect changes in the most recent release to use the resource name instead of the path name.

Using path.name as in the original implementation defeats the purpose of using the importlib.resources api. The documentation specifically calls out that the as_file method (and it's predecessors) are allowed to materialize the requested file(s) in a temporary location with arbitrary names. The code only works as written because under normal circumstances, the shiv module is already unpacked and the files are just referred to directly.

The whole point of this API is that you're not supposed to assume the latter behaviour. This breaks down in cases where the module isn't unpacked (shiv itself is in a zip file, or embedded in something like pyoxidizer). A name property is specifically provided that doesn't make this assumption and works in both cases.

Please consider pulling in this change. I'm happy to make any alterations you'd like, or even to iterate with you on other approaches. I'd really like to be able to use shiv without needing to maintain my own fork 😉

lorencarvalho commented 4 months ago

Hi @cjntaylor, Thanks so much for your contribution and especially for your patience 😓