Mark Galeck
Mark Galeck

Reputation: 6385

how to tell Python disutils.core setup function to install under a different root?

I have this Python script:

#!/usr/bin/env python
from distutils.core import setup, Extension
MOD = 'sysinfo'
setup(
    name=MOD, 
    ext_modules=[
        Extension(
            MOD, 
            sources=['python_module.c']
        )
    ]
)

When I run it, I get:

$./setup.py install
running install
running build
running build_ext
running install_lib
copying build/lib.linux-x86_64-2.7/sysinfo.so -> /usr/lib64/python2.7/site-packages
error: /usr/lib64/python2.7/site-packages/sysinfo.so: Permission denied

Naturally - I don't want and have permissions to, write to /usr directory. I want instead, to install to a different directory, under which I have a linux directory structure. Say, I want to install to /home/mark/usr/lib64/python2.7/site-packages.

I studied distutils.core documentation, and used --help but could not find any option to install under a different root.

How to do it?

Upvotes: 3

Views: 416

Answers (1)

phd
phd

Reputation: 94473

./setup.py install installs the package into global site-packages/ in your python installation making it available for all users of the system.

./setup.py install --user installs the package into local site-packages/ in your home (~/.local/lib/pythonX.Y/site-packages/) making it available only for you.

./setup.py install --root ~/custom/directory/

installs into ~/custom/directory/usr/lib64/pythonX.Y/site-packages/.

Upvotes: 2

Related Questions