Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b15eb7

Browse files
committed
Do not import pyrex in distutils unless there are some pyrex source files.
1 parent dbd30d1 commit 5b15eb7

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

numpy/distutils/command/build_src.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
from distutils.util import get_platform
1313
from distutils.errors import DistutilsError, DistutilsSetupError
1414

15-
try:
16-
import Pyrex.Compiler.Main
17-
have_pyrex = True
18-
except ImportError:
19-
have_pyrex = False
15+
def have_pyrex():
16+
try:
17+
import Pyrex.Compiler.Main
18+
return True
19+
except ImportError:
20+
return False
2021

2122
# this import can't be done here, as it uses numpy stuff only available
2223
# after it's installed
@@ -462,14 +463,15 @@ def pyrex_sources(self, sources, extension):
462463
return new_sources
463464

464465
def generate_a_pyrex_source(self, base, ext_name, source, extension):
465-
if self.inplace or not have_pyrex:
466+
if self.inplace or not have_pyrex():
466467
target_dir = os.path.dirname(base)
467468
else:
468469
target_dir = appendpath(self.build_src, os.path.dirname(base))
469470
target_file = os.path.join(target_dir, ext_name + '.c')
470471
depends = [source] + extension.depends
471472
if self.force or newer_group(depends, target_file, 'newer'):
472-
if have_pyrex:
473+
if have_pyrex():
474+
import Pyrex.Compiler.Main
473475
log.info("pyrexc:> %s" % (target_file))
474476
self.mkpath(target_dir)
475477
options = Pyrex.Compiler.Main.CompilationOptions(

0 commit comments

Comments
 (0)