Skip to content

Commit

Permalink
A few changes to Cython dependency handling
Browse files Browse the repository at this point in the history
--HG--
extra : convert_revision : svn%3A4fd6b974-1f5f-4fb2-bae3-e0fdb782a42a/trunk%40864
  • Loading branch information
dalcinl committed Aug 10, 2011
1 parent 04d4cfd commit 6b9e24a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[config]
# mpicc = mpicc
# mpicc = mpicc
# mpicxx = mpicxx
# mpif77 = mpif77
# mpif90 = mpif90
Expand Down
27 changes: 14 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def chk_cython(VERSION):
if os.path.isfile(cython_zip):
path = os.path.abspath(cython_zip)
if sys.path[0] != path:
sys.path.insert(0, os.path.abspath(cython_zip))
sys.path.insert(0, path)
log.info("adding '%s' to sys.path", cython_zip)
#
try:
Expand Down Expand Up @@ -478,8 +478,8 @@ def chk_cython(VERSION):
return True

def run_cython(source, depends=(), includes=(),
destdir_c=None, destdir_h=None, wdir=None,
force=False, VERSION=None):
destdir_c=None, destdir_h=None,
wdir=None, force=False):
from glob import glob
from distutils import log
from distutils import dep_util
Expand All @@ -497,8 +497,6 @@ def run_cython(source, depends=(), includes=(),
return
finally:
os.chdir(cwd)
if not chk_cython(VERSION):
raise DistutilsError('requires Cython>=%s' % VERSION)
log.info("cythonizing '%s' -> '%s'", source, target)
from conf.cythonize import cythonize
err = cythonize(source,
Expand All @@ -511,10 +509,13 @@ def run_cython(source, depends=(), includes=(),
"Cython failure: '%s' -> '%s'" % (source, target))

def build_sources(cmd):
if not (os.path.isdir('.svn') or
os.path.isdir('.git') or
os.path.isdir('.hg') or
cmd.force): return
from os.path import exists, isdir, join
has_src = (exists(join('src', 'mpi4py.MPI.c')) and
exists(join('src', 'mpi4py.MPE.c')))
has_vcs = (isdir('.svn') or isdir('.git') or isdir('.hg'))
if (has_src and not has_vcs and not cmd.force): return
if not chk_cython(CYTHON):
raise DistutilsError('requires Cython>=%s' % CYTHON)
# mpi4py.MPI
source = 'mpi4py.MPI.pyx'
depends = ("include/*/*.pxi",
Expand All @@ -524,16 +525,16 @@ def build_sources(cmd):
includes = ['include']
destdir_h = os.path.join('include', 'mpi4py')
run_cython(source, depends, includes,
destdir_c=None, destdir_h=destdir_h, wdir='src',
force=cmd.force, VERSION=CYTHON)
destdir_c=None, destdir_h=destdir_h,
wdir='src', force=cmd.force)
# mpi4py.MPE
source = 'mpi4py.MPE.pyx'
depends = ("MPE/*.pyx",
"MPE/*.pxi",)
includes = ['include']
run_cython(source, depends, includes,
destdir_c=None, destdir_h=None, wdir='src',
force=cmd.force, VERSION=CYTHON)
destdir_c=None, destdir_h=None,
wdir='src', force=cmd.force)

from conf.mpidistutils import build_src
build_src.run = build_sources
Expand Down

0 comments on commit 6b9e24a

Please sign in to comment.