python package installed with setuptools: fixing permission of the PKG-INFO file

Enrico Maria Crisostomo enrico.m.crisostomo at gmail.com
Fri Mar 23 10:35:19 UTC 2018


On 23 Mar 2018, at 11:06, Mojca Miklavec <mojca at macports.org> wrote:
> 
> On 23 March 2018 at 10:28, Enrico Maria Crisostomo
> <enrico.m.crisostomo at gmail.com> wrote:
>> Hi all,
>> 
>> I'm working on fixing a `py-tensorflow` port issue (https://trac.macports.org/ticket/55972) and I've found the following problem when building `py-protobuf3`:
>> 
>>    --->  Building py36-protobuf3
>>    Error: Failed to build py36-protobuf3: command execution failed
>> 
>> The log shows the following:
>> 
>>    :info:build Executing:  cd "/opt/local/var/macports/build/_Users_enrico_repos_github_macports-ports_python_py-protobuf3/py36-protobuf3/work/protobuf-3.5.1/python" && /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 setup.py --no-user-cfg build
>>    :debug:build system:  cd "/opt/local/var/macports/build/_Users_enrico_repos_github_macports-ports_python_py-protobuf3/py36-protobuf3/work/protobuf-3.5.1/python" && /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 setup.py --no-user-cfg build
>>    :info:build Traceback (most recent call last):
>>    :info:build   File "setup.py", line 12, in <module>
>>    :info:build     from setuptools import setup, Extension, find_packages
>>    [...snip...]
>>    :info:build PermissionError: [Errno 13] Permission denied: '/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/absl_py-0.1.11-py3.6.egg-info/PKG-INFO'
>> 
>> The `py-absl` port is a new port that I've added while fixing this issue.  The `PKG-INFO` file referred to in the log message has the following permissions:
>> 
>>    -rw-r-----  1 root  wheel  889 Mar 23 10:04 /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/absl_py-0.1.11-py3.6.egg-info/PKG-INFO
>> 
>> I've verified that adding o+r to the permissions fixes the build issue:
>> 
>>    chmod o+r /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/absl_py-0.1.11-py3.6.egg-info/PKG-INFO
>> 
>> So far so good.  The question now is: what's the best practice to fix _that_ file permissions in the `Portfile`?  The `Portfile` is trivial, uses the `python 1.0` port group and the installation is taken care of by `setuptools`.  Plus, I'm kind of a Python noob.  Is this an installation issue which should be fixed in any one of {upstream, setuptools, python port group, elsewhere}?  Or should I just fix the permissions in the `Portfile` by running `chmod` manually?  In the latter case, I've tried to guess what variables to use to refer to that path on the `post-destroot` phase but I couldn't find the answer.
> 
> I would say this in an upstream issue that should be reported and
> fixed. (That said, we could probably also have some code to
> automatically fix these kind of problems after extracting the files.)

Thanks Mojca.  I'll see whether I can report it upstream, then.  Yes, if this file should have an expected permission mask perhaps it would be desirable to fix it and emit a warning.

> 
> For the moment by far the easiest thing to do would be to use
>    system "chmod +r ${worksrcpath}/wherever-the-file-is"
> probably in post-extract phase.

Thanks, I'll try that then.  The python version appear multiple times in the path: I'll try with a plain replacement, hoping the path structure is not python version-dependent.

> 
> You can do it in post-destroot, but why not fix it immediately? (I
> guess that other files in the tarball might need fixing as well.)
> 
> Mojca

Good point.  I'll do that in post-extract.  I didn't know whether the setup code was making some assumptions (some obvious to me) and set it as such.  From your answer I infer that's not the case, in which case the post-extract phase is probably a better place to do it.

Cheers,
-- 
Enrico


More information about the macports-dev mailing list