py2app IOError: [Errno 63] 文件名过长:

5
我正在尝试在OS X 10.6上使用Python 2.6和py2app打包PySide应用程序。
问题是,似乎py2app陷入了循环,并将相同的目录路径递归地追加到自身,最终导致上述Python文件过长的IOError。以下是我得到的堆栈跟踪:
     copying /Users/mlakewood/Documents/Programming/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-
universal/python2.6-standalone/app/collect/_builtinSuites/__init__.pyc -> /Users/mlakewood/Documents/Programming/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/_builtinSuites
    Traceback (most recent call last):
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/build_app.py", line 579, in _run
        self.run_normal()
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/build_app.py", line 650, in run_normal
        self.create_binaries(py_files, pkgdirs, extensions, loader_files)
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/build_app.py", line 718, in create_binaries
        self.copy_package_data(item, self.collect_dir)
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/build_app.py", line 809, in copy_package_data
        copy_tree(pth, os.path.join(target_dir, fname))
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/util.py", line 501, in copy_tree
        dry_run=dry_run, condition=condition))
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/util.py", line 501, in copy_tree
        dry_run=dry_run, condition=condition))
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/util.py", line 501, in copy_tree
        dry_run=dry_run, condition=condition))

剪切...

取消剪切...


这些文本可能是在编辑器或其他应用程序中的“剪切”和“取消剪切”命令的标签或按钮。
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/util.py", line 501, in copy_tree
    dry_run=dry_run, condition=condition))
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/util.py", line 501, in copy_tree
    dry_run=dry_run, condition=condition))
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/util.py", line 501, in copy_tree
    dry_run=dry_run, condition=condition))
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2app/util.py", line 504, in copy_tree
    preserve_times, update, dry_run=dry_run)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/file_util.py", line 165, in copy_file
    _copy_file_contents(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/file_util.py", line 47, in _copy_file_contents
    fdst = open(dst, 'wb')
IOError: [Errno 63] File name too long: '/Users/mlakewood/Documents/Programming/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect/_builtinSuites/__init__.pyc'
> /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/file_util.py(47)_copy_file_contents()
-> fdst = open(dst, 'wb')

以下是我的setup.py文件

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['gui.py']
DATA_FILES = []
OPTIONS = {}
#OPTIONS = {'argv_emulation': True}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
    includes=['PySide']
)
2个回答

11
这个问题很旧,但昨晚我遇到了同样的问题并找到了解决方法。事实证明,对我来说,问题是由py2app试图在包含所构建代码引用的模块的另一个文件夹内生成builddist文件夹引起的。
由于py2app默认将builddist文件夹放置在当前工作目录中,如果您正在与其他被引用代码的模块在同一工作目录下编写构建脚本,则会遇到问题。
我通过使用py2app选项来强制创建builddist目录以位于当前目录下的父目录中来解决问题,但您可以将它们放在任何地方并实现相同的效果:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import py2app
import sys
from distutils.core import setup
from os import getcwd
from pathlib import Path

sys.argv.append('py2app')
setup(app=['<your_code.py>'],
      options=dict(py2app=dict(bdist_base=str(Path(getcwd()).parent)
      + '/build', dist_dir=str(Path(getcwd()).parent) + '/dist')))

1

检查路径是否存在任何可能导致无限递归的符号链接。打开终端应用程序,然后输入:

ls -l /Users/mlakewood/Documents/Programming/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect

如果你在执行 ls -l 命令后看到类似这样的输出:
/Users/mlakewood/Documents/Programming/DataWrangler/build/bdist.macosx-10.6-universal/python2.6-standalone/app/collect -> ../../../../../build/

那就是导致问题的原因。但脚本在搜索文件的方式中肯定存在某种导致无限递归循环的东西。


1
在构建之前,那里没有任何文件。构建失败后,该文件夹中也没有任何符号链接...所以我不认为那是问题...感谢您的回答.. - Mark Lakewood

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接