[Numpy-discussion] failed to build numpy and Numeric in Windows

Gerard Vermeulen gerard.vermeulen at grenoble.cnrs.fr
Fri Jan 12 14:54:15 CST 2007


On Fri, 12 Jan 2007 14:07:23 -0600
"Zhou, Mi" <Mi.Zhou at STJUDE.ORG> wrote:

> Hi,
> 
> Python on the same machine was built with MSVS2005. I think it is
> capable of building python modules. 
> 
> Interestingly, if I replace "floor" with "ceil" in that line of code. It
> will build just fine, and of course, the Numeric.floor() will work just
> like Numeric.ceil():
> 
> static void * floor_data[] = { (void *)ceil,  (void *)ceil,  (void
> *)"floor",  };
> 
> Thanks,
> 
> Mi
> 

I have found that I needed to patch the Python-2.4.3 distutils to build
numpy and Numeric with MSVC-2005 (check the compiler flags):

--- Python-2.4.3/Lib/distutils/msvccompiler.py.win64	2005-08-07 22:50:37.000000000 +0200
+++ Python-2.4.3/Lib/distutils/msvccompiler.py	2006-06-25 08:45:14.812500000 +0200
@@ -206,15 +206,21 @@
     def __init__ (self, verbose=0, dry_run=0, force=0):
         CCompiler.__init__ (self, verbose, dry_run, force)
         self.__version = get_build_version()
-        if self.__version >= 7:
+        if 8.0 > self.__version >= 7:
             self.__root = r"Software\Microsoft\VisualStudio"
             self.__macros = MacroExpander(self.__version)
         else:
+            # XXX: don't know how to get the MSVS2005 info from the registry.
+            # So, use of distutils in a MSVS2005 32 or 64 bit command prompt
+            # to get the info from the environment.
             self.__root = r"Software\Microsoft\Devstudio"
         self.initialized = False
 
     def initialize(self):
-        self.__paths = self.get_msvc_paths("path")
+        if self.__version >= 8.0:
+            self.__paths = os.environ['PATH'].split(os.pathsep)
+        else:
+            self.__paths = self.get_msvc_paths("path")
 
         if len (self.__paths) == 0:
             raise DistutilsPlatformError, \
@@ -227,22 +233,38 @@
         self.lib = self.find_exe("lib.exe")
         self.rc = self.find_exe("rc.exe")   # resource compiler
         self.mc = self.find_exe("mc.exe")   # message compiler
-        self.set_path_env_var('lib')
-        self.set_path_env_var('include')
+        if self.__version < 8.0:
+            self.set_path_env_var('lib')
+            self.set_path_env_var('include')
 
         # extend the MSVC path with the current path
-        try:
-            for p in string.split(os.environ['path'], ';'):
-                self.__paths.append(p)
-        except KeyError:
-            pass
-        os.environ['path'] = string.join(self.__paths, ';')
+        if self.__version < 8.0:
+            try:    
+                for p in string.split(os.environ['path'], ';'):
+                    self.__paths.append(p)
+            except KeyError:
+                pass
+            os.environ['path'] = string.join(self.__paths, ';')
 
         self.preprocess_options = None
-        self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' ,
-                                 '/DNDEBUG']
-        self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX',
-                                      '/Z7', '/D_DEBUG']
+        if self.__version < 8.0:
+            self.compile_options = [
+                '/nologo', '/Ox', '/MD', '/W3', '/GX' , '/DNDEBUG']
+            self.compile_options_debug = [
+                '/nologo', '/Od', '/MDd', '/W3', '/GX', '/Z7', '/D_DEBUG']
+        else:
+            # MSC-8.0 using /Ox (=/Ob2gity /Gs) chokes on DLLs containing:
+            #
+            # #include <math.h>
+            # static void *p = (void *)ceil;
+            #
+            # because of the /Oi option (Numeric and NumPy use such code).
+            # Moreover, the compiler flags /Og as deprecated.
+            self.compile_options = [
+                '/nologo', '/Ob2ty', '/MD', '/W3', '/EHsc' , '/DNDEBUG']
+            self.compile_options_debug = [
+                '/nologo', '/Od', '/MDd', '/W3', '/EHsc', '/Z7', '/D_DEBUG']
+       
 
         self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO']
         if self.__version >= 7:


This is clearly a compiler bug, that may go away with a bug fix.

Gerard
 

> -----Original Message-----
> From: numpy-discussion-bounces at scipy.org
> [mailto:numpy-discussion-bounces at scipy.org] On Behalf Of Robert Kern
> Sent: Friday, January 12, 2007 1:55 PM
> To: Discussion of Numerical Python
> Subject: Re: [Numpy-discussion] failed to build numpy and Numeric in
> Windows
> 
> Zhou, Mi wrote:
> > Hi,
> > 
> > I am trying to build Numpy-1.01 in windows using "python setup.py
> > build".  My C compiler is MSVS2005.
> 
> Hmm. I was pretty sure that MSVS2005 was not capable of building Python
> extension modules that work with the official Python interpreter builds.
> That
> doesn't explain or solve the problem that you state, but if the problem
> is
> restricted to MSVS2005, it may not be worth solving.
> 
> -- 
> Robert Kern
> 
> "I have come to believe that the whole world is an enigma, a harmless
> enigma
>  that is made terrible by our own mad attempt to interpret it as though
> it had
>  an underlying truth."
>   -- Umberto Eco
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
> 
> 
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
> 


More information about the Numpy-discussion mailing list