python setup.py sdist错误:不允许操作

发布于 2024-12-09 12:47:13 字数 524 浏览 0 评论 0原文

我正在尝试创建一个python源包,但在为文件创建硬链接时失败。

$ 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; 虚拟盒 4.14; 操作系统 10.6.6; 蟒蛇2.7.1;

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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

温柔嚣张 2024-12-16 12:47:13

同样的问题。我使用的是 vagrant,我的主机操作系统是 Windows,而 Gust 操作系统是 Ubuntu。我不是 vim 粉丝,所以 @simo 的回答对我没有多大帮助,因为我确实依赖虚拟盒共享文件夹将 sublime 编辑器所做的更改同步到 Ubuntu 虚拟机。

感谢 Fabian 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

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
晨敛清荷 2024-12-16 12:47:13

我遇到了同样的问题。
我可以通过将 python 源代码从 virtual box 共享文件夹移动到我的 debian 主文件夹来使其工作。 sdist 上不再有错误。

我希望它有帮助。

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.

迷路的信 2024-12-16 12:47:13

从您的问题中不清楚哪一步失败了。可能是错误之前的硬链接。您可以尝试 strace 来查看哪个系统调用失败。这至少应该可以更好地描述问题。

这个 python 错误报告 看起来他们不会在 distutils2 之前修复这个问题。有人确实提供了可能对您有用的补丁。您也许还可以通过 NFS 挂载目录并在其中构建。我相信 NFS 允许硬链接。

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.

℉服软 2024-12-16 12:47:13

看起来这个问题已在 Python 版本 2.7.9 中修复 - https://hg.python。 org/cpython/raw-file/v2.7.9/Misc/NEWS

问题 #8876:distutils 现在在硬链接时回退到复制文件
不起作用。这允许与特殊文件系统(例如 VirtualBox)一起使用
共享文件夹

Looks like this was fixed in Python version 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

触ぅ动初心 2024-12-16 12:47:13

这是我使用 Python-2.7.10 实现工作 uwsgi(Ubuntu 14.04,默认 Python 2.7.6)的方法。

步骤

在继续之前,您必须使用 --enable-shared 编译新的 Python:

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

上下文:Ubuntu 14.04 和 Python 2.7.6,使用 apt 安装了 uwsgi 和 uwsgi-python-plugin -得到
问题:我有一个 virtualenv,用于编译 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)

准备东西:

$ 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]

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]
落花随流水 2024-12-16 12:47:13

以上答案都没有解决我的问题。但是,我在 Centos 6 上的 vagrant 共享文件夹中运行以下命令:

python setup.py bdist_bdrpm

并最终出现错误:

ln:创建硬链接“xxx”:不允许操作
错误:/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

因此您应该能够替换硬链接 ln - f "$pyc" "$pyo" 在上面的 shell 脚本中使用复制命令 cp "$pyc" "$pyo" 。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文