<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=Loading_Python_.pyd_extensions</id>
	<title>Loading Python .pyd extensions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=Loading_Python_.pyd_extensions"/>
	<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=Loading_Python_.pyd_extensions&amp;action=history"/>
	<updated>2026-08-05T23:55:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://bf2tech.uturista.pt/index.php?title=Loading_Python_.pyd_extensions&amp;diff=83&amp;oldid=prev</id>
		<title>Pireax: Created page with &quot;If you&#039;ve found yourself on this page hoping to find out how to load your own C++ code (.DLL) via a .pyd file. You may well be dissappointed. As of yet I have not worked out h...&quot;</title>
		<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=Loading_Python_.pyd_extensions&amp;diff=83&amp;oldid=prev"/>
		<updated>2018-06-21T19:24:51Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;If you&amp;#039;ve found yourself on this page hoping to find out how to load your own C++ code (.DLL) via a .pyd file. You may well be dissappointed. As of yet I have not worked out h...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;If you&amp;#039;ve found yourself on this page hoping to find out how to load your own C++ code (.DLL) via a .pyd file. You may well be dissappointed. As of yet I have not worked out how to do this.&lt;br /&gt;
&lt;br /&gt;
I was using the boost_python libraries to create the .pyd file, but I&amp;#039;ve downloaded several other types and you always get this error message.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;ImportError: Don&amp;#039;t know how to import XYZ (type code 3) &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you know the answer please post here.&lt;br /&gt;
&lt;br /&gt;
Perhaps this page can be about brain-storming a few ideas.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;19 September 2006&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I haven&amp;#039;t used [http://www.python.org/infogami-faq/windows/is-a-pyd-file-the-same-as-a-dll/ .pyd] files or [http://www.boost.org/libs/python/doc/ Boost.Python], so I don&amp;#039;t have a solution for you, but I do have some suggestions:&lt;br /&gt;
&lt;br /&gt;
* Have you tried using your code with a normal stand-alone Python interpreter--that is, one that isn&amp;#039;t part of BF2? The Python interpreter in BF2 is an old version of Python and has had some of it&amp;#039;s standard libraries removed, so occasionally I&amp;#039;ve found things that work in normal Python that don&amp;#039;t work in BF2. It may be that the ability to load .pyd files is one of the things that has been lobotomized out of BF2&amp;#039;s Python.&lt;br /&gt;
* I notice that the [http://www.boost.org/libs/python/doc/v2/platforms.html Boost.Python documentation] only mentions compatibility with Python 2.2. BF2 uses Python 2.3--I don&amp;#039;t know if this is a problem or not; maybe their documentation just hasn&amp;#039;t been updated in a long time.&lt;br /&gt;
* The Python/C API changes slightly from one version of Python to the next; if your .pyd file was compiled for the current version of Python (2.4), it probably won&amp;#039;t work with BF2&amp;#039;s Python (2.3). If this is the problem, you ought to be able to recompile for Python 2.3 and have it work.&lt;br /&gt;
* Unless you really get into writing C code, you might have a look at [http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ Pyrex]; it lets you write Python extensions in a subset of Python (a very large subset) that it then compiles into C code, which you can compile into a binary executable. It gives you the speed of C with the convienience of Python. I&amp;#039;ve been thinking about trying it with BF2, but haven&amp;#039;t done so yet, so this is something of a shot in the dark.&lt;br /&gt;
&lt;br /&gt;
--Woody 10:02, 19 September 2006 (MDT)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Thanx very much for the input, greatly appreciated. In reply to your points:&lt;br /&gt;
&lt;br /&gt;
* Yes I have run the .pyd from within an interpreter and it imports and runs perfectly.&lt;br /&gt;
* good point, I will try compiling my .pyd against v2.2&lt;br /&gt;
* I have tried compiling with both 2.3 and 2.4. BF2 python reports its version as 2.3&lt;br /&gt;
* interesting suggestion, unfortunately I need to integrate existing c++ code and be able to call it from event handlers within BF2 so this is not going to solve my problem&lt;br /&gt;
&lt;br /&gt;
What also puzzles me is that it is not just my .pyd which won&amp;#039;t import into BF2 python, I have tried a wide variety of .pyd&amp;#039;s from a number of sources and none will import ( ctypes, calldll, winsound among others). I am beginning to fear that what you said about the BF2 Python interpreter being lobotomized is the problem.&lt;br /&gt;
&lt;br /&gt;
--Andrewd 01:59, 20 September 2006 (MDT)&lt;/div&gt;</summary>
		<author><name>Pireax</name></author>
	</entry>
</feed>