setup.py build & SWIG: missing py files (they are outside the build directory)

mauro mauro.tiz at gmail.com
Wed Oct 10 13:36:12 CEST 2007


Hi all,
I am trying to make a package distribution containing some extension
module written in C. The problem is that when I run setup.py some
files are generated in the wrong position.
Suppose that this is my setup.py:

from distutils.core import setup, Extension

setup(name='foo',
	package_dir  = {"foo" : "src"},
	packages=['foo',
		'foo.spam',
		],
	ext_modules=[
		Extension("foo.spam._spam",
			sources=['src/spam/spam.i',
				'src/spam/spam.cc',
				],
			)
		]
)

Here is an example of what I get after running:

python setup.py build -cmingw32 bdist

.\
    +build\
        +lib.win32-2.4\
            +foo\
                +spam\
                    __init__.py
                    _spam.pyd
                __init__.py
                foo.py
    +src\
    +dist\
        foo-0.0.win32.zip
    setup.py
    spam.py

So the problem is that spam.py (generated by SWIG) is not in .\build
\lib.win32-2.4\foo\spam but in the same directory as setup.py!
Of course I can move it manually, but I have to update also
foo-0.0.win32.zip and all this is quite annoying...
Did I miss some option in the setup? Is it possible to run a system
command (copy) after each extension is compiled and linked and the
corresponding .py file is generated?
Thanks in advance!

Mauro




More information about the Python-list mailing list