nachdem ich unlängst Probleme mit einem setup-Skript hatte, hier die Lösung, die ich inzwischen gewählt habe. Etwas eingekürzt, aber so allgemein, daß wer es braucht, sicher was damit anfangen kann:
Code: Alles auswählen
from distutils.core import setup
from distutils.extension import Extension
try:
from Pyrex.Distutils import build_ext
has_pyrex = True
except ImportError:
has_pyrex = False
if has_pyrex:
pyx_sources = ["src/my_pyrexmodule1.pyx", "src/my_pyrexmodule2.pyx"]
cmdclass = {'build_ext': build_ext}
else:
pyx_sources = ['my_pyrexmodule1.c', 'my_pyrexmodule2.c']
cmdclass = {}
import numpy
# ggf. eine Benachrichtigung an den User, daß numpy nötig ist
pyx_ext = Extension('ext_modul_name',
pyx_sources,
include_dirs = [numpy.get_include()])
setup(
name = "paketnames",
<snip metadaten>
packages = ['paketname'],
package_dir={'paketname': 'src/'},
package_data = {'paketname': ['README', 'INSTALL']},
ext_package='paketname',
ext_modules = [pyx_ext],
cmdclass = cmdclass
)
Gruß,
Christian