473,703 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pyrex installation on windows XP: step-by-step guide

Do you wand to install Pyrex on Windows ?

Here is a step-by-step guide explaining:

A) how to install Pyrex on Windows XP.
B) how to compile a Pyrex module.

Julien Fiore,
U. of Geneva

-------------------------------------------

### A) Pyrex installation on Windows XP ###
# step A.1 #
Install Python (we used version 2.4.2)
# step A.2 #
Run the windows installer for Pyrex (e.g. Pyrex-0.9.3.1.win32.e xe),
available on the Pyrex homepage
(http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/)
# step A.3 #
Install Mingw, the gcc compiler for Windows, available at
http://www.mingw.org/download.shtml. (we downloaded the file
MinGW-5.0.2.exe and installed only the "base tool" (this includes
mingw-runtime 3.9, w32api-3.6, binutils 2.15.91 and gcc-core 3.4.2).
Add Mingw path ("C:\MinGW\bin" ) to the Windows "Path" environment
variable. If you already have cygwin installed, add C:\MinGW\bin before
the Cygwin path.
# step A.4 #
Create or edit the file "c:/Python2x/Lib/distutils/distutils.cfg" and
put the following into it:
[build]
compiler = mingw32

-------------------------------------------
### B) Create a Pyrex module ###
# step B.1 #
Create a working directory (e.g. D:\pyrex_module \). Write a pyrex
module and save it with a "pyx" extension (e.g. "primes.pyx ", code
available on the Pyrex homepage)
# step B.2 #
Write the following python script and save it as "setup.py" in your
working directory.

from distutils.core import setup
from distutils.exten sion import Extension
from Pyrex.Distutils import build_ext
setup(
name = "PyrexGuide ",
ext_modules=[
Extension("prim es", ["primes.pyx "])
],
cmdclass = {'build_ext': build_ext}
)

If you want to compile several modules, duplicate the line starting
with "Extension" and replace "primes" by your module names.
# step B.3 #
In your working directory, create a batch file called
"build_and_inst all.bat" containing the following lines, where
"PythonXX" should be replaces by your Python version (e.g. "Python24") .

C:\Python24\pyt hon.exe setup.py build_ext install
pause

To run the batch, double-click the file. You will see many "Warning"
messages during the building process: do not worry, it is normal.
# step B.4 #
Mission completed. The file "primes.pyd " (a "pyd" is a Python Extension
DLL, equivalent of .so in Unix) is now located in
"C:\Python24\Li b\site-packages" and the "primes" module is available in
Python. In your working directory, you can delete the file "primes.c"
and the "build" folder created by the building process.

Test your new module at the python shell:
import primes
primes.primes(1 0)

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

--------------------------------------------

Apr 19 '06 #1
27 3974
Merci beaucoup !
Thank you very much!

--
@-salutations

Michel Claveau
Apr 19 '06 #2
vj
Can you use the stock python build or do you have to build python from
scratch with mingw to use pyrex modules built with mingw?

Apr 20 '06 #3
To install Pyton, I simply used the python Windows installer
(python-2.4.2.msi) available at python.org.

Julien

Apr 20 '06 #4
Julien Fiore wrote:
Do you wand to install Pyrex on Windows ?

Here is a step-by-step guide explaining:

A) how to install Pyrex on Windows XP.
B) how to compile a Pyrex module.

Julien Fiore,
U. of Geneva
Thanks. One detail missing : for this (step b3) to work smoothly, one needs to
make sure that (a copy of) eg python24.dll resides in Python24\libs\

-------------------------------------------

### A) Pyrex installation on Windows XP ###
# step A.1 #
Install Python (we used version 2.4.2)
# step A.2 #
Run the windows installer for Pyrex (e.g. Pyrex-0.9.3.1.win32.e xe),
available on the Pyrex homepage
(http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/)
# step A.3 #
Install Mingw, the gcc compiler for Windows, available at
http://www.mingw.org/download.shtml. (we downloaded the file
MinGW-5.0.2.exe and installed only the "base tool" (this includes
mingw-runtime 3.9, w32api-3.6, binutils 2.15.91 and gcc-core 3.4.2).
Add Mingw path ("C:\MinGW\bin" ) to the Windows "Path" environment
variable. If you already have cygwin installed, add C:\MinGW\bin before
the Cygwin path.
# step A.4 #
Create or edit the file "c:/Python2x/Lib/distutils/distutils.cfg" and
put the following into it:
[build]
compiler = mingw32

-------------------------------------------
### B) Create a Pyrex module ###
# step B.1 #
Create a working directory (e.g. D:\pyrex_module \). Write a pyrex
module and save it with a "pyx" extension (e.g. "primes.pyx ", code
available on the Pyrex homepage)
# step B.2 #
Write the following python script and save it as "setup.py" in your
working directory.

from distutils.core import setup
from distutils.exten sion import Extension
from Pyrex.Distutils import build_ext
setup(
name = "PyrexGuide ",
ext_modules=[
Extension("prim es", ["primes.pyx "])
],
cmdclass = {'build_ext': build_ext}
)

If you want to compile several modules, duplicate the line starting
with "Extension" and replace "primes" by your module names.
# step B.3 #
In your working directory, create a batch file called
"build_and_inst all.bat" containing the following lines, where
"PythonXX" should be replaces by your Python version (e.g. "Python24") .

C:\Python24\pyt hon.exe setup.py build_ext install
pause

To run the batch, double-click the file. You will see many "Warning"
messages during the building process: do not worry, it is normal.
# step B.4 #
Mission completed. The file "primes.pyd " (a "pyd" is a Python Extension
DLL, equivalent of .so in Unix) is now located in
"C:\Python24\Li b\site-packages" and the "primes" module is available in
Python. In your working directory, you can delete the file "primes.c"
and the "build" folder created by the building process.

Test your new module at the python shell:
import primes
primes.primes(1 0)

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

--------------------------------------------

Apr 26 '06 #5

Julien Fiore wrote:

# step A.3 #
Install Mingw, the gcc compiler for Windows, available at
http://www.mingw.org/download.shtml. (we downloaded the file
MinGW-5.0.2.exe and installed only the "base tool" (this includes
mingw-runtime 3.9, w32api-3.6, binutils 2.15.91 and gcc-core 3.4.2).
Add Mingw path ("C:\MinGW\bin" ) to the Windows "Path" environment
variable. If you already have cygwin installed, add C:\MinGW\bin before
the Cygwin path.

I don't think this is safe. MinGW links with msvcrt.dll whereas the
main Python distribution links with msvcr71.dll (due to Visual C++
2003). It is not safe to mix and blend different C runtime libraries.
If you are to build a C extension with MinGW, you also need to build
Python against msvcrt.dll, i.e. you have to use a Python built with
MinGW or Visual C++ 6.0. There other option is to make MinGW link
against msvcr71.dll. I don't know if that is feasible.

Apr 26 '06 #6
Thanks for your remark, Sturlamolden.

Is there a free version of the "Visual C++ 2003" compiler available on
the web? I have found "Visual C++ 2005 Express edition"
(http://msdn.microsoft.com/vstudio/express/visualc/). According to
Micrsoft, it replaces VC++2003
(http://msdn.microsoft.com/visualc/vctoolkit2003/). Is VC++2005ee the
good compiler to compile a Pyrex module (or any Python extension) ?
Does it link with msvcr71.dll ?

Apr 27 '06 #7

Julien Fiore wrote:
Thanks for your remark, Sturlamolden.

Is there a free version of the "Visual C++ 2003" compiler available on
the web? I have found "Visual C++ 2005 Express edition"
(http://msdn.microsoft.com/vstudio/express/visualc/). According to
Micrsoft, it replaces VC++2003
(http://msdn.microsoft.com/visualc/vctoolkit2003/). Is VC++2005ee the
good compiler to compile a Pyrex module (or any Python extension) ?
Does it link with msvcr71.dll ?


The bad news is that "Visual C++ 2005 Express" links with msvcr80.dll,
which incompatible with both msvcrt.dll and msvcr71.dll. What you need
is the "Microsoft .NET Framework SDK Version 1.1". It contains version
7.1 of Microsoft's C/C++ compiler and links with the correct CRT.

http://tinyurl.com/5flob

I am not sure if this is an optimizing compiler. Microsoft did not give
away their optimizing compiler prior to "Visual C++ 2005 Express". Even
the standard version of Visual Studio did not have an optimizing
compiler, it only shipped with the professional and enterprise
versions. If this compiler does not optimize, you may try to make
"Visual C++ 2005 Express" use the import library for msvcr71.dll which
ships with the .NET SDK.

Now you know the meaning of the word "DLL HELL".

Apr 27 '06 #8

sturlamolden wrote:
I don't think this is safe. MinGW links with msvcrt.dll whereas the
main Python distribution links with msvcr71.dll (due to Visual C++
2003).


In order to make minGW link with msvcr71.dll, edit the text file

c:\mingw\lib\gc c\mingw32\3.2.4 \specs

and change "-lmsvcrt" to "-lmsvcr71".

Now MinGW will link with the same CRT as Python 2.4.

Apr 27 '06 #9
sturlamolden wrote:
edit the text file "c:\mingw\lib\g cc\mingw32\3.2. 4\specs"
and change "-lmsvcrt" to "-lmsvcr71".


Thank you very much sturlamolden,

This procedure should be added to the "step-by-step" guide (see 1st
message of this thread) as "step A.5".

For ignorant people like me, CRT = "C runtime library".

Apr 28 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2306
by: Gary Stephenson | last post by:
I'm getting a clean generate, compile and link from my .pyx script, but when I attempt to run the resultant .exe, I get: "The procedure entry point Py_NoneStruct could not be located in the dynamic link library python23.dll" Can anybody provide me with a clue here? I've already cut down my script to remove all references to None, Py_None, NULLs, etc, but to no avail. fwiw I'm using latest Pyrex and ActiveState build 232.
1
1673
by: Paul Prescod | last post by:
PyCon 2004 Slides on "Extending Python with Pyrex" PDF: http://www.prescod.net/pyrex/ExtendingPythonWithPyrex.pdf PPT: http://www.prescod.net/pyrex/ExtendingPythonWithPyrex.ppt Pycon 2004 Slides on "Optimizing Python code with Pyrex" PDF: http://www.prescod.net/pyrex/OptimizingPythonWithPyrex.pdf PPT: http://www.prescod.net/pyrex/OptimizingPythonWithPyrex.ppt I hope this helps me. Please report any mistakes.
4
2071
by: Kyler Laird | last post by:
I mentioned earlier that I started using Pyrex because I'm taking a computer vision course that requires all assignments to be submitted as C(++). While I could write C it would hurt me to do so and certainly distract me from the computer vision aspects. I like using Python these days and Pyrex looked like a good solution. (BTW, on the last assignment I saw several messages from someone having difficulty with segfaults due to memory...
6
1935
by: SeeBelow | last post by:
I just read "about Pyrex" at http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/version/Doc/About.html It seems that it is not compiled into machine code, as C would be, and therefore it does not offer the only valid reason for using C, which is for an increase in execution speed. The word "speed" does not appear on the above web page. Am I wrong about this? Perhaps I don't understand how Pyrex works.
1
1626
by: SM | last post by:
Hi, I would like to play with Pyrex for Windows. I have no clue how to install it including a c compiler. Anyone using pyrex on windows who could give a quickstart? Stani http://spe.pycs.net http://www.stani.be
1
3578
by: Martin Bless | last post by:
Now that I've got my extension building machine using the VC++ Toolkit 2003 up and running I'm keen on using Pyrex (Pyrex-0.9.3, Python-2.4.0). But the definition of the swig_sources() method seems to have changed. When I try to build the examples from Pyrex I get a TypeError: c:\Pyrex-0.9.3\Demos> python Setup.py build_ext --inplace
3
409
by: Kenneth Lai | last post by:
After installed MSDN Library Oct 2003. I got a HTML error "Action Cancel" on the first page and no contents can be loaded. I try reinstall several time and still got this problem. Anyone have this experience before. The followings are the config of my computer which may
6
2233
by: JW | last post by:
I have a lousy little Python extension, generated with the generous help of Pyrex. In Linux, things are simple. I compile the extension, link it against some C stuff, and *poof*! everything works. My employer wants me to create a Windows version of my extension that works with the vanilla Python 2.5 from python.org. My employment contract states that I won't be required to run Windows, and I desperately want to honor that clause....
3
1762
by: Mathieu | last post by:
Salut à tous et bonne année, Alors, voilà, je suis allé sur le site http://java.sun.com/, mais je n'arrive à télécharger aucun jdk, ni actuel ni ancien par exemple pour le plus récent jdk6, je sélectionne bien la version pour windows, mais il me met un message comme quoi il est recommandé d'utiliser WXP Pro SP2... je le laisse dire... SP2 je sais pas, mais wxp pro c'est ce que j'ai. Mais ensuite, j'ai un message d'erreur pendant...
3
3659
by: Raja | last post by:
Hi, I have installed wamp server in windows, now i try to install php- gtk2 extension i can't installed, any one know the installation of php-gtk2, could you please help the installation process. Thanks & Regards,
0
8659
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5920
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4674
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2424
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.