我正在尝试在 Ubuntu 12.04/12.10 上安装 Quickshot 应用程序,并且每当我运行 setup.py 时都会遇到以下错误(如果我只运行 setup.py、setup.py 检查、setup.py 也没关系build 或 setup.py clean——我没有尝试 setup.py install)。
WARNING: the following files are not recognized by DistUtilsExtra.auto:
bin/quickshot
hooks/quickshot-crashdb.conf
hooks/source_quickshot.py
po/quickshot.pot
quickshot.desktop
run.sh
我还将 setup.py 文件的副本粘贴到其中。在 Ubuntu 12.10 上,bin/quickshot 不会触发,但其余部分会触发。非常感谢任何有关修复什么以使其正常工作的建议。
谢谢,祝你周末愉快(剩下的):)帕特里克。
安装程序.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2010 Benjamin Humphrey <humphreybc@gmail.co>
#This program is free software: you can redistribute it and/or modify it
#under the terms of the GNU General Public License version 3, as published
#by the Free Software Foundation.
#
#This program is distributed in the hope that it will be useful, but
#WITHOUT ANY WARRANTY; without even the implied warranties of
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
#PURPOSE. See the GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License along
#with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
try:
import DistUtilsExtra.auto
except ImportError:
import sys
print >> sys.stderr, 'To build quickshot you need https://launchpad.net/python-distutils-extra'
sys.exit(1)
assert DistUtilsExtra.auto.__version__ >= '2.10', 'needs DistUtilsExtra.auto >= 2.10'
import os
def update_data_path(prefix, oldvalue=None):
try:
fin = file('quickshot/quickshotconfig.py', 'r')
fout = file(fin.name + '.new', 'w')
for line in fin:
fields = line.split(' = ') # Separate variable from value
if fields[0] == '__quickshot_data_directory__':
# update to prefix, store oldvalue
if not oldvalue:
oldvalue = fields[1]
line = "%s = '%s'\n" % (fields[0], prefix)
else: # restore oldvalue
line = "%s = %s" % (fields[0], oldvalue)
fout.write(line)
fout.flush()
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError), e:
print ("ERROR: Can't find quickshot/quickshotconfig.py")
sys.exit(1)
return oldvalue
def update_desktop_file(datadir):
try:
fin = file('quickshot.desktop.in', 'r')
fout = file(fin.name + '.new', 'w')
for line in fin:
if 'Icon=' in line:
line = "Icon=%s\n" % (datadir + 'media/icon.png')
fout.write(line)
fout.flush()
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError), e:
print ("ERROR: Can't find quickshot.desktop.in")
sys.exit(1)
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
def run(self):
if self.root or self.home:
print "WARNING: You don't use a standard --prefix installation, take care that you eventually " \
"need to update quickly/quicklyconfig.py file to adjust __quickly_data_directory__. You can " \
"ignore this warning if you are packaging and uses --prefix."
previous_value = update_data_path(self.prefix + '/share/quickshot/')
update_desktop_file(self.prefix + '/share/quickshot/')
DistUtilsExtra.auto.install_auto.run(self)
update_data_path(self.prefix, previous_value)
##################################################################################
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
##################################################################################
DistUtilsExtra.auto.setup(
name='quickshot',
version='0.0.83',
license='GPL-3',
author='Benjamin Humphrey, Tommy Brunn',
author_email='humphreybc@gmail.com',
url='https://launchpad.net/quickshot',
description='Quickshot is a program designed for capturing a large number of screenshots in different languages. It is principally designed for use with the Ubuntu Manual Project, but should be able to be tweaked for different projects and uses.',
#long_description='Here a longer description',
cmdclass={'install': InstallAndUpdateDataDirectory}
)
如果 setup.py 文件中的空格不正确,那是因为必须在此处手动缩进它们。应该假定它们在实际文件中是正确的,因为它确实安装在 Ubuntu 10.04、10,10 和可能的 11.04/11.10 下(我还没有验证最后两个)。
setup.py build 的结果也如下:
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/quickshot
creating build/lib.linux-x86_64-2.7/quickshot/lib
creating build/lib.linux-x86_64-2.7/quickshot/lib/capture
copying quickshot/lib/capture/__init__.py -> build/lib.linux-x86_64-2.7/quickshot/lib/capture
copying quickshot/__init__.py -> build/lib.linux-x86_64-2.7/quickshot
copying quickshot/common.py -> build/lib.linux-x86_64-2.7/quickshot
creating build/lib.linux-x86_64-2.7/quickshot/lib/server
copying quickshot/lib/server/__init__.py -> build/lib.linux-x86_64-2.7/quickshot/lib/server
creating build/lib.linux-x86_64-2.7/quickshot/lib/resolution
copying quickshot/lib/resolution/__init__.py -> build/lib.linux-x86_64-2.7/quickshot/lib/resolution
copying quickshot/lib/__init__.py -> build/lib.linux-x86_64-2.7/quickshot/lib
creating build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/screenshot_list.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/user_account.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/screenshot_compare.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/about.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/credits.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/graphics_confirm.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/licence.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/dialogue.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/graphics_change.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/base.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/__init__.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/user_details.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/screenshot_detail.py -> build/lib.linux-x86_64-2.7/quickshot/gui
copying quickshot/gui/project_selection.py -> build/lib.linux-x86_64-2.7/quickshot/gui
creating build/lib.linux-x86_64-2.7/quickshot/lib/account
copying quickshot/lib/account/environment.py -> build/lib.linux-x86_64-2.7/quickshot/lib/account
copying quickshot/lib/account/__init__.py -> build/lib.linux-x86_64-2.7/quickshot/lib/account
running build_i18n
intltool-update -p -g quickshot
running build_icons
running build_help
WARNING: the following files are not recognized by DistUtilsExtra.auto:
bin/quickshot
hooks/quickshot-crashdb.conf
hooks/source_quickshot.py
quickshot.desktop
run.sh
以下是 setup.py 安装的结果:
running install
ERROR: Can't find quickshot/quickshotconfig.py
Traceback (most recent call last):
File "setup.py", line 103, 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 83, in run
previous_value = update_data_path(self.prefix + '/share/quickshot/')
File "setup.py", line 54, in update_data_path
sys.exit(1)
NameError: global name 'sys' is not defined