IronLanguages / main

Work for this repo has moved to https://github.com/IronLanguages/ironpython2
1.16k stars 347 forks source link

Tracking: Support CPython extension modules (*.pyd) #296

Open ironpythonbot opened 9 years ago

ironpythonbot commented 9 years ago

This isn't something we're likely to implement soon - there's lots of challenges in getting this to work. Unfortunately you'll probably not be able to get it working from C# either, but this might be a great use for C++/CLI instead. I believe we do have a bug filed against it, we just won't get to it anytime soon J.

There's two big problems here:

            #1) Re-creating the unmanaged CPython interfaces - this will be no small chore
            #2) Dealing w/ direct access to the raw object layout.  For example I don't believe bumping the ref count goes through an API, instead it just uses a macro which adjusts the raw memory.

1 is by and large just a matter of someone cranking through and creating

the thunks that map into the IronPython runtime (I'd include the calls into the PYD's init and other functions as well here). But #2 is a large can of worms. What probably needs to happen is VirtualAlloc'ing a block of memory as read-only, setting up an exception handler, and fixing the memory up at runtime as it's accessed - then when changes happen directly to memory the C# objects can be updated.

All in all it's a huge project... In the mean time you might be able to find a .NET library that does the same thing as the PYD and either wrap that in some Python code if programming against the same API is a must or just program directly against it if that's not one of your requirements.

Glad you're having a good time with it!

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Josh Cassell
Sent: Tuesday, October 03, 2006 11:14 AM
To: users at lists.ironpython.com
Subject: [IronPython] pyd files

Is there ever going to be a way to import from a .pyd file in IronPython? If not, is it possible to interop to a .pyd file in C# in order to wrap it for use from IronPython?

Btw, I'm new to Python, and it has been very enjoyable and exciting using IronPython. Thanks very much!

Josh

Work Item Details

Original CodePlex Issue: Issue 11333 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jun 25, 2007 at 6:55 PM Reported by: dfugate Updated on: Aug 26, 2013 at 11:56 PM Updated by: Lythie

ironpythonbot commented 9 years ago

On 2007-06-26 05:51:26 UTC, sborde commented:

We can look into hosting the CPython engine to build an interop bridge without having to deal with the CPython interfaces directly.

ironpythonbot commented 9 years ago

On 2007-11-02 21:03:38 UTC, fuzzyman commented:

This feature will be added to IronPython by Resolver Systems as an open source project. Some progress has already been made.

Relevant links:

http://www.resolversystems.com/news/?p=17 (project announcement)

http://groups.google.com/group/c-extensions-for-ironpython (mailing list)

http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml (working proof of concept)

ironpythonbot commented 9 years ago

On 2008-12-02 12:00:04 UTC, TraumaPony commented:

I wish I could vote up more than once for this.

ironpythonbot commented 9 years ago

On 2008-12-02 19:29:56 UTC, Eloff commented:

You can, Ironclad is open source, http://code.google.com/p/ironclad/, feel free to contribute.

ironpythonbot commented 9 years ago

On 2008-12-05 19:56:07 UTC, fuzzyman commented:

Shouldn't this issue be closed? There's no way it will be implemented separately from Ironclad right?

ironpythonbot commented 9 years ago

On 2013-05-29 04:30:22 UTC, bc3tech commented:

Looks like Ironclad might have worked in the past, but its DLLs are statically referencing IronPython 2.6 and won't work with IP 2.7 :( Would be great if IP would pull in Ironclad since it looks like it is mostly there as of 2.6 - might just need to recompile against 2.7 IP DLLs

sopelt commented 9 years ago

FYI: It seem like https://github.com/IronLanguages/ironclad attempts to revive ironclad and support it in IPy 2.7.

macumber commented 7 years ago

Would love to see this implemented.!

slide commented 7 years ago

I don't think this will get life in the 2.7 releases, but we could look at it for IronPython 3