是否可以在安装程序生成期间(或在实际安装期间)指定Python模块的自定义路径?举个例子,假设我有5个模块,我为它们生成了一个安装程序,使用:
c:\>python setup.py bdist一切都被正确打包,但当我安装时,我被迫安装到站点包中。我需要能够指定我的自定义目录(或安装程序的选择)。至少,我需要能够覆盖默认路径,以便我的自定义路径显示为默认路径。
使用构建的发行版可以做到这一点吗?
发布于 2012-11-02 16:45:39
您应该编写setup.cfg,您可以在其中指定安装选项(参见python setup.py安装--帮助输出),然后运行python setup.py bdist。在创建二进制发行版时,python将在"build“子目录下使用此选项执行哑巴安装,并从这个哑巴安装创建安装程序。例如,如果要创建bdist,它会将库安装到/some/lib/setup.cfg,并将脚本安装到/some/bin/path,请创建以下bdist:
[install]
prefix=/
install_lib=/some/lib/path
install_scripts=/some/bin/path然后运行python setup.py bdist
发布于 2011-09-09 06:32:40
从运行python setup.py --help install
Options for 'install' command:
--prefix installation prefix
--exec-prefix (Unix only) prefix for platform-
specific files
--home (Unix only) home directory to install
under
--user install in user site-package
'/home/jterrace/.local/lib/python2.7/si
te-packages'
--install-base base installation directory (instead of
--prefix or --home)
--install-platbase base installation directory for
platform-specific files (instead of --
exec-prefix or --home)
--root install everything relative to this
alternate root directory发布于 2014-02-10 08:22:20
我确实认为MaxSin的回答有点正确。但是要使用他对命令的回答:"python setup.py bdist_wininst“,你必须这样做:
[bdist_wininst]
prefix=/
install_lib=/some/lib/path
install_scripts=/some/bin/path看起来语法here是:
[command]
option=value
...编辑:
这看起来不起作用:(不确定是否有其他可能的解决方案。
https://stackoverflow.com/questions/7354096
复制相似问题