简体   繁体   中英

python setup.py sdist error: Operation not permitted

I'm trying to create a python source package, but it fails when creating hard links for files.

$ python setup.py sdist

running sdist
running check
reading manifest template 'MANIFEST.in'
writing manifest file 'MANIFEST'
making hard links in foo-0.1...
hard linking README.txt -> foo-0.1
error: Operation not permitted

I've tried running the command with sudo, but it produces the same error.

This also produces the same error:

ln foo bar

I'm using vbox to run a virtual instance of ubuntu, which is probably where the problem comes from. Is there a way round using hard links when creating source distributions?

System information:

Ubuntu server 11.04; VirtualBox 4.14; osx 10.6.6; python 2.7.1;

Same issue. I am using vagrant, my host OS is Windows while the Gust OS is Ubuntu. I am not a vim fan, so @simo's answer does not help me much because I really rely on virtual box shared folders to sync changes made by sublime editor to the Ubuntu virtual machine.

Thanks to Fabian Kochem, he found a quick and dirty workaround: post

# if you are not using vagrant, just delete os.link directly,
# The hard link only saves a little disk space, so you should not care
if os.environ.get('USER','') == 'vagrant':
    del os.link

I ran into the same issues. I was able to get it working by moving the python sources from the virtual box shared folder to my debian home folder. No error on sdist anymore.

I hope it helps.

It is unclear from your question what step is failing. Might be the hard linking right before the error. You can try strace to see what system call is failing. That should give a better picture of the problem at least.

This python bug report looks like they're not going to fix this until distutils2. Someone did supply a patch that might be useful to you. You might also be able to mount a directory over NFS and build there. I believe that NFS allows hard linking.

看起来这是在Python 2.7.9版本中修复的 - https://hg.python.org/cpython/raw-file/v2.7.9/Misc/NEWS

Issue #8876: distutils now falls back to copying files when hard linking doesn't work. This allows use with special filesystems such as VirtualBox shared folders

This is the way I reached a working uwsgi(Ubuntu 14.04, default Python 2.7.6) with Python-2.7.10.

Steps

Before continuing, you must compile new Python with --enable-shared :

$ ./configure --enabled-shared
$ sudo make altinstall

Context: Ubuntu 14.04 with Python 2.7.6 with uwsgi and uwsgi-python-plugin installed with apt-get Problem: I have a virtualenv for my all with compiled Python-2.7.10

# Previously installed Python-2.7.10 as altinstall
$ python2.7
Python 2.7.10 (default, Nov 25 2015, 11:21:38)
$ source ~/env/bin/activate
$ python
Python 2.7.10 (default, Nov 25 2015, 11:21:38)

Preparing stuff:

$ cd /tmp/
$ git clone https://github.com/unbit/uwsgi.git
$ cd uwsgi
$ make PROFILE=nolang
# On /tmp/uwsgi
$ PYTHON=python ./uwsgi --build-plugin "plugins/python python27"

On ini file:

[uwsgi]
plugins         = python27

Results on:

** Starting uWSGI 1.9.17.1-debian (64bit) on [Thu Nov 26 12:56:42 2015] ***
compiled with version: 4.8.2 on 23 March 2014 17:15:32
os: Linux-3.19.0-33-generic #38~14.04.1-Ubuntu SMP Fri Nov 6 18:17:28 UTC 2015
nodename: maquinote
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 12
current working directory: /etc/uwsgi/apps-enabled
detected binary path: /usr/bin/uwsgi-core
your processes number limit is 257565
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: enabled
uwsgi socket 0 bound to UNIX address /var/run/uwsgi/app/pypi-server/socket fd 3
Python version: 2.7.10 (default, Nov 26 2015, 11:44:40)  [GCC 4.8.4]

None of the above answers solved my problem. However, I was running the following command in a vagrant shared folder on Centos 6:

python setup.py bdist_bdrpm

And ended up with the error:

ln: creating hard link `xxx': Operation not permitted error: Bad exit status from /var/tmp/rpm-tmp.S9pTDl (%install)

It turns out that it's a bash file that eventually executes the hard links:

cat /usr/lib/rpm/redhat/brp-python-hardlink

#!/bin/sh

# If using normal root, avoid changing anything.
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
        exit 0
fi

# Hardlink identical *.pyc and *.pyo, originally from PLD's rpm-build-macros
# Modified to use sha1sum instead of cmp to avoid a diffutils dependency.
find "$RPM_BUILD_ROOT" -type f -name "*.pyc" | while read pyc ; do
       pyo="$(echo $pyc | sed -e 's/.pyc$/.pyo/')"
       if [ -f "$pyo" ] ; then
               csha="$(sha1sum -b $pyc | cut -d' ' -f 1)" && \
               osha="$(sha1sum -b $pyo | cut -d' ' -f 1)" && \
               if [ "$csha" = "$osha" ] ; then
                       ln -f "$pyc" "$pyo"
               fi
       fi
done

Therefore you should be able to replace the hard link ln -f "$pyc" "$pyo" with a copy command cp "$pyc" "$pyo" in the above shell script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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