Override default installation directory for Python bdist Windows installer
Is开发者_如何学JAVA 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?
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
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
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.
精彩评论