Thanks for the idea
The following appears to work as long as it is the only thing in xmldiff.
[assembly: PythonModule("maplookup", typeof(xmldiff.maplookup))]
namespace xmldiff {
public static class maplookup {
...
}
however, if it try to mix it with other parts of the xmldiff package which
are pure python, it is not visible anymore.
for now the workaround is to create maplookup.py inside the xmldiff package
and load things indirectly
[assembly: PythonModule("_maplookup", typeof(xmldiff.maplookup))]
namespace xmldiff {
internal static class maplookup {
...
}
import sys
if sys.platform=="cli":
import os
import clr
clr.AddReferenceToFileAndPath(os.path.join(os.path.dirname(__file__),r'maplookup.dll'))
from _maplookup import *
On Fri, Jan 11, 2013 at 9:07 PM, Michael van der Kolff <
[email protected]> wrote:
> Why not just add xmldiff to maplookup's namespace? i.e. instead of
> namespace maplookup {
> public static class maplookup {
> public const string __doc__ = "test string";
> ...
> }
> Write:
> namespace xmldiff.maplookup {
> public static class maplookup {
> public const string __doc__ = "test string";
> ...
> }
>
> On Sat, Jan 12, 2013 at 4:00 AM, Pawel Jasinski
> <[email protected]> wrote:
> >
> >
> > ---------- Forwarded message ----------
> > From: Pawel Jasinski <[email protected]>
> > Date: Fri, Jan 11, 2013 at 5:58 PM
> > Subject: Re: [Ironpython-users] importing .net assembly as module in a
> > package
> > To: Jeff Hardy <[email protected]>
> >
> >
> >
> >
> >
> > On Fri, Jan 11, 2013 at 5:02 PM, Jeff Hardy <[email protected]> wrote:
> >>
> >> On Fri, Jan 11, 2013 at 6:37 AM, Pawel Jasinski
> >> <[email protected]> wrote:
> >> >
> >> > hi,
> >> >
> >> >
> >> > I am looking for a way to use module created as .net assembly as part
> of
> >> > the package
> >> >
> >> > So instead of having:
> >> >
> >> > import clr
> >> > clr.AddReferenceToFileAndPath(".\maplookup.dll")
> >> > import maplookup
> >> >
> >> > I prefer:
> >> >
> >> > import clr
> >> > clr.AddReferenceToFileAndPath(".\maplookup.dll")
> >> > import xmldiff.maplookup
> >> >
> >> > Is there any way to accomplish it?
> >>
> >> What is xmldiff? Is it an existing Python package?
> >
> >
> > xmldiff is located in site-packages
> >
> >>
> >>
> >> Also, is maplookup just a .NET class, or is it actually a PythonModule
> >> class?
> >
> >
> >
> > this is PythonModule class but compiled separately from IronPython
> >
> > [assembly: PythonModule("maplookup", typeof(maplookup.maplookup))]
> >
> > namespace maplookup {
> > public static class maplookup {
> > public const string __doc__ = "test string";
> > ...
> > }
> >
> > I owe the explanation here. xmldiff is a python package with one module
> > implemented as C extension
> > What I am trying to do, is to port this C extension as .NET class.
> > This would be analog to porting build-in C modules into .NET but outside
> of
> > the IronPython.
> >
> >>
> >>
> >> - Jeff
> >
> >
> >
> >
> > _______________________________________________
> > Ironpython-users mailing list
> > [email protected]
> > http://mail.python.org/mailman/listinfo/ironpython-users
> >
>
_______________________________________________
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users