我想使用cx_freeze来冻结一个Python应用程序,但我还想保留使用pip从源代码安装软件包的可能性。当我尝试以开发模式安装软件包(pip install -e .
)时,我会遇到以下错误。看起来cx_freeze在后台使用的是distutils
而不是setuptools
。有没有可能强制cx_freeze也使用setuptools?
D:\Python\FPF4Creator>pip install -e .
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Obtaining file:///D:/Python/FPF4Creator
Requirement already satisfied (use --upgrade to upgrade): jinja2 in c:\winpython\python-2.7.6\lib\site-packages (from fpf4creator==0.0.2)
Requirement already satisfied (use --upgrade to upgrade): six in c:\winpython\python-2.7.6\lib\site-packages (from fpf4creator==0.0.2)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in c:\winpython\python-2.7.6\lib\site-packages (from jinja2->fpf4creator==0.0.2)
Installing collected packages: fpf4creator
Running setup.py develop for fpf4creator
Complete output from command C:\WinPython\python-2.7.6\python.exe -c "import setuptools, tokenize; __file__='D:\\Python\\FPF4Creator\\setup.py'; e
xec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps:
running develop
Checking .pth file support in C:\Program Files (x86)\fpf4creator\Lib\site-packages\
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Error 5] Zugriff verweigert: 'C:\\Program Files (x86)\\fpf4creator'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
C:\Program Files (x86)\fpf4creator\Lib\site-packages\
This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).
----------------------------------------
Command "C:\WinPython\python-2.7.6\python.exe -c "import setuptools, tokenize; __file__='D:\\Python\\FPF4Creator\\setup.py'; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps" failed with error code 1 in D:\Python\FPF4Creator
setup.py
的内容如下:
import os
from setuptools import find_packages
from cx_Freeze import setup, Executable
from fpf4creator import __version__
options = {
'build_exe': {
'include_files': 'fpf4creator/data',
}
}
executables = [
Executable('fpf4creator/gui.py', targetName='FPF4Creator.exe',
icon='fpf4creator/data/gui/icon.ico', base="Win32GUI")
]
fpf4_data = []
for root, dirnames, filenames in os.walk('fpf4creator/data'):
for fname in filenames:
fpf4_data.append(os.path.join(root, fname).replace('fpf4creator/', ''))
setup(
name='fpf4creator',
version=__version__,
author='Author',
author_email='mail@author.com',
packages=find_packages(),
package_data={
'fpf4creator': fpf4_data
},
install_requires=['jinja2', 'six'],
entry_points={
'gui_scripts': [
'fpf4Creator = fpf4creator.gui:main',
],
},
options=options,
executables=executables
)
cx_setup.py
文件,以及一个用于 Python 打包工具的普通setup.py
文件。 - Thomas K