[Pyrex] problem building simple package with extensions in Windows, but not OS X
Lenard Lindstrom
len-l at telus.net
Wed Jan 9 23:14:55 CET 2008
Brian Blais wrote:
> Hello,
>
> I am trying to build a package of mine, and for some reason the build
> process with distutils is failing in Windows, but not in OS X (and I
> imagine also in Linux, but I haven't tested it). I am not sure if
> this is a Pyrex problem, a distutils problem, or me doing something
> stupid problem. :)
>
> I boiled it down to the simplest package that still fails. My
> setup.py is:
>
> from distutils.core import setup
> from distutils.extension import Extension
> from Pyrex.Distutils import build_ext
>
> setup(
> name = 'myproject',
> version='0.0.1',
> description="Here is a description",
> author="Brian Blais",
> ext_modules=[
> Extension("myproject/train",["myproject/train.pyx"]),
> ],
>
> packages=['myproject'],
>
> cmdclass = {'build_ext': build_ext}
> )
>
>
>
> and my project has one directory, myproject, with two files.
> train.pyx is:
>
> def func(blah):
>
> print blah
>
>
> and an __init__.py, which has the single line:
>
> import train
>
>
> So, in OS X, I can do
>
> python setup.py build
>
> and the build goes through. In windows, with the same basic setup
> (version numbers all below), I get:
>
> [Desktop\test]|5> !python setup.py build
> running build
> running build_py
> creating build
> creating build\lib.win32-2.5
> creating build\lib.win32-2.5\myproject
> copying myproject\__init__.py -> build\lib.win32-2.5\myproject
> running build_ext
> building 'myproject/train' extension
> creating build\temp.win32-2.5
> creating build\temp.win32-2.5\Release
> creating build\temp.win32-2.5\Release\myproject
> c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\python25\include
> -Ic:\pytho
> n25\PC -c myproject/train.c -o
> build\temp.win32-2.5\Release\myproject\train.o
> writing build\temp.win32-2.5\Release\myproject\train.def
> c:\mingw\bin\gcc.exe -mno-cygwin -shared -s
> build\temp.win32-2.5\Release\myproje
> ct\train.o build\temp.win32-2.5\Release\myproject\train.def
> -Lc:\python25\libs -
> Lc:\python25\PCBuild -lpython25 -lmsvcr71 -o
> build\lib.win32-2.5\myproject/train
> .pyd
> Cannot export initmyproject/train: symbol not defined
> collect2: ld returned 1 exit status
> error: command 'gcc' failed with exit status 1
>
>
>
> On both the Mac and the PC I have:
>
> Python 2.5.1
> Pyrex version 0.9.5.1a
> distutils 2.5.1
>
>
>
> am I doing something wrong?
In setup.py try replacing:
Extension("myproject/train",["myproject/train.pyx"]),
with:
Extension("myproject.train",["myproject/train.pyx"]),
When compiling with MinGW distutils creates a def file to export the
module's init routine. When it encountered the backslash in
"myproject/train" it didn't know what to do with it, so tried to export
function initmyproject/train, which is definitely wrong. But distutils
recognizes the dot as a part of a qualified Python module name so
removes the package part. Installing the package shows that everything
goes to the right place.
--
Lenard Lindstrom
<len-l at telus.net>
More information about the Pyrex
mailing list