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

Skip to content

setupext: support using environment variables for dependencies #26679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def get_pkg_config():

def pkg_config_setup_extension(
ext, package,
atleast_version=None, alt_exec=None, default_libraries=()):
atleast_version=None, alt_exec=None, envprefix=None, default_libraries=()):
"""Add parameters to the given *ext* for the given *package*."""

# First, try to get the flags from pkg-config.
Expand Down Expand Up @@ -295,6 +295,13 @@ def pkg_config_setup_extension(
conda_env_path = Path(conda_env_path)
ext.include_dirs.append(str(conda_env_path / "Library/include"))
ext.library_dirs.append(str(conda_env_path / "Library/lib"))
elif envprefix:
env_include = os.getenv(envprefix + '_INCLUDE_DIRS')
if env_include:
ext.include_dirs.extend(env_include.split(';'))
env_library_dirs = os.getenv(envprefix + '_LIBRARY_DIRS')
if env_library_dirs:
ext.library_dirs.extend(env_library_dirs.split(';'))

# Default linked libs.
ext.libraries.extend(default_libraries)
Expand Down Expand Up @@ -585,6 +592,7 @@ def add_flags(cls, ext):
ext, 'freetype2',
atleast_version='9.11.3',
alt_exec=['freetype-config'],
envprefix='FREETYPE',
default_libraries=['freetype'])
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system'))
else:
Expand Down Expand Up @@ -755,6 +763,12 @@ class Qhull(SetupPackage):
def add_flags(cls, ext):
if options.get("system_qhull"):
ext.libraries.append("qhull_r")
env_include = os.getenv('QHULL_INCLUDE_DIRS')
if env_include:
ext.include_dirs.extend(env_include.split(';'))
env_library_dirs = os.getenv('QHULL_LIBRARY_DIRS')
if env_library_dirs:
ext.library_dirs.extend(env_library_dirs.split(';'))
else:
cls._extensions_to_update.append(ext)

Expand Down