Override default installation directory for Python bdist Windows installer

馋奶兔 提交于 2019-12-21 03:57:18

问题


Is it possible to specify during the installer generation (or during the actual installation) a custom path for Python modules? By way of example, let's say I have 5 modules for which I generate an installer using:

c:\>python setup.py bdist

Everything gets packaged up correctly, but when I install, I am forced to install into site-packages. I need to be able to specify a custom directory of my (or the installer's choosing). At a minimum, I need to be able to override the default so my custom path appears as the default.

Is this possible using a built distribution?


回答1:


You should write setup.cfg where you can specify installation options(see python setup.py install --help output) and then run python setup.py bdist. When creating binary distro python will do the dumb installation under the "build" subdir with this options and create the installer from this dumb installation. For example, if you want to create bdist which installs libraries to /some/lib/path and scripts to /some/bin/path create the following setup.cfg:

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

And then run python setup.py bdist




回答2:


From running 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



回答3:


I do beleive that MaxSin's answer was somewhat correct. But to use his answer for the command: "python setup.py bdist_wininst" you would have to do it like this:

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

Seeing as the syntax here is:

[command]
option=value
...

edit:

It looks like this doesnt work :( not sure of a possible other solution.



来源:https://stackoverflow.com/questions/7354096/override-default-installation-directory-for-python-bdist-windows-installer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!