Jump to content
  • Advertisement
Sign in to follow this  


This topic is 4026 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there guys, I was wondering what you guys thought about PyRex. It looks really cool, only problem I’ve heard so far is that you need to use Visual Studio 7.1 to build the modules because Python was built with VC 7.1. A little bit of a problem for me because all I got is VC8. I went ahead and rebuilt Python with VC8 to see if that will solve the problem and so far the build I made seams to be working with other python modules. I don’t know how to build a PyRex module yet (or even a firm grasp on what’s needed to make one) but once I’m there I’ll give my newly built python exe a shot and see if that works. Added: Gezz... well that was a bust. I dug up my old copy of MSVC 7.1 academic and uninstalled MSVC 8 in prep to try again. I don't see why it won't work this time around. [Edited by - MrRage on July 12, 2007 8:26:34 AM]

Share this post

Link to post
Share on other sites
Crap.. now I have a DLL but havn't got a clue how to turn this into a module. The prime.dll is now in DLLs and I made an empty Libs/prime/__init__.py

So I'm missing something... perhaps I need to use disutils or something.

Share this post

Link to post
Share on other sites
Ok... Got it working with visual studio 7.1. Kind of a disappointment that I had to downgrade my compiler. But oh well, guess it really wasn't much of an upgrade if things stopped working.

For anyone hows interested in trying this out. Download Pyrex-0.9.x - install it using the setup .py.

1) Create a simple PyRex file, like so.

def primes(int kmax):
cdef int n, k, i
cdef int p[1000]
result = []
if kmax > 1000:
kmax = 1000
k = 0
n = 2
while k < kmax:
i = 0
while i < k and n % p <> 0:
i = i + 1
if i == k:
p[k] = n
k = k + 1
n = n + 1
return result

2) Build that using the pyrexc script like so.
python c:\Python25\Scripts\pyrexc.py prime.pyx

3) Build a project and compile the built code into a DLL. Key things - compile as C, DLL and I think thats it.

4) Use this setup.py to buld your new prime module.

from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
name = "prime",
Extension("prime", ["prime.pyx"], libraries = ["prime"])
cmdclass = {'build_ext': build_ext}

And finally - build the module using the command line:
python setup.py build_ext --inplace

There you have it. This might be review for most of you but I burned my whole evening last night trying to figure this out on my own. So maybe now someone won't have to.

[Edited by - MrRage on July 12, 2007 11:59:34 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!