[MERGE] Fast _walkdirs for win32

Alexander Belchenko bialix at ukr.net
Thu Jul 17 19:03:39 BST 2008


John Arbash Meinel пишет:
> Alexander Belchenko wrote:
> | Adrian Wilkins ?8H5B:
> |> :
> |> [...]
> |>>> 2) But anyway it failed because linker cannot find Win32 API 
> functions:
> |>>>
> |>
> |> That's odd, it builds fine here.
> |
> | Then something wrong with my computer.
> |
> |> Which environment are you using?
> |
> | IIUC it's called Microsoft Visual Studio .NET 2003.
> |
> |> I'm on MS Visual C++ Toolkit 2003, and I'm using it's headers and
> |> libraries.
> |> This corresponds to the environment used to build Python 2.5.
> |>
> |> AFAIK jam is using MinGW.
> 
> Looking at the generated code, I'm pretty sure it is your Pyrex version.

I disagree with you. I've upgraded Pyrex to latest version 0.9.8.4 but still has
the same problem.

> Your version spits out:
> 
> #ifndef WIN32
> #define __stdcall
> #endif
> 
> Which universally overwrites it.
> 
> Here I'm seeing
> 
> #ifndef WIN32
> #  ifndef __stdcall
> #    define __stdcall
> #  endif
> #endif
> 
> Which won't override them if they are already set.

But my problem is that my compiler does not set neither WIN32 symbol nor __stdcall.
According to MSDN __stdcall is keyword, not define.

I just did very simple testing main.c:

#ifndef __stdcall
#error __stdcall is not defined
#endif

And when I'm trying to compile it (via simple SConstruct) I have error:

C:\Temp\5>scons
scons: Entering directory `C:\Temp\5'
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /nologo /c main.c /Fomain.obj
main.c
main.c(2) : fatal error C1189: #error :  __stdcall is not defined
scons: *** [main.obj] Error 2
scons: building terminated because of errors.


But I found the way to satisfy pyrex and python's distutils. This change in setup.py
does resolve my problem:


=== modified file 'setup.py'
--- setup.py 17.07.2008 15:55:11
+++ setup.py 17.07.2008 20:58:25
@@ -216,18 +216,19 @@
      pyrex_name = path + '.pyx'
      c_name = path + '.c'
      if have_pyrex:
-        ext_modules.append(Extension(module_name, [pyrex_name]))
+        ext_modules.append(Extension(module_name, [pyrex_name], **kwargs))
      else:
          if not os.path.isfile(c_name):
              unavailable_files.append(c_name)
          else:
-            ext_modules.append(Extension(module_name, [c_name]))
+            ext_modules.append(Extension(module_name, [c_name], **kwargs))


  add_pyrex_extension('bzrlib._dirstate_helpers_c')
  add_pyrex_extension('bzrlib._knit_load_data_c')
  if sys.platform == 'win32':
-    add_pyrex_extension('bzrlib._walkdirs_win32')
+    add_pyrex_extension('bzrlib._walkdirs_win32',
+                        define_macros=[('WIN32',None)])
  ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))




So even if my compiler is ugly or broken, there is the bug in Pyrex too.
It should use MS_WINDOWS constant instead of WIN32, according to C:\Python25\include\pyconfig.h




More information about the bazaar mailing list