This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: distutils2 clean command: Remove extension modules built in-place
Type: behavior Stage: resolved
Components: Documentation Versions: 3rd party
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eric.araujo, pitrou, purpleidea, python-dev, r.david.murray, tarek, thijs
Priority: normal Keywords: patch

Created on 2009-05-29 15:51 by purpleidea, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
clean.py.patch purpleidea, 2009-05-29 15:51 patch for /usr/lib/python2.5/distutils/command/clean.py
clean.py.patch purpleidea, 2009-06-01 18:47 Updated patch. So that everyone is happy :)
Messages (17)
msg88512 - (view) Author: James (purpleidea) Date: 2009-05-29 15:51
Priority: 4
Keywords: patch, distutils, pyc
Comment:
I posted this on the distutils mailing list, and they said I should post
it here instead.

---
Hi,
I'm certaintly new to distutils and setuptools, however I figured I'd
send in this patch, and either it will get merged because it's a great
idea or someone will perhaps tell me why this doesn't exist already.
(or maybe it does and i can't find it)
In any case, it adds the pyc option to the clean command so that the
.pyc can be removed on request. Personally i'll have a [clean] pyc=1
option in my setup.cfg, but that's for my convenience.
cheers,

_J


---

ps: i wasn't able to pick a priority or keywords, there isn't a box to
type those in, however the titles are there. so either i don't have
permissions or there's a bug ?
msg88637 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-06-01 10:09
The clean command cleans up temporary files from 'build' command.

Your patch removes files that are not generated by the build command only
but by a normal usage of Python modules.

Why do you need to remove them precisely ?
msg88642 - (view) Author: James (purpleidea) Date: 2009-06-01 13:11
Hi, the patch only removes them if one adds the --pyc option.
I think it is a good idea to have some option or target somewhere to
remove the types of files that can be regenerated because often
developers want to "get them out of the way". Example: I'll be working
on a project in my code directory, and it's nice to be able to do an "$
ls" without seeing extra files lying that clutter up the view. Perhaps
different people want to remove them for different reasons. I remember
searching for "remove .pyc" or something like it and it returned some
hits from other people wanting similar functionality. Thanks for your
time, I hope you include something like this patch in upstream.

_J
msg88644 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-06-01 13:43
It seems to me that this functionality is similar to what a 'distclean'
target would do in a typical makefile.  Don't know if that perspective
helps any :)
msg88645 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-06-01 14:32
I don't think distutils should host whetever functionality useful to
developers. Distutils is for packaging and distributing Python software.
msg88651 - (view) Author: James (purpleidea) Date: 2009-06-01 16:07
I could agree with R. David Murray, and I think that it's fine that this
be included under a dist clean command.
Ultimately I'm writing an application and I'm trying to use distutils
with it. I'll potentially run a: "$ setup.py build_ext -i" or whatever
it may be, and then I'll want to get rid of all the mess. So I'll want
to run a clean. If that clean won't get rid of .pyc for me in one
command, then i have to run a second shell script to clean my dir,
instead of sticking the two together. Which is why i think a clean --pyc
option is useful (off by default) and which I can easily enable in
setup.cfg with [clean] pyc=1
I think this is harmless. Anyone agree?

thanks!
_J
msg88652 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-06-01 16:11
I'm not sure why you call it a "mess". Generating a pyc file is the
normal way of operating when importing a Python module from source. It's
not just distutils.

And the fact that it's "harmless" does not justify adding a distutils
option for something which doesn't seem to have anything to do with
distutils...
msg88665 - (view) Author: James (purpleidea) Date: 2009-06-01 18:47
ps: included is a platform independent version of the code, so that it
doesn't depend on os.system() specific commands.

HTH,
_J
msg88666 - (view) Author: James (purpleidea) Date: 2009-06-01 18:56
Antoine: Okay sorry not a mess then.
I just figure that if i'm using the distutils tool for doing all the fun
things to my local source directory that I potentially used to do with
say a makefile, then would it not be beneficial to have a useful
-option- (as included in the patch). It won't affect any previous
distutils setups, and can only benefit future users. Why not?

_J
msg88668 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-06-01 19:36
The only reason I would see to clean .pyc file in distutils clean
command is if the build command (or any other command) would generate
them in the source tree, which is not the case.

That said, build_ext -i *does* create .so files in the source tree, so
we should provide a way to remove them I think.
msg88743 - (view) Author: James (purpleidea) Date: 2009-06-02 13:42
Currently, I have (had) a make file with a clean target that would
remove these files. Would you recommend keeping this file and it's
associated functionality, or is the idea to be able to integrate this
into distutils and be able to do away with makefiles for python projects?

I'm aware that I can subclass Command and make my own "target"... I've
done this, but it seems to me it's better suited upstream.
msg102656 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-04-09 00:08
Hello

So, is this bug “add a distclean command” now?

Regards
msg102657 - (view) Author: James (purpleidea) Date: 2010-04-09 00:22
i'm fine with that and willing to contribute patches, however i would feel better if whoever upstream was, was more supportive of the idea.
someone let me know.

a thought:
- it's true (as mentioned) that distclean isn't necessarily directly related to distributing python scripts, however (in my mind anyways) i see distutils as a replacement for common things we do in makefiles. so as a result if we did this we could get rid of makefiles and provide useful "action" targets such as distclean, test, etc... 100% pure python if needed...
msg127862 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-04 03:04
Discussion summary:
- clean is supposed to remove the products of build
- build_ext is a subcommand of build
- build_ext with the inplace option writes files that are not removed by clean
- removing .pyc files is out of scope (they’re products of normal Python behavior, not related to distutils)
→ I’m reclassifying this as a distutils2 feature request concerning the products of build_ext --inplace.

I’m not sure whether we should remove those products when the --all option is given to clean, or add a new option that we could enable by default.
msg213463 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-13 20:37
New changeset 67ada6ab7fe2 by Éric Araujo in branch '2.7':
Clarify distutils’ clean command (ref #6142)
http://hg.python.org/cpython/rev/67ada6ab7fe2
msg213489 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-13 22:32
New changeset 066b896b6132 by Éric Araujo in branch '3.3':
Clarify distutils’ clean command (ref #6142)
http://hg.python.org/cpython/rev/066b896b6132

New changeset 50ee8fe8e841 by Éric Araujo in branch 'default':
Clarify distutils’ clean command (ref #6142)
http://hg.python.org/cpython/rev/50ee8fe8e841
msg213491 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-13 22:34
distutils doc now warns about clean not removing extensions built in place.  distutils2 is no more.  Closing.
History
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50392
2014-03-13 22:34:12eric.araujosetstatus: open -> closed

assignee: docs@python
components: + Documentation, - Distutils2

nosy: + docs@python
messages: + msg213491
resolution: out of date
stage: needs patch -> resolved
2014-03-13 22:32:43python-devsetmessages: + msg213489
2014-03-13 20:37:52python-devsetnosy: + python-dev
messages: + msg213463
2011-02-04 03:04:07eric.araujosetassignee: tarek -> (no value)
components: + Distutils2, - Distutils
title: Distutils doesn't remove .pyc files -> distutils2 clean command: Remove extension modules built in-place
nosy: pitrou, tarek, eric.araujo, r.david.murray, thijs, purpleidea
versions: + 3rd party, - Python 3.1, Python 2.7
messages: + msg127862
stage: needs patch
2010-04-09 00:22:15purpleideasetmessages: + msg102657
2010-04-09 00:08:28eric.araujosetnosy: + eric.araujo
messages: + msg102656
2010-03-16 00:04:14thijssetnosy: + thijs
2009-06-02 13:42:53purpleideasetmessages: + msg88743
2009-06-01 19:36:40tareksetmessages: + msg88668
2009-06-01 18:56:24purpleideasetmessages: + msg88666
2009-06-01 18:47:50purpleideasetfiles: + clean.py.patch

messages: + msg88665
2009-06-01 16:11:49pitrousetmessages: + msg88652
2009-06-01 16:07:41purpleideasetmessages: + msg88651
2009-06-01 14:32:06pitrousetnosy: + pitrou
messages: + msg88645
2009-06-01 13:43:26r.david.murraysetnosy: + r.david.murray
messages: + msg88644
2009-06-01 13:11:47purpleideasetmessages: + msg88642
2009-06-01 10:09:12tareksetmessages: + msg88637
components: + Distutils, - Library (Lib)
versions: + Python 3.1, Python 2.7, - Python 2.5
2009-06-01 03:11:35jnollersetpriority: normal
assignee: tarek

components: + Library (Lib)
nosy: + tarek
2009-05-29 15:51:10purpleideacreate