我想为 Python 包创建一个设置脚本,该脚本在不同架构上的行为不同。
我从以下内容开始:
class CustomInstallCommand(install):
def run(self):
if 'win32' in sys.platform:
if not os.path.exists('./.setup'):
os.mkdir('./.setup')
urllib.urlretrieve(("http://www.voidspace.org.uk/downloads/"
"pycrypto26/pycrypto-2.6.win32-py2.7.exe"),
os.path.join('./.setup',
('pycrypto-2.6.win32-py2.7.exe')))
os.system('easy_install '
+ os.path.join('./.setup',
'pycrypto-2.6.win32-py2.7.exe'))
### here should come more windows specific instructions
### how do I get my setup script to download all the dependecies given below???
install.run(self)
else:
install.run(self)
setup(... trimmed ...
zip_safe=False,
install_requires=['pycrypto>=2.6',
'colorama>=0.2.4',
'dependency1>=0.1,
'dependency2>=0.0.1],
classifiers=[
'Environment :: Console',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7'
],
cmdclass={'install': CustomInstallCommand},
)
我可以使用它sys.platfrom
来检测架构,但是如何让我CustomInstallCommand
知道设置选项?
更新:
我self.distribution.install_requires
在查看run
方法内部时发现了这一点self
。现在我只需要弄清楚如何安装依赖项。因为似乎只是调用install.run(self)
不会安装 colorama 和其他依赖项。