classification
Title: distutils should preserve +x bit on data files
Type: behavior Stage: test needed
Components: Distutils Versions: Python 3.4, Python 3.3, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alexis, eric.araujo, gsakkis, tarek, yaneurabeya
Priority: normal Keywords: easy

Created on 2009-02-17 21:54 by gsakkis, last changed 2014-03-13 20:26 by eric.araujo.

Messages (5)
msg82372 - (view) Author: George Sakkis (gsakkis) Date: 2009-02-17 21:54
Distutils ignores file permissions when copying modules and package_data
files to the build directory, and consequently to the installation
directory too. According to an XXX comment at
distutils/command/build_py.py, this is deliberate so that the built
files are not read-only, which would be a nuisance when rebuilding. This
problem though could be solved by just setting the write flag for the
user (chmod u+w) instead of overwriting all the flags. In my case, some
executable files ceased to be executable after installation.

I believe that the default behavior should be changed to preserve all
permissions, with the possible exception of setting u+w. Even that might
be unnecessary; AFAIK to delete a file you need write permissions only
to its parent directory, not to the file itself.

Even if the current behavior is deemed correct, at the very least the
code should be refactored to allow easy overriding. Currently
build_module and build_package_data pass preserve_mode=False in their
body, so I had to copy and paste the whole methods just to set
preserve_mode=True.
msg82389 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-02-17 23:24
> I believe that the default behavior should be changed to preserve 
> all permissions, with the possible exception of setting u+w. 
> Even that might be unnecessary; AFAIK to delete a file you need 
> write permissions only to its parent directory, not to the 
> file itself.

The u+w setting could also be done on the fly by copy_file at
installation time. e.g. when overwriting a read-only file.


> In my case, some 
>  executable files ceased to be executable after installation.

what is your use case of having executable file here ?

I'd use the 'scripts' metadata for that ?


> Even if the current behavior is deemed correct, at the very least 
> the code should be refactored to allow easy overriding.
> Currently build_module and build_package_data pass 
> preserve_mode=False in their
> body, so I had to copy and paste the whole methods 
> just to set preserve_mode=True.

But How do you handle the overwrite of a read-only file in your code then ?
msg82423 - (view) Author: George Sakkis (gsakkis) Date: 2009-02-18 15:51
> what is your use case of having executable file here ?
>
> I'd use the 'scripts' metadata for that ?

For one thing they are external binaries, not python scripts, and second
they are used internally only (through Subprocess), they are not
supposed to be called directly by clients.

> But How do you handle the overwrite of a read-only file in your code 
> then ?

I didn't, all my files were writable (by me), but if I had to, I'd look
at tweaking the directory write permissions; as I mentioned, I don't
think file permissions affect whether you can delete the file.
msg151384 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-01-16 16:33
FTR it looks like http://mail.python.org/pipermail/python-list/2009-January/1188084.html was the original report for this.
msg201053 - (view) Author: Garrett Cooper (yaneurabeya) Date: 2013-10-23 18:51
The whole permissions setting operation seems a bit convoluted.

I was hoping there was something formalized with install_data.py where I could specify a default or fine-grained user/group/mode for files, but it doesn't appear to be possible. I'll investigate applying a custom rule after install is run, but I would prefer for this to be formalized in the future.
History
Date User Action Args
2014-03-13 20:26:15eric.araujosetassignee: tarek ->
title: distutils ignores file permissions -> distutils should preserve +x bit on data files
components: + Distutils, - Distutils2
versions: + Python 2.7, Python 3.3, Python 3.4, - 3rd party
2013-10-23 18:51:00yaneurabeyasetnosy: + yaneurabeya
messages: + msg201053
2012-02-03 20:57:52patrick.andrewsetnosy: + alexis
title: build_module failure -> distutils ignores file permissions

components: + Distutils2, - Distutils
versions: + 3rd party, - Python 2.7
2012-02-03 20:56:31patrick.andrewsettitle: build_module faulre -> build_module failure
2012-02-03 20:56:27patrick.andrewsettitle: Distutils ignores file permissions -> build_module faulre
components: + Distutils, - Distutils2
versions: + Python 2.7, - 3rd party
2012-01-16 16:33:20eric.araujosetmessages: + msg151384
2010-09-30 02:10:10eric.araujosetkeywords: + easy
stage: test needed
versions: + 3rd party, - Python 2.6, Python 2.5, Python 3.1, Python 2.7, Python 3.2
2010-08-10 13:54:40eric.araujosetnosy: gsakkis, tarek, eric.araujo
components: + Distutils2, - Distutils
versions: + Python 2.6, Python 2.5, Python 3.2
2010-06-03 14:54:56eric.araujosetnosy: + eric.araujo
2009-02-18 15:51:48gsakkissetmessages: + msg82423
2009-02-17 23:24:38tareksetmessages: + msg82389
versions: + Python 3.1, Python 2.7
2009-02-17 21:54:53gsakkiscreate