-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
setup.py leaves build, dist, .egg-info etc + even clean doesn't remove them #1347
Comments
I end up putting this in every setup.py class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
CLEAN_FILES = './build ./dist ./*.pyc ./*.tgz ./*.egg-info'.split(' ')
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
global here
for path_spec in self.CLEAN_FILES:
# Make paths absolute and relative to this path
abs_paths = glob.glob(os.path.normpath(os.path.join(here, path_spec)))
for path in [str(p) for p in abs_paths]:
if not path.startswith(here):
# Die if path in CLEAN_FILES is absolute + outside this directory
raise ValueError("%s is not a path inside %s" % (path, here))
print('removing %s' % os.path.relpath(path))
shutil.rmtree(path) |
Other solutions I've found which have been refined a stage above "here's what's worked for me" code snippets here and on stack overflow:
|
I've made good headway with setupext-janitor starting from @ionelmc's fork https://github.com/ionelmc/setupext-janitor which fixes namespace. There's a blocking issue though on Windows, |
It might be worth opening a PR marked WIP so we can easily see the changes. |
@stuaxo Sorry, I don't follow. A PR here in setuptools? I've identified where the error occurs in setuptools now, but don't know how to proceed. dave-shawley/setupext-janitor#12 (comment) |
Sorry for the noise, was replying on my phone in a hurry :) |
I've got setupext-janitor working and issued a PR to the base master dave-shawley/setupext-janitor#14 |
It would be very nice if the behaviour of clean in setuptools could be improved; the current behaviour is really annoying IMHO. @maphew's updated version of setupext-janitor works nicely (thanks!). However, the original owner/maintainer (@dave-shawley) doesn't seem to be much interested any more (?), unfortunately. Is there a chance to get the patched version released on Pypi somehow? Or even be integrated into setuptools properly? |
Rather than trying to clean up files from the source directory, would it be better to be able to do out-of-source package builds? Something like this: |
@cmarquardt these and other recent comments have woken up setupext-janitor and a recent version has been published to pypi. @dave-shawley wasn't receiving notifications and didn't know there was any interest or significant downstream use. @gary-jackson are you suggesting this be something setup.py does automatically or as documenting best practice instructions? |
Not speaking for @gary-jackson but I'd like it to do this automatically, not sure if it will break someones build process though ? OTOH not leaving random files around has to be a pretty good benefit. |
@maphew I suggest that it be added as functionality (it doesn't work that way currently), then documented as a best practice. It shouldn't break the way it's done now. |
Unfortunately setuptools creates a superfluous 'dist' directory that isn't removed with clean... pypa/setuptools#1347 Working around the test failure it causes... ====================================================================== FAIL: test_sdist ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 141, in <lambda> self.method = lambda test: self.result(test) # method that can be mixed into TestCases File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 208, in result test.fail(self._result.msg) AssertionError: /home/atagar/Desktop/stem/dist already exists, maybe you manually ran 'python setup.py sdist'?
Setuptools 'clean' command doesn't work... pypa/setuptools#1347 Cleaning up after the turds it creates when we run our tests.
I completely agree. I find it very strange that there is no option to select a different output folder AND that the clean command does not really remove the generated artifacts. I think a out-of-source build and proper clean should be natively supported by setuptools, as per previous comments. |
Trying to make a nice workaround for this stuff, I couldn't manage with changing workdir - it fails with line "error: package directory 'my_root_package' does not exist". How it works:
Not really convenient solution, but it does not require any extra code. |
I had problems with that, I added data files to |
If you find an easy-to-use built-in solution, it would be great to post it here as well: https://stackoverflow.com/questions/64952572/output-directories-for-python-setup-py-sdist-bdist-wheel |
Like others who've commented here, I have had to resort to a custom clean command to remove the dist directory. It would be good if this could be fixed in setuptools. A user would reasonably expect that
|
Clean up `dist` directory before starting the build. This is in order to prevent `error: unrecognized arguments` at `python -m install` time, which would occur if `dist` happens to contain a stale wheel from an earlier build. See also: pypa/setuptools#1347
By default, setup.py leaves build, dist, ${project_name}.egg-info directories in a projects directory.
I'm not convinced these need to be here these days, certainly feels messy to have these.
Putting all this output into one directory would be some improvement. But maybe there's a better solution ?
python setup.py clean
doesn't even delete these without adding hacks.The text was updated successfully, but these errors were encountered: