Issue 5300: distutils should preserve +x bit on data files (original) (raw)

Created on 2009-02-17 21:54 by gsakkis, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
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: Enji Cooper (ngie) * 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.
msg386416 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:29
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils. If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2022-04-11 14:56:45 admin set github: 49550
2021-02-03 18:29:09 steve.dower set status: open -> closednosy: + steve.dowermessages: + resolution: out of datestage: test needed -> resolved
2014-03-13 20:26:15 eric.araujo set assignee: tarek -> title: distutils ignores file permissions -> distutils should preserve +x bit on data filescomponents: + Distutils, - Distutils2versions: + Python 2.7, Python 3.3, Python 3.4, - 3rd party
2013-10-23 18:51:00 ngie set nosy: + ngiemessages: +
2012-02-03 20:57:52 patrick.andrew set nosy: + alexistitle: build_module failure -> distutils ignores file permissionscomponents: + Distutils2, - Distutilsversions: + 3rd party, - Python 2.7
2012-02-03 20:56:31 patrick.andrew set title: build_module faulre -> build_module failure
2012-02-03 20:56:27 patrick.andrew set title: Distutils ignores file permissions -> build_module faulrecomponents: + Distutils, - Distutils2versions: + Python 2.7, - 3rd party
2012-01-16 16:33:20 eric.araujo set messages: +
2010-09-30 02:10:10 eric.araujo set keywords: + easystage: test neededversions: + 3rd party, - Python 2.6, Python 2.5, Python 3.1, Python 2.7, Python 3.2
2010-08-10 13:54:40 eric.araujo set nosy:gsakkis, tarek, eric.araujocomponents: + Distutils2, - Distutilsversions: + Python 2.6, Python 2.5, Python 3.2
2010-06-03 14:54:56 eric.araujo set nosy: + eric.araujo
2009-02-18 15:51:48 gsakkis set messages: +
2009-02-17 23:24:38 tarek set messages: + versions: + Python 3.1, Python 2.7
2009-02-17 21:54:53 gsakkis create