473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

finding the same package in multiple places


At work we have a package structure for our homegrown code. Developers each
have their own sandboxes where they work on the stuff they are responsible
for (mixtures of C++ libraries, SWIG wrappers and pure Python packages).
We're running into a problem where we have two versions of the main package,
one in the developer's sandbox that contains just the developer's bits and
one in the central location which contains all the installed stuff. We're
running into problems because the search for a module within a package stops
when the first instance of the top level package is found. I don't know of
a good way to work around this problem. I've cooked up a scheme involving
symlinks, but that's a very bad hack. I'd like something cleaner.

Let me make it more concrete. We have a central package, call it "central".
Inside that package are three subpackages, "a", "b" and "c". Imports thus
look like

import central.a
from central import b
from central.c import foo

Now suppose I need to work on subpackage c. If I create a local package
called "central" and install my working copy of "c" there, athen adjust
PYTHONPATH accordingly, I can't import "central.a" or "central.b" any longer
because the search for them ends when the developer's local version of
"central" is encountered. For various reasons our sandbox directory doesn't
have the same structure as the installation directory, so I actually have to
"install" stuff in my local sandbox to get the proper directory structure.
Even if that wasn't the case, most developers don't need or want to build
all the C++ and SWIG stuff anyway.

Any ideas would be greatly appreciated (import hooks that cause the search
for a package's submodules and subpackages to continue beyond the first
occurrence of the package would be especially welcome).

Thanks,

Skip

Jul 18 '05 #1
2 1664
Skip Montanaro wrote:
Let me make it more concrete. We have a central package, call it
"central".
Inside that package are three subpackages, "a", "b" and "c". Imports thus
look like

import central.a
from central import b
from central.c import foo

Now suppose I need to work on subpackage c. If I create a local package
called "central" and install my working copy of "c" there, athen adjust
PYTHONPATH accordingly, I can't import "central.a" or "central.b" any
longer


I haven't used it myself, but if I read the documentation correctly,
http://docs.python.org/lib/module-pkgutil.html
may do what you need.

Peter

Jul 18 '05 #2

Peter> I haven't used it myself, but if I read the documentation
Peter> correctly, http://docs.python.org/lib/module-pkgutil.html may do
Peter> what you need.

Thanks Peter. This does exactly what I need.

Skip

Jul 18 '05 #3

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

Similar topics

3
by: Noam Dekers | last post by:
Hi all, I would like to find a word stored in a text file. Structure: I have one file named keyWords.txt that stores some key words I'm interested in finding. In addition I also have a file...
3
by: Brent Bortnick | last post by:
Does anyone know how to find out the number of decimal places a number has. I need this info so that i can round to 3 decimal places if the number has 3 decimal places or to 2 decimal places if...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
3
by: MilanB | last post by:
Hello I'm asking is it possible that two or more Web User Control have same file (.ascx) name within same project? Namespace is different. I got error message: "CS1595: 'ASP.EditForm_ascx' is...
3
by: shorti | last post by:
running on AIX with DB2 v8.2.2 I ran across a problem with naming source files with similar names. For instance, if I have these three files: upd_startaccessingdb.sqc upd_startusingdb.sqc...
8
by: Joshua J. Kugler | last post by:
So, I have: ModTest __init__.py AModule.py BModule.py CModule.py All works fine. However, when I import ModTest, I would like it to discover and store the names of the modules beneath it,...
10
by: parag_paul | last post by:
HI all, Suppose I have a huge code base, And I have a very common header file. Now there are mulitple places where this header file is kept. This header file cannot be factored as it has...
1
by: joshetomlinson | last post by:
Hi all, I'm new to python, and am trying to determine if it's possible to do the following... I have a directory structure like this, with both 'dir1' and 'dir2' in my PYTHONPATH dir1/...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.