Setuptools: How to make sure file generated by packed code be deleted by pip
The __init__.py
file tells python that the directory it is in is a module, and to look at all the sub-modules located within. This makes pip
think that it is a module, therefore mentioning everything inside it.
From the documentation:
The init.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later (deeper) on the module search path. In the simplest case, init.py can just be an empty file
For your second question, my answer is maybe. I say this because, there is no way I know for sure that this is possible.
P.S: I don't know for sure(because I have not tested it), but maybe you could change file.txt
's extension to .py
maybe fooling pip into removing that.
At line 381 of pip/blob/master/src/pip/_internal/req/req_uninstall.py:
if not verbose:
will_remove, will_skip = compress_for_output_listing(self.paths)
else:
# In verbose mode, display all the files that are going to be
# deleted.
will_remove = list(self.paths)
will_skip = set()
_display('Would remove:', will_remove)
_display('Would not remove (might be manually added):', will_skip)
_display('Would not remove (outside of prefix):', self._refuse)
You can see compress_for_output_listing
seperating files to be deleted from files to keep, except if verbose
is True
, it seems to delete them all. It's a bummer though, since verbose
seems to be an internal function argument, and there is no command-line argument to set it, and would require changes to the source code for it to delete all files instead.