Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage_setup/command/sage_build_cython.py: Remove top-level imports…
Browse files Browse the repository at this point in the history
… from sage.env, Cython
  • Loading branch information
Matthias Koeppe committed Oct 17, 2020
1 parent 6fe4d56 commit 698a6ea
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/sage_setup/command/sage_build_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@
from distutils.errors import (DistutilsModuleError,
DistutilsOptionError)

from Cython.Build.Dependencies import default_create_extension
from sage_setup.util import stable_uniq
from sage_setup.find import find_extra_files
from sage_setup.library_order import library_order

from sage.env import (cython_aliases, sage_include_directories)

# Do not put all, but only the most common libraries and their headers
# (that are likely to change on an upgrade) here:
Expand Down Expand Up @@ -57,13 +53,6 @@
if subprocess.call("""$CC --version | grep -i 'gcc.* 4[.]8' >/dev/null """, shell=True) == 0:
extra_compile_args.append('-fno-tree-copyrename')

# Search for dependencies in the source tree and add to the list of include directories
include_dirs = sage_include_directories(use_sources=True)

# Look for libraries only in what is configured already through distutils
# and environment variables
library_dirs = []

class sage_build_cython(Command):
name = 'build_cython'
description = "compile Cython extensions into C/C++ extensions"
Expand Down Expand Up @@ -225,6 +214,13 @@ def run(self):
Call ``cythonize()`` to replace the ``ext_modules`` with the
extensions containing Cython-generated C code.
"""
from sage.env import (cython_aliases, sage_include_directories)
# Set variables used in self.create_extension
from ..library_order import library_order
self.library_order = library_order
# Search for dependencies in the source tree and add to the list of include directories
self.sage_include_dirs = sage_include_directories(use_sources=True)

from Cython.Build import cythonize
import Cython.Compiler.Options

Expand Down Expand Up @@ -295,7 +291,7 @@ def create_extension(self, template, kwds):
# Libraries: sort them
libs = kwds.get('libraries', [])
kwds['libraries'] = sorted(set(libs),
key=lambda lib: library_order.get(lib, 0))
key=lambda lib: self.library_order.get(lib, 0))

# Dependencies: add setup.py and lib_headers
depends = kwds.get('depends', []) + [self.distribution.script_name]
Expand Down Expand Up @@ -336,11 +332,13 @@ def create_extension(self, template, kwds):
kwds['extra_link_args'] = stable_uniq(ldflags)

# Process library_dirs
lib_dirs = kwds.get('library_dirs', []) + library_dirs
lib_dirs = kwds.get('library_dirs', [])
kwds['library_dirs'] = stable_uniq(lib_dirs)

# Process include_dirs
inc_dirs = kwds.get('include_dirs', []) + include_dirs + [self.build_dir]
inc_dirs = kwds.get('include_dirs', []) + self.sage_include_dirs + [self.build_dir]
kwds['include_dirs'] = stable_uniq(inc_dirs)

from Cython.Build.Dependencies import default_create_extension

return default_create_extension(template, kwds)

0 comments on commit 698a6ea

Please sign in to comment.