0

I'd like to to install Django into a custom location, I've read the distutils documentation and it suggests that I should be able to do something like the following to install under my home directory (when run from an unpacked django tarball).

> python setup.py install --home=~/code/packages/install --install-purelib=modules --install-platlib=modules --install-scripts=scripts --install-data=data 

However, every time I run this, it doesn't seem to concatenate the home path with the separate element paths, and so I simply end up with

modules/
scripts/
data/ 

In the unpacked tar ball directory. I.e. it seems to be treating modules, scripts etc as simply relative paths to local directory and not relative to the --home specified.

I've tried setting the root with --prefix, and using a setup.cfg and nothing seems to work. --prefix and and --home on their own with no other overrides work, but when used together with --install-xxx overrides it doesn't.

I'm either probably doing something stupid, or the documentation is wrong, or their is a bug. Any help much obliged.

2
  • Have you tried looking at guides to install on shared hosting? Seems like a similar issue. And are you doing this as root? Oct 29, 2009 at 13:18
  • I'm running on Ubuntu so root is dead. I'm noting doing the commands using sudo though. The commands do actually work they are just going to the wrong location! I've tried looking at guides, and I'm aware that I can set up a "user-specific" site-packages. But thats not quite what I want.
    – andre_b
    Oct 29, 2009 at 14:45

4 Answers 4

2

I would strongly suggest that you look at Virtualenv and Pip for creating basically silos of python packages.

The Pinax project uses this exclusively now for bundling requirements together for other people to use, and it's becoming more and more of a defacto standard in the reusable apps space.

1
  • thanks for the links, they seem to be close to what I'm trying to do.
    – andre_b
    Oct 29, 2009 at 17:19
1

Ok, so I've been looking at the distutils source code to see what is going on - distutils.command.install does all of the pathname manipulation.

It turns out that the documentation is actually incorrect. Whenever an --install-xxxx style option is provided it completely overrides any value that might be derived from --home or --prefix - the code not does do any straightforward concatenation of paths.

However, what it does do is variable substitution of a set of special variables. The one of interest to me specifically is $base. Using it on the command line you can define the overrides, and distutils will replace all occurrences with what was specified for --home etc. But note you must quote your filenames so BASH does not try expand it as a environment variable.

So the command line that I had initially, becomes:

python setup.py install --home=/home/andre/code/packages/install --install-purelib='$base/modules' \
  --install-platlib='$base/modules' --install-scripts='$base/scripts' --install-data='$base/data'

Hope someone other than me finds that useful!

1
  • Thanks - useful... worth adding a comment to the Django book. Oct 29, 2009 at 19:02
0

As a quick check, I'd suggest replacing

~/code/packages/install

with

/full_path_to_your_user/code/packages/install

1
  • thanks for the suggestion, I did try this before and didn't work.
    – andre_b
    Oct 29, 2009 at 14:31
0

If you just want it in your home directory, there's no need to install it at all. Just make sure that the container directory is on your pythonpath somewhere, and move the scripts in django/bin into somewhere on your main PATH (or add that dir to your path).

1
  • Thanks - I'm aware of that, but it is part of a pattern that I want to re-use for other Python modules, so I want to try and control the process using standard Python infrastructure if I can.
    – andre_b
    Oct 29, 2009 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.