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: make clean failed on OpenBSD
Type: Stage: resolved
Components: Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: petri.lehtinen, pitrou, python-dev, rpointel, vstinner
Priority: normal Keywords: easy

Created on 2011-11-02 23:15 by rpointel, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python3_3_Makefile_pre_in rpointel, 2011-11-02 23:15 diff to correct find -exec review
Messages (15)
msg146882 - (view) Author: Remi Pointel (rpointel) * Date: 2011-11-02 23:15
Hi,

"make clean" failed on OpenBSD with this error:

find: -exec: no terminating ";"
*** Error code 1 (ignored)

It seems that "-exec" with "+" is a GNU extension.

Are you OK with this diff which does the same and is multi-platform?
Modifications can only be done for __pycache__, what do you prefer?

Cheers,

Remi.
msg146883 - (view) Author: Remi Pointel (rpointel) * Date: 2011-11-02 23:16
FYI I tested with Python 3.3, but I didn't look for 2.7 and 3.2, I think modifications are also needed.
msg146899 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-03 08:00
According to the man page, find -print0 and xargs -r are also GNU extensions. Even though they work on OpenBSD (do they?), they could still break on some platforms.

As find -exec cmd {} ';' is already used for everything but __pycache__, I'd rather only change the removal of __pycache__. I believe there are more files that match '*.py[co]' than '__pycache__', and people are already waiting for a separate rm process to be invoked on each *.py[co], so invoking a separate rmdir for each __pycache__ shouldn't make it much slower.
msg146902 - (view) Author: Remi Pointel (rpointel) * Date: 2011-11-03 08:19
> According to the man page, find -print0 and xargs -r are also GNU extensions. Even though they work on OpenBSD (do they?), they could still break on some platforms.

Yes, it works fine, but you're allright.

> As find -exec cmd {} ';' is already used for everything but __pycache__, I'd rather only change the removal of __pycache__. I believe there are more files that match '*.py[co]' than '__pycache__', and people are already waiting for a separate rm process to be invoked on each *.py[co], so invoking a separate rmdir for each __pycache__ shouldn't make it much slower.

You mean to just exec rmdir instead of rm only for __pycache__?

Cheers,

Remi.
msg146905 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-03 08:37
I mean that this should be enough to close this issue:

-	-find $(srcdir) -name '__pycache__' -exec rmdir {} '+'
+	-find $(srcdir) -name '__pycache__' -exec rmdir {} ';'

That is, use ';' instead of the unportable '+' instead of changing all cleaning to use find ... | xargs ...
msg146907 - (view) Author: Remi Pointel (rpointel) * Date: 2011-11-03 08:48
Please see this:

http://bugs.python.org/issue8665
http://hg.python.org/cpython/rev/5468f3aee4ae/
msg146908 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-03 08:55
Ah, I didn't think about that.

How about using the -depth option then? It's in POSIX but does OpenBSD have it? The man page of GNU find says it has a -d option (that does the same as -depth) for compatibility with BSD.
msg146909 - (view) Author: Remi Pointel (rpointel) * Date: 2011-11-03 09:07
> How about using the -depth option then? It's in POSIX but does OpenBSD have it? The man page of GNU find says it has a -d option (that does the same as -depth) for compatibility with BSD.

Yes, we have this option:
-depth  This primary always evaluates to true.  The same as specifying the -d option.

Source: http://www.openbsd.org/cgi-bin/man.cgi?query=find
msg146910 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-11-03 09:24
By the way, removing *.pyc and *.pyo is useless: Python 3.3 only generates such files in __pycache__:

+	-find $(srcdir) -name '*.py[co]' -print0 | xargs -0r rm -f
+	-find $(srcdir) -name '__pycache__' -print0 | xargs -0r rmdir

can be simplified to

+	-find $(srcdir) -name '__pycache__' -print0 | xargs -0r rm -rf
msg146912 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-03 09:27
> +	-find $(srcdir) -name '__pycache__' -print0 | xargs -0r rm -rf

I'd still do it like this for portability's sake:

+	-find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';'
msg146915 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-03 11:28
> I'd still do it like this for portability's sake:
> 
> +	-find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';'

Then you'd probably reintroduce issue8665.
msg146916 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-03 11:42
> Then you'd probably reintroduce issue8665.

No, the -depth argument avoids that.
msg146921 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-03 12:16
> No, the -depth argument avoids that.

Ah, you are right, my bad.
msg146934 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-03 14:10
The issue exists only in 3.2 and 3.3, as 2.7 doesn't have __pycache__ (PEP 3147). In 3.2 and 3.3, all *.py[co] files are in __pycache__ directories, so the pycremoval make target can only remove the __pycache__ directories, using the -depth option of find to remove child directories before the parent.
msg147105 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-05 20:02
New changeset 41ab1dfaf1d4 by Petri Lehtinen in branch '3.2':
Remove __pycache__ directories correctly on OpenBSD
http://hg.python.org/cpython/rev/41ab1dfaf1d4

New changeset f853a2cbd68b by Petri Lehtinen in branch 'default':
Remove __pycache__ directories correctly on OpenBSD
http://hg.python.org/cpython/rev/f853a2cbd68b
History
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57535
2011-11-05 20:02:42python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg147105

resolution: fixed
stage: needs patch -> resolved
2011-11-03 14:10:12petri.lehtinensetkeywords: + easy

stage: needs patch
messages: + msg146934
versions: + Python 3.2, Python 3.3
2011-11-03 12:16:53pitrousetmessages: + msg146921
2011-11-03 11:42:24petri.lehtinensetmessages: + msg146916
2011-11-03 11:28:57pitrousetmessages: + msg146915
2011-11-03 09:27:41petri.lehtinensetmessages: + msg146912
2011-11-03 09:24:48vstinnersetmessages: + msg146910
2011-11-03 09:07:08rpointelsetmessages: + msg146909
2011-11-03 08:55:02petri.lehtinensetmessages: + msg146908
2011-11-03 08:48:09rpointelsetmessages: + msg146907
2011-11-03 08:37:52petri.lehtinensetmessages: + msg146905
2011-11-03 08:19:51rpointelsetmessages: + msg146902
2011-11-03 08:00:43petri.lehtinensetnosy: + petri.lehtinen
messages: + msg146899
2011-11-02 23:22:16vstinnersetnosy: + vstinner
2011-11-02 23:16:46rpointelsetmessages: + msg146883
2011-11-02 23:15:47rpointelcreate