import problem using setuptools (resend without html)
I am using setuptools to creat a windows installer (using python setup.py bdist --format=wininst). setuptools creates a 'entry point', so it generates a .exe in the Scripts directory (this exe calls start.py) /base/ start.py b.py /lib/ __init__.py c.py start.py imports b.py (which has a global that is initialised) then start.py imports c.py c.py imports start.py (as far as I know this is not a circular import, because I am using only 'import xx', not 'from xx import ..') when running start.py directly (as 'python start.py') everything goes OK. My problem is when I run the .exe from the entry point in the Scripts directory. when start.py is imported from c.py and start.py on its turn imports b.py, b.py is completly initialised again. This behavious does not happen when start.py is called directly. what am I doing wrong? I also noticed that, when creating and installing a windwos instaler, the easy-install.pth does not get an entry for my application. Is this intended? best regards, Henk-Jan
At 01:31 PM 5/15/2007 +0200, henk-jan ebbers wrote:
I am using setuptools to creat a windows installer (using python setup.py bdist --format=wininst). setuptools creates a 'entry point', so it generates a .exe in the Scripts directory (this exe calls start.py)
/base/ start.py b.py /lib/ __init__.py c.py
start.py imports b.py (which has a global that is initialised) then start.py imports c.py c.py imports start.py (as far as I know this is not a circular import, because I am using only 'import xx', not 'from xx import ..')
when running start.py directly (as 'python start.py') everything goes OK.
Are these the *actual* names of your files and directories? Please repost using actual real real names and paths, if not. If these *are* the actual names of the files and directories, the problem is that you are using an out-of-date version of setuptools that doesn't put "-script" in the filenames of scripts to be run using an .exe. That, and there is probably also something terribly wrong with your setup.py. However, if the above are *not* the real names of the files and directories involved, please repost and provide them, because it might be something else altogether.
I also noticed that, when creating and installing a windwos instaler, the easy-install.pth does not get an entry for my application. Is this intended?
Yes. When you create "bdist_wininst", "bdist_msi", or "bdist_rpm" (or indeed most any "bdist" except bdist_egg), you should get a package layout identical to that produced by normal distutils, but with the addition of an .egg-info directory alongside the package. This layout doesn't require any .pth files.
At 05:37 PM 5/15/2007 +0200, henk-jan ebbers wrote:
Thanks for your response. Yes, these are not the real names. My situation is (using real names, but using only relevant files):
/bots/ engine.py transform.py botslib.py __init__.py /usersys/ __init__.py /mappings/ __init__.py 02ordersedi2aperak.py
so: engine.py is the start point. engine.py imports botslib.py (initialises global), imports transform.py and starts function from transform.py transform imports botslib.py, imports usersys.mappings.02ordersedi2aperak.py usersys.mappings.02ordersedi2aperak.py imports botslib.py->in this import it is initialised again.
Ah, then your code has a bug. It should be importing bots.botslib, instead (e.g. "from bots import botslib" instead of "import botslib"). It appears that you also either have the bots/ directory somehow appearing on sys.path (where it *should not be*!) OR you have another copy of botslib.py on sys.path.
At 10:27 PM 5/15/2007 +0200, henk-jan ebbers wrote:
You are right on both points. thank you. this works. I am a bit surprised that I should use 'import transform.py' in the /bots/ directory,
You should not. In Python 2.6 and 3.0 it will not work any more. Use "import bots.transform" or "from bots import transform" instead.
and 'import bots.transform' in the /mapping/ directory.
Under Python 2.5, you also have the option of doing 'from .. import transform' to import the transform module from the package above you, or 'from . import transform' to import it from the package you are in. See PEP 328 at http://www.python.org/dev/peps/pep-0328/ for more info.
participants (2)
-
henk-jan ebbers
-
Phillip J. Eby