2011-09-08 59 views
8

是否可以在安装程序生成期间(或在实际安装期间)指定Python模块的自定义路径?举例来说,假设我有5个模块,我生成使用安装程序:覆盖Python bdist的默认安装目录Windows安装程序

c:\>python setup.py bdist 

一切都被正确地打包,但是当我安装,我不得不安装到站点包。我需要能够指定我的(或安装程序的选择)的自定义目录。至少,我需要能够覆盖默认,所以我的自定义路径显示为默认值。

这是可能的使用构建的分布?

回答

1

从运行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 
+1

谢谢。由bdist生成的安装程序是一个可执行文件。我没有从命令行运行setup.py。 –

+0

吧?你的意思是bdist或bdist_wininst? – jterrace

+0

是的,bdist_wininst。 –

10

你应该写setup.cfg在那里你可以指定安装选项(见蟒蛇的setup.py安装--help输出),然后运行python setup.py bdist。当创建二进制发行版时,python将使用此选项在“build”子目录下执行哑安装,并从此哑安装创建安装程序。例如,如果你想创建bdist它安装库/一些/ lib目录/路径和脚本/一些/斌/路径创建以下setup.cfg:

[install] 
prefix=/ 
install_lib=/some/lib/path 
install_scripts=/some/bin/path 

然后运行python setup.py bdist

1

我确实相信MaxSin的回答有些错误。但用他的答案命令:“蟒蛇setup.py bdist_wininst”你会做这样的:

[bdist_wininst] 
prefix=/ 
install_lib=/some/lib/path 
install_scripts=/some/bin/path 

看到,因为语法here是:

[command] 
option=value 
... 

编辑:

看起来像这不工作:(不知道可能的其他解决方案。

+0

我要试试这个,我会反馈它是否适合我。 – pianist1119