简体   繁体   English

python包的正确权限

[英]Proper permissions for python packages

I keep seeing this with python packages... a python package installs extra files. 我一直看到python包...一个python包安装额外的文件。 In the packaged tar, you get things like this: 在打包的tar中,你得到这样的东西:

-rw-r-----  1 schwehr eng     7 Sep  3 18:10 VERSION

for: 对于:

https://github.com/scrapy/scrapy/blob/master/scrapy/VERSION https://github.com/scrapy/scrapy/blob/master/scrapy/VERSION

Then when you python setup.py install as root into a managed environment (eg fink for MacOSX) that uses root permissions, this file gets owned by root and the permissions are preserved. 然后,当您以root用户身份将python setup.py安装到使用root权限的托管环境(例如fink for MacOSX)时,此文件将由root拥有并保留权限。 Then the code run as a user is unable to access this file. 然后代码运行,因为用户无法访问此文件。

This project and other projects with the same issue (typically with the eggs portion of their install) use python setup.py sdist upload. 此项目和具有相同问题的其他项目(通常使用其安装的egg部分)使用python setup.py sdist upload。

How are these projects supposed to build a tar that has the proper permissions so that all files are world readable? 这些项目如何构建具有适当权限的tar,以便所有文件都具有全局可读性? eg 例如

wget https://pypi.python.org/packages/source/S/Scrapy/Scrapy-0.18.2.tar.gz#md5=14f105e2fdb047c666b944990e691389

tar tfvv Scrapy-0.18.2.tar.gz  | head
drwx------ buildbot/buildbot 0 2013-09-03 10:30 Scrapy-0.18.2/
-rw------- buildbot/buildbot 385 2013-09-03 10:27 Scrapy-0.18.2/MANIFEST.in
-rw------- buildbot/buildbot 140 2013-09-03 10:30 Scrapy-0.18.2/setup.cfg
drwx------ buildbot/buildbot   0 2013-09-03 10:30 Scrapy-0.18.2/bin/
-rw------- buildbot/buildbot 114 2013-09-03 10:27 Scrapy-0.18.2/bin/runtests.bat
-rwx------ buildbot/buildbot 1271 2013-09-03 10:27 Scrapy-0.18.2/bin/runtests.sh
-rwx------ buildbot/buildbot   68 2013-09-03 10:27 Scrapy-0.18.2/bin/scrapy
drwx------ buildbot/buildbot    0 2013-09-03 10:30 Scrapy-0.18.2/scrapy/
-rw------- buildbot/buildbot 2785 2013-09-03 10:27 Scrapy-0.18.2/scrapy/telnet.py
drwx------ buildbot/buildbot    0 2013-09-03 10:30 Scrapy-0.18.2/scrapy/commands/

See also: https://github.com/scrapy/scrapy/issues/377 另见: https//github.com/scrapy/scrapy/issues/377

It happens when sdist tarball is generated with a restrictive umask or when files were created without others/nobody read/execute permissions. 当使用限制性umask生成sdist tarball或者在没有其他/ nobody读取/执行权限的情况下创建文件时,会发生这种情况。

A simple workaround is to broak the umask bits and chmod files before tar'ing 一个简单的解决方法是在tar'ing之前扩展umask位和chmod文件

umask 0022 && chmod -R a+rX . && python setup.py sdist upload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM