[IronPython] How to install 3rd part packages into IronPython ?

Ben Rousch brousch at gmail.com
Tue Apr 27 14:38:03 CEST 2010


First of all I'm new to IronPython, so I'm probably doing this
completely wrong. However it has worked for me so far.

I have been compiling any non-standard modules I need to a DLL named
after the module, and then I include and reference that DLL in my
IronPython project. I only have to compile the module/dll once, and it
is easy to keep everything together.

For instance I use want to use ArgParse. So I download the argparse
module source code (not easy_install), create a little script to
compile it to DLL, then put the generate argparse.dll in my project.

To compile the argeparse DLL, I run this script through ipy.exe:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import clr
clr.CompileModules("argparse.dll", "argparse.py")

A more complicated example is xlrd, which as multiple source files:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import clr
clr.CompileModules("xlrd.dll", "xlrd/biffh.py", "xlrd/compdoc.py",
    "xlrd/formatting.py", "xlrd/formula.py", "xlrd/__init__.py",
    "xlrd/licences.py", "xlrd/sheet.py", "xlrd/timemachine.py",
    "xlrd/xldate.py")

If this continues to work for me, I will create a more generalized
script for compiling, and I expect to build up a nice library of
modules/dlls as I do more IronPython projects.


On Tue, Apr 27, 2010 at 6:44 AM, Michael Foord
<fuzzyman at voidspace.org.uk> wrote:
> Hello David,
>
> Not sure how close distutils is to working with IronPython.
>
> The correct way to install packages for an installed version of IronPython
> *should* be to use the "user site-packages" rather than the global
> site-packages (which won't be writable for IronPython without admin rights):
>
>     http://www.python.org/dev/peps/pep-0370/
>
>     ipy setup.py install --user
>
> setuptools is a complex, horrible old beast and I wouldn't like to guess at
> its IronPython compatibility. Shame MySQLdb depends on it for an install -
> but MySQLdb almost certainly depends on C extensions anyway. In the long run
> distutils2 will replace setuptools entirely (for CPython the distribute
> package has *already* replaced it whilst remaining compatible). The
> distutils2 guys are *very* open to input - so 'someone' should run the tests
> with IronPython and report any problems.
>
> distutils used to break *after* installing a pure-Python package for
> IronPython when it attempted to do byte-code compilation. This specific
> problem is fixed in trunk but I don't know if it is fixed in the version of
> distutils shipped with IronPython 2.6. This was the last step - so the error
> was alarming but wouldn't stop the install.
>
> All the best,
>
> Michael Foord
>
> On 27/04/2010 07:19, David Shieh wrote:
>
> Hi guys,
> I don't whether somebody else asked this question, but I am really confused
> about this.
> I have already installled IronPython2.6 and add it into my system's path, so
> I can directly type ipy to start IronPython2.6.
> So I tried " ipy setup.py install" to install MySQLdb, but it give me an
> error said no module named setuptools. Then I download setuptools and
> install it, it gave me an error:
> No module named pkg_resources.
> Why doesn't IronPython2.6 ship with a setuptools like easy_install ?
> Now, I can't install any 3rd party package and don't know how to fix it.
> Regards,
> David
> --
> ----------------------------------------------
> Attitude determines everything !
> ----------------------------------------------
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
>
> READ CAREFULLY. By accepting and reading this email you agree, on behalf of
> your employer, to release me from all obligations and waivers arising from
> any and all NON-NEGOTIATED agreements, licenses, terms-of-service,
> shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure,
> non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have
> entered into with your employer, its partners, licensors, agents and
> assigns, in perpetuity, without prejudice to my ongoing rights and
> privileges. You further represent that you have the authority to release me
> from any BOGUS AGREEMENTS on behalf of your employer.
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>



-- 
  Ben Rousch
  brousch at gmail.com
  http://ishmilok.blogspot.com/



More information about the Ironpython-users mailing list