Hello,
I have a problem where I need to set up two separate Python projects
that each live under the same package. Once they are distributed,
they will live under the same filesystem path, but during development,
they are separated.
For example:
proj1/lib/pkg/foo/mod1.py
proj2/lib/pkg/bar/mod2.py
Furthermore, proj1 is dependent on proj2, so I want to be able to say
things like this, from within proj1:
import pkg.foo.mod1
import pkg.bar.mod2
Of course this doesn't work, even with a PYTHONPATH configured to see
both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
will be hidden from view.
Any suggestions?
Thanks! 3 1638 rp*******@sneakemail.com schrieb:
Hello,
I have a problem where I need to set up two separate Python projects
that each live under the same package. Once they are distributed,
they will live under the same filesystem path, but during development,
they are separated.
For example:
proj1/lib/pkg/foo/mod1.py
proj2/lib/pkg/bar/mod2.py
Furthermore, proj1 is dependent on proj2, so I want to be able to say
things like this, from within proj1:
import pkg.foo.mod1
import pkg.bar.mod2
Of course this doesn't work, even with a PYTHONPATH configured to see
both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
will be hidden from view.
Any suggestions?
Thanks!
Hi,
my only suggestion would be to overthink your project organization.
You can surely solve that problem with symlinks, but if they depend
on another, perhaps the structure is not optimal.
If you use python 2.5 you can try absolute imports (which I personally
find not so well):
from __future__ import absolute_import
See here: http://python.mirrors-r-us.net/dev/peps/pep-0328/
Cheers,
Stefan rp*******@sneakemail.com schrieb:
Hello,
I have a problem where I need to set up two separate Python projects
that each live under the same package. Once they are distributed,
they will live under the same filesystem path, but during development,
they are separated.
For example:
proj1/lib/pkg/foo/mod1.py
proj2/lib/pkg/bar/mod2.py
Furthermore, proj1 is dependent on proj2, so I want to be able to say
things like this, from within proj1:
import pkg.foo.mod1
import pkg.bar.mod2
Of course this doesn't work, even with a PYTHONPATH configured to see
both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
will be hidden from view.
Any suggestions?
Thanks!
Hi,
my only suggestion would be to overthink your project organization.
You can surely solve that problem with symlinks, but if they depend
on another, perhaps the structure is not optimal.
If you use python 2.5 you can try absolute imports (which I personally
find not so well):
from __future__ import absolute_import
See here: http://python.mirrors-r-us.net/dev/peps/pep-0328/
Cheers,
Stefan
<rp*******@sneakemail.comwrote:
Hello,
I have a problem where I need to set up two separate Python projects
that each live under the same package. Once they are distributed,
they will live under the same filesystem path, but during development,
they are separated.
For example:
proj1/lib/pkg/foo/mod1.py
proj2/lib/pkg/bar/mod2.py
Furthermore, proj1 is dependent on proj2, so I want to be able to say
things like this, from within proj1:
import pkg.foo.mod1
import pkg.bar.mod2
Of course this doesn't work, even with a PYTHONPATH configured to see
both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
will be hidden from view.
proj1/lib/pkg/__init__.py (and its counterpart under proj2) might set
their __path__ as to "merge" the two separate directories when seen as
Python packages. A rather contorted "solution" (compared to the simple
and obvious one of NOT "separating during development" parts that appear
to be so closely entwined) but I think it would work.
Alex This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul Rubin |
last post by:
That's what the Python style guides advise. They don't seem to like
def frob(x):
import re
if re.search('sdfxyz', x): ...
instead preferring that you pollute your module's global namespace...
|
by: Rob B |
last post by:
Hello,
I am just starting to learn Python and was writing a simple script on
my machine (Mac OS X 10.3.4), but I can't seem to import the random
module:
#!/usr/bin/env python
import random
|
by: Charles Fineman |
last post by:
I've been asked to look over an integration toolkit that has a bunch
of schemas to specify message format. There are a couple of strange
things I noticed right off the bat and I wanted to get...
|
by: Shapper |
last post by:
Hello,
In the main root of my web site together with my aspx and aspx.vb files
I have the file global.vb.
This file has a class with all the functions which are used in many
aspx.vb files and...
|
by: Connelly Barnes |
last post by:
Hi,
I wrote the 'autoimp' module , which allows you to import lazy modules:
from autoimp import * (Import lazy wrapper objects around all modules; "lazy
modules" will turn into normal...
| |
by: jobo |
last post by:
I am importing bmp images into a jet database
The embedded picture appears as a chunky square thumbnail with the filename in large font underneath. The size of the thumbnail and font seems to...
|
by: lotus18 |
last post by:
Hello all
I have these records on my Day Table for my complete database table please click here
1. M
2. T
3. W
4. TH
5. F
6. S
|
by: iu2 |
last post by:
Hi all
I've got three files:
file a1.py:
========
the_number = None
file a2.py:
========
|
by: Stef Mientki |
last post by:
hello,
The import statement "import sqlite3" gives the error given below.
In simple programs, the import statement (sometimes) succeed,
and I can indeed access the database.
So I guess there is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |