LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-08-2016, 01:00 PM   #1
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Problem trying to install python from sources into a local directory


I need to install a Python module into a project directory and not into a systemwide "site-packages" directory. (Only a select few have root access and we will never get it.)

In some cases I've been able to add a section to "setup.cfg" like
Code:
[easy_install]
install_dir = /home/project/python-modules
and making sure that the PYTHONPATH includes "/home/project/python-modules". Then, running
Code:
python setup.py install
would neatly place the module into the target directory.

Now I've got the sources for a module that does not include a "setup.cfg" file. I've tried creating one that includes the "install_dir" directive I showed above. Unfortunately, the build command returns a message that seems to indicate that the build process is not even looking at my "setup.cfg" and proceeds to try and install the module in the systemwide module location.

Question:

Ideas on how to override this default setting?

TIA...

--
Rick
 
Old 03-08-2016, 01:34 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
I don't know why you're overcomplicating it like this. If you want to put it in a user directory, then it's just:

Code:
python setup.py install --user
or

Code:
pip install <whatever> --user
To install into an arbitrary prefix (for packaging), it's:

Code:
python setup.py install --root=<wherever
This will give you the rest of the options:

Code:
python setup.py --help install
You will never need anything other than a command-line flag after "install".

Last edited by dugan; 03-08-2016 at 01:45 PM.
 
Old 03-08-2016, 02:02 PM   #3
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by dugan View Post
I don't know why you're overcomplicating it like this. If you want to put it in a user directory, then it's just:
Maybe because I've never NOT had access to root when installing packages for users before. :^/

What I've found to be working is:
Code:
export PYTHONPATH=${PYTHONPATH}:/home/myhome/lib/python
mkdir /home/myhome/lib/python
cd <module1-src-root>
install setup.py install --home=/home/myhome
cd <module2-src-root>
install setup.py install --home=/home/myhome
Then a simple Python script
Code:
#!/usr/bin/python
import module1
import module2
exit
executes without any errors. Now I'm writing a script to exercise some of the functions available in these packages to make sure things are really working. My testing may point out some subtle differences between the "--user", "--home", etc. switches.

I've had to install these under my home directory as the sysadmins have yet to grant my account the group membership needed to do the installations into the project directory. (Asking to have my account "B" look just like existing account "A" was somehow misinterpreted as "give account B a small subset of account A's capabilities". Gotta love it.) I'm hoping I don't have to reinvent these steps once I get that group membership. My current plan it to merely change "myhome" to the project library subdirectory.

Thanks...

--
Rick
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Yum local install - package and all dependencies in local directory lppatmore Linux - Newbie 6 02-21-2015 02:53 AM
[SOLVED] python, pip --user into a different directory than .local a4z Programming 1 06-16-2013 10:39 AM
How do I install to a local directory? How with bootstrap? golmschenk Linux - Newbie 2 11-03-2010 07:34 PM
how to install packages kept at local directory karthikg356 Linux - General 1 12-26-2007 07:42 AM
Cant install unsatisfied /usr/local/bin/python/ Fredstar Linux - Newbie 1 02-02-2005 01:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration