Skip to content

Commit 65b80e8

Browse files
committed
Shorter Path import in setupext.
Now that there's no `class Path` in setupext anymore, we can just do `from pathlib import Path`.
1 parent 382be60 commit 65b80e8

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

setupext.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from io import BytesIO
88
import logging
99
import os
10-
import pathlib
10+
from pathlib import Path
1111
import platform
1212
import shlex
1313
import shutil
@@ -32,7 +32,7 @@ def _get_xdg_cache_dir():
3232
cache_dir = os.path.expanduser('~/.cache')
3333
if cache_dir.startswith('~/'): # Expansion failed.
3434
return None
35-
return pathlib.Path(cache_dir, 'matplotlib')
35+
return Path(cache_dir, 'matplotlib')
3636

3737

3838
def _get_hash(data):
@@ -219,10 +219,9 @@ def pkg_config_setup_extension(
219219
conda_env_path = (os.getenv('CONDA_PREFIX') # conda >= 4.1
220220
or os.getenv('CONDA_DEFAULT_ENV')) # conda < 4.1
221221
if conda_env_path and os.path.isdir(conda_env_path):
222-
ext.include_dirs.append(os.fspath(
223-
pathlib.Path(conda_env_path, "Library/include")))
224-
ext.library_dirs.append(os.fspath(
225-
pathlib.Path(conda_env_path, "Library/lib")))
222+
conda_env_path = Path(conda_env_path)
223+
ext.include_dirs.append(str(conda_env_path / "Library/include"))
224+
ext.library_dirs.append(str(conda_env_path / "Library/lib"))
226225

227226
# Default linked libs.
228227
ext.libraries.extend(default_libraries)
@@ -304,7 +303,7 @@ def check(self):
304303

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

310309

@@ -527,8 +526,7 @@ def add_flags(self, ext):
527526
default_libraries=['freetype'])
528527
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system'))
529528
else:
530-
src_path = pathlib.Path(
531-
'build', f'freetype-{LOCAL_FREETYPE_VERSION}')
529+
src_path = Path('build', f'freetype-{LOCAL_FREETYPE_VERSION}')
532530
# Statically link to the locally-built freetype.
533531
# This is certainly broken on Windows.
534532
ext.include_dirs.insert(0, str(src_path / 'include'))
@@ -545,7 +543,7 @@ def do_custom_build(self):
545543
if options.get('system_freetype'):
546544
return
547545

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

550548
# We've already built freetype
551549
if sys.platform == 'win32':
@@ -595,13 +593,11 @@ def do_custom_build(self):
595593
"--with-png=no", "--with-harfbuzz=no"],
596594
env=env, cwd=src_path)
597595
subprocess.check_call(["make"], env=env, cwd=src_path)
598-
else:
599-
# compilation on windows
600-
shutil.rmtree(str(pathlib.Path(src_path, "objs")),
601-
ignore_errors=True)
596+
else: # compilation on windows
597+
shutil.rmtree(str(Path(src_path, "objs")), ignore_errors=True)
602598
msbuild_platform = (
603599
'x64' if platform.architecture()[0] == '64bit' else 'Win32')
604-
base_path = pathlib.Path("build/freetype-2.6.1/builds/windows")
600+
base_path = Path("build/freetype-2.6.1/builds/windows")
605601
vc = 'vc2010'
606602
sln_path = (
607603
base_path / vc / "freetype.sln"

0 commit comments

Comments
 (0)