Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

IronPython: sys.path/import vs. AddReference in multiple projects

$
0
0

Hi folks,

I'm an experienced Pythoniast, but a newcomer to .NET/sharpdevelop.

I'm setting up a new solution which consists out of two projects: one part is the GUI, the other part is the core "BASE" library with source which is probably be used also by other projects/solutions.

Now I'm wondering which is the right/best way to access BASE-functionality (modules, classes, ...) from the GUI project. 

There is the usual Python-way: add the BASE path to the sys.path and then simple "from ... import ...". Works. But I guess that's not the right way to do, since this works (assumption) only in the dev environment and not in the final binary distribution.

I added the BASE project as a reference to the GUI project, and I found a BASE.dll in the bin-folder of the GUI project. So sharpdevelop creates obviously a .NET assembly from my BASE-sources and copies it to the GUI-binary folder.

I guess the right way would be to do something comparable to cls.AddReference("BASE"), but I didn't find a working version of that. The BASE.dll isn't found and I have no clue to find out the right folder to somethink like cls.AddReferenceByFile("BASE.dll"). In the doc of AddReference is written that it also scans sys.path, but for this I would need to find out the correct binary folder, and Application.executablePath just shows the path of the IronPython executable, not the run path of the GUI.

Hardcoding any paths would be... suboptimal :-)

I searched forums, IronPython doc and I also bought "IronPython in Action" - no success. 

Probably a simple solution but in the mysteries of .NET assemblies.

Any pointer would help :-)

Andrew


Viewing all articles
Browse latest Browse all 1764

Trending Articles