Skip to content

Shorter Path import in setupext. #16871

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

Merged
merged 1 commit into from
Mar 24, 2020
Merged
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
26 changes: 11 additions & 15 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from io import BytesIO
import logging
import os
import pathlib
from pathlib import Path
import platform
import shlex
import shutil
Expand All @@ -32,7 +32,7 @@ def _get_xdg_cache_dir():
cache_dir = os.path.expanduser('~/.cache')
if cache_dir.startswith('~/'): # Expansion failed.
return None
return pathlib.Path(cache_dir, 'matplotlib')
return Path(cache_dir, 'matplotlib')


def _get_hash(data):
Expand Down Expand Up @@ -219,10 +219,9 @@ def pkg_config_setup_extension(
conda_env_path = (os.getenv('CONDA_PREFIX') # conda >= 4.1
or os.getenv('CONDA_DEFAULT_ENV')) # conda < 4.1
if conda_env_path and os.path.isdir(conda_env_path):
ext.include_dirs.append(os.fspath(
pathlib.Path(conda_env_path, "Library/include")))
ext.library_dirs.append(os.fspath(
pathlib.Path(conda_env_path, "Library/lib")))
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"))

# Default linked libs.
ext.libraries.extend(default_libraries)
Expand Down Expand Up @@ -304,7 +303,7 @@ def check(self):

def _pkg_data_helper(pkg, subdir):
"""Glob "lib/$pkg/$subdir/**/*", returning paths relative to "lib/$pkg"."""
base = pathlib.Path("lib", pkg)
base = Path("lib", pkg)
return [str(path.relative_to(base)) for path in (base / subdir).rglob("*")]


Expand Down Expand Up @@ -527,8 +526,7 @@ def add_flags(self, ext):
default_libraries=['freetype'])
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system'))
else:
src_path = pathlib.Path(
'build', f'freetype-{LOCAL_FREETYPE_VERSION}')
src_path = Path('build', f'freetype-{LOCAL_FREETYPE_VERSION}')
# Statically link to the locally-built freetype.
# This is certainly broken on Windows.
ext.include_dirs.insert(0, str(src_path / 'include'))
Expand All @@ -545,7 +543,7 @@ def do_custom_build(self):
if options.get('system_freetype'):
return

src_path = pathlib.Path('build', f'freetype-{LOCAL_FREETYPE_VERSION}')
src_path = Path('build', f'freetype-{LOCAL_FREETYPE_VERSION}')

# We've already built freetype
if sys.platform == 'win32':
Expand Down Expand Up @@ -595,13 +593,11 @@ def do_custom_build(self):
"--with-png=no", "--with-harfbuzz=no"],
env=env, cwd=src_path)
subprocess.check_call(["make"], env=env, cwd=src_path)
else:
# compilation on windows
shutil.rmtree(str(pathlib.Path(src_path, "objs")),
ignore_errors=True)
else: # compilation on windows
shutil.rmtree(src_path / "objs", ignore_errors=True)
msbuild_platform = (
'x64' if platform.architecture()[0] == '64bit' else 'Win32')
base_path = pathlib.Path("build/freetype-2.6.1/builds/windows")
base_path = Path("build/freetype-2.6.1/builds/windows")
vc = 'vc2010'
sln_path = (
base_path / vc / "freetype.sln"
Expand Down