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

时间:2011-10-09 03:24:27

标签: python pyside py2app

我试图使用python 2.6在OS X 10.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))

snip ...(许多行与上面和下面的行相同)

... unsnip

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 个答案:

答案 0 :(得分:8)

这个问题真的很老了,但昨晚我遇到了同样的问题并找到了解决方案。对我来说,问题是 py2app 的副产品试图在另一个包含引用模块的文件夹中生成 build dis t文件夹通过正在构建的代码。

由于 py2app 默认将 build dist 文件夹放在当前工作目录中,这意味着如果您遇到麻烦在与代码引用的其他模块相同的工作目录中编写构建脚本。

我通过使用 py2app 选项强制在以下当前目录的父目录中创建 build dist 目录来修复此问题,但你可以把它们放在你选择的任何地方并实现同样的目的:

#!/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 :(得分: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/

那就是造成这个问题的原因。但是肯定会出现一种导致脚本搜索文件的无限递归循环的东西。