473,762 Members | 7,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python at compile - possible to add to PYTHONPATH

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

Jun 21 '06 #1
3 1444
On 21 Jun 2006 15:54:56 -0700, rh0dium <st**********@g mail.com> wrote:
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.
Jun 21 '06 #2
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 ...
Jun 21 '06 #3
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.

Avell Diroll wrote:
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 ...


Jun 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9989
by: jg.campbell.ng | last post by:
I'm beginning learning Python and OpenGL in Python. Python fine. But difficulties with OpenGL; presumably with the installation of OpenGL. OS = Linux FC5. Python program gl_test.py: from OpenGL.GLUT import *
7
2407
by: wardm | last post by:
I have created a Dict object in a C++ App that calls (embedded) Python functions. The Dict is to be used to pass variable data between the C++ App and the python functions. However I cannot get the Python functions to 'see' the Dict created in the C++ App. The C++ app creates the Dict using the following functions:
11
1440
by: Michael Spencer | last post by:
Announcing: compiler2 --------------------- For all you bytecode enthusiasts: 'compiler2' is an alternative to the standard library 'compiler' package, with several advantages. Improved pure-python compiler - Produces identical bytecode* to the built-in compile function for all /Lib and Lib/test modules, including 'peephole' optimizations
69
3222
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of this pep would be to make it impossible to use the name 'print' in a backward compatible manner. Indeed, if a program is to compile in both Python 2.x and Python 3.x, the print function (or the print statement with parentheses) can not use the...
0
1053
by: mathieu | last post by:
Hi there, I am currently involved in managing a large python/c++ project (using swig to automagically wrap c++ code to python). So far my current experience was that python was a second class citizen and extremely little python code was written and everything seemed to work. Now this is the contrary, large portion of code are written python with a few expection of c++ code for core algorithms. So as you might
7
1631
by: greg | last post by:
Thomas Philips wrote: Have a look in /Library/Frameworks/Python.framework/Versions/2.5 You can't -- this feature only exists in the Search window, which is a different kind of window from the normal Finder
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.