Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override default installation directory for Python bdist Windows installer

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?

like image 667
Bill Craun Avatar asked Sep 08 '11 20:09

Bill Craun


3 Answers

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

like image 81
MaxSin Avatar answered Nov 06 '22 20:11

MaxSin


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
like image 1
jterrace Avatar answered Nov 06 '22 19:11

jterrace


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.

like image 1
pianist1119 Avatar answered Nov 06 '22 20:11

pianist1119