安装时很快出现错误

安装时很快出现错误

我将一个应用程序移植到 Quickly,并根据需要替换了所有文件。当我说quickly run应用程序运行时没有问题时。但是,当我尝试打包/安装它时,问题就出现了。以下是我尝试安装时出现的问题:

$ sudo python ./setup.py install 
running install
running build
running build_py
running build_scripts
running build_i18n
intltool-update -p -g foobar
running build_icons
running build_help
running install_lib
running install_scripts
changing mode of /usr/local/bin/foobar to 755
running install_data
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/foobar-0.1a.egg-info
Writing /usr/local/lib/python2.7/dist-packages/foobar-0.1a.egg-info
Traceback (most recent call last):
  File "setup.py", line 146, in <module>
    cmdclass={'install': InstallAndUpdateDataDirectory}
  File "/usr/lib/python2.7/dist-packages/DistUtilsExtra/auto.py", line 100, in setup
    distutils.core.setup(**attrs)
  File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 120, in run
    target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
  File "/usr/lib/python2.7/posixpath.py", line 422, in relpath
    start_list = [x for x in abspath(start).split(sep) if x]
  File "/usr/lib/python2.7/posixpath.py", line 352, in abspath
    if not isabs(path):
  File "/usr/lib/python2.7/posixpath.py", line 61, in isabs
    return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'

由于程序quickly run没有问题,所以我认为是安装文件的问题:这是我配置的部分setup.py

DistUtilsExtra.auto.setup(
    name='foobar',
    version='0.1a',
    license='GPL-3',
    author='My name',
    author_email='[email protected]',
    description='A description',
    long_description='A looooonger description',
    url='https://launchpad.net/foobar',
    cmdclass={'install': InstallAndUpdateDataDirectory}
    )

一些额外的信息:

$ quickly --version
Quickly 12.08.1

  Python interpreter: /usr/bin/python 2.7.5
  Python standard library: /usr/lib/python2.7

  Quickly used library: /usr/lib/python2.7/dist-packages/quickly
  Quickly data path: /usr/share/quickly
  Quickly detected template directories:
          /usr/share/quickly/templates/

Copyright 2009 Rick Spencer
Copyright 2009-2011 Didier Roche
Copyright 2010-2011 Canonical Ltd
https://launchpad.net/quickly

quickly comes with ABSOLUTELY NO WARRANTY. quickly is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 3 or later.

我正在使用 Ubuntu 13.10,但我也在 Trusty 上测试过并得到了相同的结果。

谢谢你!

答案1

self.root在您的 setup.py 文件中None哪个会引发异常。

例子:

# This is to mimic line 120 in your setup.py file
# target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
>>> os.path.relpath("/spam/eggs", None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/posixpath.py", line 422, in relpath
    start_list = [x for x in abspath(start).split(sep) if x]
  File "/usr/lib/python2.7/posixpath.py", line 352, in abspath
    if not isabs(path):
  File "/usr/lib/python2.7/posixpath.py", line 61, in isabs
    return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'

这是相同的回溯。我不熟悉 Quickly,但你必须弄清楚为什么self.root会这样设置None,然后修复它。

相关内容