Python at compile - possible to add to PYTHONPATH

R

rh0dium

Hi all,

Can anyone help me out. I would like to have python automatically look
in a path for modules similar to editing the PYTHONPATH but do it at
compile time so every user doesn't have to do this..

Soo...

I want to add /foo/bar to the PYTHONPATH build so I don't have to add
it later on. Is there a way to do this?

../configure ??

../configure --help doesn't help..


Thanks
 
S

Serge Orlov

Hi all,

Can anyone help me out. I would like to have python automatically look
in a path for modules similar to editing the PYTHONPATH but do it at
compile time so every user doesn't have to do this..

Soo...

I want to add /foo/bar to the PYTHONPATH build so I don't have to add
it later on. Is there a way to do this?

You don't need to recompile python. Just change sys.path before all
import statements.
 
A

Avell Diroll

rh0dium wrote:
(snip)
I want to add /foo/bar to the PYTHONPATH build so I don't have to add
it later on. Is there a way to do this?
(snip)

If i understand correctly, you want to add a directory to your
PYTHONPATH for a specific script without modifying the system PYTHONPATH
global variable ...

To import the Gazonk() class defined in /foo/bar/baz.py without adding
/foo/bar to PYTHONPATH you can try this:

###

import sys
sys.path.append('/foo/bar')

import baz
quux = baz.Gazonk()

###

hope it helped ...
 
R

rh0dium

Hi all,

Thanks for the response. Yeah that's what I'm currently doing but I
thought that it would be cleaner for me to append my own location at
compile time. I'm surprised that this doesn't exist..

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top