python setup.py sdist错误:不允许操作
我试图创建一个python源代码包,但创建文件的硬链接时失败。python setup.py sdist错误:不允许操作
$ 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
我试着用sudo运行命令,但它会产生相同的错误。
这也产生了同样的错误:
ln foo bar
我用VBOX Ubuntu运行的虚拟实例,这大概是哪里出了问题的来源。创建源代码发行版时,是否有使用硬链接的方法?
系统信息:
Ubuntu的服务器11.04; VirtualBox 4.14; osx 10.6.6; python 2.7.1;
从你的问题来看,目前还不清楚哪一步失败。可能是错误发生之前的硬链接。您可以尝试strace以查看哪些系统调用失败。至少应该能够更好地了解问题。
This python bug report看起来他们不会去解决这个问题,直到distutils2。有人提供了一个可能对你有用的补丁。你也许可以通过NFS挂载一个目录并在那里建立。我相信NFS允许硬连接。
我遇到了同样的问题。 我能够通过将虚拟框共享文件夹中的Python源代码移动到我的debian主文件夹中来实现它。 sdist再也没有错误了。
我希望它有帮助。
这对我有用 - 我想,你无法在某些装入的卷上创建硬链接。 –
这是由于这个问题:https://www.virtualbox.org/ticket/10085 –
同样的问题。我使用流浪汉,我的主机操作系统是Windows,而Gust OS是Ubuntu。我不是一个vim粉丝,所以@ simo的回答对我来说帮不了多少忙,因为我真的依靠虚拟机箱共享文件夹来将由sublime编辑器所做的更改同步到Ubuntu虚拟机。
感谢费边Kochem,他发现了一个快速和肮脏的解决方法: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
如果以root身份运行,此检查将失败;我不幸无法避免。 :( – ThorSummoner
@ThorSummoner你可以直接使用'del os.link' –
@ThorSummoner你并没有被束缚在特定的条件下,你可能必须根据自己的情况来创造性,例如,你可能会把'-vagrant '在你的同步文件夹名称中,'if'-vagrant'in os.path.abspath(os.path.dirname(__ file __)):'... – Jamey
看起来这是固定在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
这是我使用Python-2.7.10实现了工作uwsgi(Ubuntu 14.04,默认Python 2.7.6)。
步骤
在继续之前,您必须编译新的Python与--enable-shared
:
$ ./configure --enabled-shared
$ sudo make altinstall
语境的Ubuntu 14.04使用Python 2.7.6与APT-安装uwsgi和uwsgi-蟒蛇,插件得到 问题:我为编译Python-2.7的所有人准备了virtualenv。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)
准备的东西:
$ 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"
在ini文件:
[uwsgi]
plugins = python27
结果上:
** 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]
以上答案都不对解决我的问题。但是,我是在一个无业游民的共享文件夹运行在CentOS 6以下命令:
python setup.py bdist_bdrpm
,结束了与错误:
ln: creating hard link `xxx': Operation not permitted error: Bad exit status from /var/tmp/rpm-tmp.S9pTDl (%install)
事实证明,这是一个bash文件,最终执行硬链接:
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
因此,你应该能够取代上述shell脚本复制命令cp "$pyc" "$pyo"
硬链接ln -f "$pyc" "$pyo"
。
你使用的是什么操作系统/ python版本? –
我正在运行Ubuntu服务器11.04。 Python 2.7.1 – rlayte
我在Mac上尝试构建一个通过samba共享文件夹访问的python项目时,发生了同样的情况。 –