我尝试在安装过程中使用自定义安装从 setup.py 调用 Python 脚本:
class CustomInstall(install):
def run(self):
install.run(self)
...
p = subprocess.Popen(
[sys.executable, 'demo_package/deploy_database.py'],
shell=True,
stdout=subprocess.PIPE,
cwd=os.path.join(self.install_lib, 'demo_package'))
out, err = p.communicate()
setup(..., cmdclass=dict(install=CustomInstall))
在 Ubuntu 机器上部署包时,该过程不会执行 deploy_database.py,而是显示任何内容。当我使用 Ctrl+C 手动停止它时,输出似乎表明它没有实际运行 deploy_database.py,而是简单地启动 Python:
^CDownloading/unpacking PypiPackagesMonitoring
Downloading demo-1.0.64.zip
Running setup.py egg_info for package demo
Installing collected packages: demo
Running setup.py install for demo
Python 3.3.2+ (default, Oct 9 2013, 14:50:09)
[GCC 4.8.1 on linux
Type "help", "copyright", "credits" or "license" for more information.
Cleaning up...
Operation cancelled by the user
Storing complete log in /home/.../.pip/pip.log
我调用 Python 脚本的方式有什么问题?我应该怎么做呢?