考虑以下setup.py
文件(例如,此处生成唯一的其他源文件(false.c
)):
#!/usr/bin/env python
from setuptools import setup
from distutils.ccompiler import new_compiler
from subprocess import check_call
with open('false.c', 'w') as F:
F.write('int main(int argc, char **argv){ return 1; }\n')
compiler = new_compiler().compiler
check_call(compiler + ['-O3', 'false.c', '-o', 'false'])
setup(
name='false',
scripts=['false'],
)
。当使用python-2 *(在使用此pip install -e .
文件的目录中使用setup.py
时)将已编译的false
可执行文件安装到$VIRTUAL_ENV/bin
时,此文件可正常工作。但是,如果我使用python-3 *的虚拟环境,则会因以下错误而失败:(full error log)
<...>
File "/home/zyx/.virtenvs/python3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/develop.py", line 27, in run
self.install_for_development()
File "/home/zyx/.virtenvs/python3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/develop.py", line 105, in install_for_development
self.process_distribution(None, self.dist, not self.no_deps)
File "/home/zyx/.virtenvs/python3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/easy_install.py", line 659, in process_distribution
self.install_egg_scripts(dist)
File "/home/zyx/.virtenvs/python3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/develop.py", line 138, in install_egg_scripts
script_text = f.read()
File "/home/zyx/.virtenvs/python3.2/lib64/python3.2/codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 208: invalid start byte
<...>