(self)
return custom_build_ext
Returns a class that can be used as a replacement for the
        ``build_ext`` command in ``setuptools`` and that will compile the C core
        of igraph before compiling the Python extension.
Returns a class that can be used as a replacement for the
        ``build_ext`` command in ``setuptools`` and that will compile the C core
        of igraph before compiling the Python extension.
Returns a class that can be used as a replacement for the build_ext command in setuptools and that will compile the C core of igraph before compiling the Python extension .
def build_ext(self) -> Command:
        """Returns a class that can be used as a replacement for the
        ``build_ext`` command in ``setuptools`` and that will compile the C core
        of igraph before compiling the Python extension.
        """
        from setuptools.command.build_ext import build_ext

        buildcfg = self

        class custom_build_ext(build_ext):
            def run(self):
                # Bail out if we don't have the Python include files
                include_dir = sysconfig.get_path('include')
                if not os.path.isfile(os.path.join(include_dir, "Python.h")):
                    print("You will need the Python headers to compile this extension.")
                    sys.exit(1)

                # Check whether the user asked us to discover a pre-built igraph
                # with pkg-config
                detected = False
                if buildcfg.use_pkgconfig:
                    detected = buildcfg.detect_from_pkgconfig()
                    if not detected:
                        print(
                            "Cannot find the C core of igraph on this system using pkg-config."
                        )
                        sys.exit(1)
                else:
                    # Build the C core from the vendored igraph source
                    self.run_command("build_c_core")
                    if not buildcfg.c_core_built:
                        # Fall back to an educated guess if everything else failed
                        if not detected:
                            buildcfg.use_educated_guess()

                # Add any extra library paths if needed; this is needed for the
                # Appveyor CI build
                if "IGRAPH_EXTRA_LIBRARY_PATH" in os.environ:
                    buildcfg.library_dirs = (
                        list(os.environ["IGRAPH_EXTRA_LIBRARY_PATH"].split(os.pathsep))
                        + buildcfg.library_dirs
                    )

                # Add extra libraries that may have been specified
                if "IGRAPH_EXTRA_LIBRARIES" in os.environ:
                    extra_libraries = os.environ["IGRAPH_EXTRA_LIBRARIES"].split(",")
                    buildcfg.libraries.extend(extra_libraries)

                # Override static specification based on environment variable
                if "IGRAPH_STATIC_EXTENSION" in os.environ:
                    if os.environ["IGRAPH_STATIC_EXTENSION"].lower() in [
                        "true",
                        "1",
                        "on",
                    ]:
                        buildcfg.static_extension = True
                    else:
                        buildcfg.static_extension = False

                # Replaces library names with full paths to static libraries
                # where possible. libm.a is excluded because it caused problems
                # on Sabayon Linux where libm.a is probably not compiled with
                # -fPIC
                if buildcfg.static_extension:
                    if buildcfg.static_extension == "only_igraph":
                        buildcfg.replace_static_libraries(only=["igraph"])
                    else:
                        buildcfg.replace_static_libraries(exclusions=["m"])

                # Add extra libraries that may have been specified
                if "IGRAPH_EXTRA_DYNAMIC_LIBRARIES" in os.environ:
                    extra_libraries = os.environ[
                        "IGRAPH_EXTRA_DYNAMIC_LIBRARIES"
                    ].split(",")
                    buildcfg.libraries.extend(extra_libraries)

                # Remove C++ standard library as we will use the C++ linker
                for lib in ("c++", "stdc++"):
                    if lib in buildcfg.libraries:
                        buildcfg.libraries.remove(lib)

                # Prints basic build information
                buildcfg.print_build_info()

                # Find the igraph extension and configure it with the settings
                # of this build configuration
                ext = first(
                    extension
                    for extension in self.extensions
                    if extension.name == "igraph._igraph"
                )
                buildcfg.configure(ext)

                # Run the original build_ext command
                build_ext.run(self)

        return custom_build_ext
def build_ext ( self ) -> Command : from setuptools . command . build_ext import build_ext buildcfg = self class custom_build_ext ( build_ext ) : def run ( self ) : # Bail out if we don't have the Python include files include_dir = sysconfig . get_path ( 'include' ) if not os . path . isfile ( os . path . join ( include_dir , "Python.h" ) ) : print ( "You will need the Python headers to compile this extension." ) sys . exit ( 1 ) # Check whether the user asked us to discover a pre-built igraph # with pkg-config detected = False if buildcfg . use_pkgconfig : detected = buildcfg . detect_from_pkgconfig ( ) if not detected : print ( "Cannot find the C core of igraph on this system using pkg-config." ) sys . exit ( 1 ) else : # Build the C core from the vendored igraph source self . run_command ( "build_c_core" ) if not buildcfg . c_core_built : # Fall back to an educated guess if everything else failed if not detected : buildcfg . use_educated_guess ( ) # Add any extra library paths if needed; this is needed for the # Appveyor CI build if "IGRAPH_EXTRA_LIBRARY_PATH" in os . environ : buildcfg . library_dirs = ( list ( os . environ [ "IGRAPH_EXTRA_LIBRARY_PATH" ] . split ( os . pathsep ) ) + buildcfg . library_dirs ) # Add extra libraries that may have been specified if "IGRAPH_EXTRA_LIBRARIES" in os . environ : extra_libraries = os . environ [ "IGRAPH_EXTRA_LIBRARIES" ] . split ( "," ) buildcfg . libraries . extend ( extra_libraries ) # Override static specification based on environment variable if "IGRAPH_STATIC_EXTENSION" in os . environ : if os . environ [ "IGRAPH_STATIC_EXTENSION" ] . lower ( ) in [ "true" , "1" , "on" , ] : buildcfg . static_extension = True else : buildcfg . static_extension = False # Replaces library names with full paths to static libraries # where possible. libm.a is excluded because it caused problems # on Sabayon Linux where libm.a is probably not compiled with # -fPIC if buildcfg . static_extension : if buildcfg . static_extension == "only_igraph" : buildcfg . replace_static_libraries ( only = [ "igraph" ] ) else : buildcfg . replace_static_libraries ( exclusions = [ "m" ] ) # Add extra libraries that may have been specified if "IGRAPH_EXTRA_DYNAMIC_LIBRARIES" in os . environ : extra_libraries = os . environ [ "IGRAPH_EXTRA_DYNAMIC_LIBRARIES" ] . split ( "," ) buildcfg . libraries . extend ( extra_libraries ) # Remove C++ standard library as we will use the C++ linker for lib in ( "c++" , "stdc++" ) : if lib in buildcfg . libraries : buildcfg . libraries . remove ( lib ) # Prints basic build information buildcfg . print_build_info ( ) # Find the igraph extension and configure it with the settings # of this build configuration ext = first ( extension for extension in self . extensions if extension . name == "igraph._igraph" ) buildcfg . configure ( ext ) # Run the original build_ext command build_ext . run ( self ) return custom_build_ext