[IronPython] Compilation difficulties

Dave Fugate dfugate at microsoft.com
Mon Oct 2 09:50:12 PDT 2006


I'm glad to see people are finding this sample useful!

My first suggestion is to verify you have an __init__.py in Cheesemonger. I'm pretty sure the answer is yes but just to be certain...

Second, using a command such as:
        E:\Temp>ipy F:\ipsd\IronPython\Samples\Pyc\pyc.py Cheesemonger\Counter.py Cheesemonger\Shopkeeper.py Cheesemonger\__init__.py /main:main.py /out:CM.dll
should do what I *think* you're trying to do. This creates an (executable) CM.dll based on main.py which pretty much follows your series of files except that my main.py invokes a function from Cheesemonger.Counter. When I run CM.dll, the output verifies it is indeed using modules from Cheesemonger.*

Last but definitely not least, please stay away from using tools like ildasm, reflector, etc to examine the contents of IronPython created DLLs. What you'll find there is almost certainly not what you'd expect as mentioned on the Codeplex Samples page.




-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of William Reade
Sent: Friday, September 29, 2006 5:27 AM
To: Discussion of IronPython
Subject: [IronPython] Compilation difficulties

Hi all

I've been playing with the (excellent) Pyc sample, and I've got stuck. I
have a series of files a bit like the following:

project/
| main.py
+ Cheesemonger/
  | Shopkeeper.py
  | Counter.py

...in which main.py contains statements like:

from Cheesemonger.Counter import Counter

...and Counter.py also contains statements like:

from Cheesemonger.Shopkeeper import Shopkeeper

---

This is all very well, but I can't work out how to compile a
Cheesemonger.dll in which the above imports still function -- when I
inspect it with ildasm, the dll contains "Counter" and "Shopkeeper"
rather than "Cheesemonger.Counter" and "Cheesemonger.Shopkeeper".

I can "fix" the issue by undisambiguating the imports:

clr.AddReference("Cheesemonger")
from Counter import Counter

...and:

from Shopkeeper import Shopkeeper

...but we've been burned by ambiguous imports before and would prefer
not to reintroduce them (life can get confusing when every directory
contains its own "UnitTests" directory ;)).

Is there any way of compiling a directory (and subdirectories) into a
single dll, such that no import statements need to be changed? A quick
look at the IP source left me none the wiser, I'm afraid.

Cheers
William

_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list