我有一个 setup.cfg 包含 Linux 安装选项,
[install]
prefix=/opt/foo
install-lib=/opt/foo
这对应于该项目在 Linux 下的默认目录布局。
现在同一个项目使用 py2exe 进行 Windows 安装。目前,我正在使用 .bat 文件在运行时将此 setup.cfg 移开,python setup.py py2exe
以免将 py2exe 与那些设置混淆,我认为这相当于使用默认参数的 distutils/py2exe。
我宁愿调用python setup.py py2exe
一些额外的参数来覆盖 setup.cfg 中指定的参数,但是使用--prefix= --install-lib=
给了我
[...]
*** copy data files ***
Traceback (most recent call last):
File "setup.py", line 158, in <module>
**platformOptions)
File "C:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 243, in run
self._run()
File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 312, in _run
self.create_binaries(py_files, extensions, dlls)
File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 560, in create_binaries
install_data.ensure_finalized()
File "C:\Python27\lib\distutils\cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "C:\Python27\lib\distutils\command\install_data.py", line 41, in finalize_options
('force', 'force'),
File "C:\Python27\lib\distutils\cmd.py", line 298, in set_undefined_options
src_cmd_obj.ensure_finalized()
File "C:\Python27\lib\distutils\cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "C:\Python27\lib\distutils\command\install.py", line 353, in finalize_options
'userbase', 'usersite')
File "C:\Python27\lib\distutils\command\install.py", line 504, in convert_paths
setattr(self, attr, convert_path(getattr(self, attr)))
File "C:\Python27\lib\distutils\util.py", line 199, in convert_path
raise ValueError, "path '%s' cannot be absolute" % pathname
ValueError: path '/opt/trelby' cannot be absolute
这与根本不尝试覆盖 setup.cfg 参数时的行为相同,因此似乎出了点问题。
如有必要,我也愿意在 setup.py 中设置distutils.core.setup()
'options
参数,但主要问题似乎是:设置为什么值,以实现默认的 py2exe 行为?
顺便说一句,代码位于https://github.com/oskusalerma/trelby