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.75k stars 99 forks source link

Shiv ignores files defined in .gitignore without an option to override and add anyway #226

Closed janka102 closed 2 years ago

janka102 commented 2 years ago

I recently found shiv and while trying to bundle my python module I noticed it seems to not include git ignored files in the output.

That is probably fine for a lot of cases, but for me I have generated files that I gitignore but are still needed during runtime. I would like to be able to include those in the bundle but I am unable to find an option to allow that.

I have resorted to a hack that I would rather not have to do which is to comment out the lines in my .gitignore file before running shiv and that successfully includes the files.

It would be good in my opinion to have an option to either turn off the ignore or to specify overrides for certain paths.

lorencarvalho commented 2 years ago

hi @janka102,

shiv is source control agnostic, so I'm not sure what might be happening given your issue description. Do you have steps to reproduce the issue? Do you happen to be using setuptools-scm? I know that package can sometimes cause issues like the one you're describing.

janka102 commented 2 years ago

Thanks for getting back to me. I am using shiv with poetry so maybe that is effecting it then. I just tried to do a minimal reproduction with a new git repo and was able to get the same results.

I've used python quite a bit, but am new to actual packages and bundling so forgive me if this is common knowledge.

After looking a bit more into this I've found that it seems shiv first builds the package into a "wheel" which is defined by poetry, and that build output is what is used for the bundling. I don't completely understand how that works, but after some mental hand waving I can accept that. When I do a poetry build it builds a wheel and a tarball. When looking into the tarball I see the ignored files are missing. So it does indeed appear to be poetry that is not including the files. And after looking some more I found a way to override included files with poetry https://python-poetry.org/docs/pyproject/#include-and-exclude. So I'll close this issue.