diff options
44 files changed, 42 insertions, 92 deletions
@@ -15,7 +15,7 @@ # limitations under the License. import sys -from mesonbuild._pathlib import Path +from pathlib import Path # If we're run uninstalled, add the script directory to sys.path to ensure that # we always import the correct mesonbuild modules even if PYTHONPATH is mangled diff --git a/mesonbuild/_pathlib.py b/mesonbuild/_pathlib.py deleted file mode 100644 index aac2a1b..0000000 --- a/mesonbuild/_pathlib.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2020 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import sys -import typing as T - -# Python 3.5 does not have the strict kwarg for resolve and always -# behaves like calling resolve with strict=True in Python 3.6+ -# -# This module emulates the behavior of Python 3.6+ by in Python 3.5 by -# overriding the resolve method with a bit of custom logic -# -# TODO: Drop this module as soon as Python 3.5 support is dropped - -if T.TYPE_CHECKING: - from pathlib import Path -else: - if sys.version_info.major <= 3 and sys.version_info.minor <= 5: - - # Inspired by https://codereview.stackexchange.com/questions/162426/subclassing-pathlib-path - import pathlib - import os - - # Can not directly inherit from pathlib.Path because the __new__ - # operator of pathlib.Path() returns a {Posix,Windows}Path object. - class Path(type(pathlib.Path())): - def resolve(self, strict: bool = False) -> 'Path': - try: - return super().resolve() - except FileNotFoundError: - if strict: - raise - return Path(os.path.normpath(str(self))) - - else: - from pathlib import Path - -from pathlib import PurePath, PureWindowsPath, PurePosixPath diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index a322d5f..b9f175a 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -14,7 +14,7 @@ from collections import OrderedDict from functools import lru_cache -from .._pathlib import Path +from pathlib import Path import enum import json import os diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 15218c1..f79e1f0 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -20,7 +20,7 @@ import subprocess from collections import OrderedDict from enum import Enum, unique import itertools -from .._pathlib import PurePath, Path +from pathlib import PurePath, Path from functools import lru_cache from . import backends diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 6edf36a..6d81e69 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -19,7 +19,7 @@ import xml.dom.minidom import xml.etree.ElementTree as ET import uuid import typing as T -from .._pathlib import Path, PurePath +from pathlib import Path, PurePath from . import backends from .. import build diff --git a/mesonbuild/cmake/client.py b/mesonbuild/cmake/client.py index 8f9456b..eeaab57 100644 --- a/mesonbuild/cmake/client.py +++ b/mesonbuild/cmake/client.py @@ -19,7 +19,7 @@ from .common import CMakeException, CMakeConfiguration, CMakeBuildFile from .. import mlog from contextlib import contextmanager from subprocess import Popen, PIPE, TimeoutExpired -from .._pathlib import Path +from pathlib import Path import typing as T import json diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py index 4bcc4d9..0ec1698 100644 --- a/mesonbuild/cmake/common.py +++ b/mesonbuild/cmake/common.py @@ -17,7 +17,7 @@ from ..mesonlib import MesonException from .. import mlog -from .._pathlib import Path +from pathlib import Path import typing as T language_map = { diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index e11dbe9..19971e3 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -16,7 +16,7 @@ # or an interpreter-based tool. import subprocess as S -from .._pathlib import Path +from pathlib import Path from threading import Thread import typing as T import re diff --git a/mesonbuild/cmake/fileapi.py b/mesonbuild/cmake/fileapi.py index 1b6c30d..ce63219 100644 --- a/mesonbuild/cmake/fileapi.py +++ b/mesonbuild/cmake/fileapi.py @@ -15,7 +15,7 @@ from .common import CMakeException, CMakeBuildFile, CMakeConfiguration import typing as T from .. import mlog -from .._pathlib import Path +from pathlib import Path import json import re diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index e2f11a0..5797c0d 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -27,7 +27,7 @@ from ..mesondata import mesondata from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header from enum import Enum from functools import lru_cache -from .._pathlib import Path +from pathlib import Path import typing as T import re from os import environ diff --git a/mesonbuild/cmake/toolchain.py b/mesonbuild/cmake/toolchain.py index 52d1f10..1870445 100644 --- a/mesonbuild/cmake/toolchain.py +++ b/mesonbuild/cmake/toolchain.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .._pathlib import Path +from pathlib import Path from ..envconfig import CMakeSkipCompilerTest from ..mesonlib import MachineChoice from .common import language_map diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index c6f2b9d..613b4b2 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -21,7 +21,7 @@ from .. import mlog from ..mesonlib import version_compare import typing as T -from .._pathlib import Path +from pathlib import Path import re import json import textwrap diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 036369a..db52951 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .._pathlib import Path +from pathlib import Path import typing as T import subprocess, os diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 3c2c53c..dca09ea 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -28,7 +28,7 @@ import os import re import subprocess import typing as T -from ..._pathlib import Path +from pathlib import Path from ... import arglist from ... import mesonlib diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py index bc16cac..61dee8d 100644 --- a/mesonbuild/compilers/mixins/pgi.py +++ b/mesonbuild/compilers/mixins/pgi.py @@ -16,7 +16,7 @@ import typing as T import os -from ..._pathlib import Path +from pathlib import Path from ..compilers import clike_debug_args, clike_optimization_args diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 4dae12e..310174f 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -16,7 +16,7 @@ from . import mlog, mparser import pickle, os, uuid import sys from itertools import chain -from ._pathlib import PurePath +from pathlib import PurePath from collections import OrderedDict, defaultdict from .mesonlib import ( MesonException, EnvironmentException, MachineChoice, PerMachine, diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 87518e1..d13c3ac 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -27,7 +27,7 @@ import textwrap import platform import typing as T from enum import Enum -from .._pathlib import Path, PurePath +from pathlib import Path, PurePath from .. import mlog from .. import mesonlib diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 404c279..370fa72 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -16,7 +16,7 @@ import os import re import functools import typing as T -from .._pathlib import Path +from pathlib import Path from .. import mlog from .. import mesonlib diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py index 3b2612b..c04e2fc 100644 --- a/mesonbuild/dependencies/cuda.py +++ b/mesonbuild/dependencies/cuda.py @@ -16,7 +16,7 @@ import glob import re import os import typing as T -from .._pathlib import Path +from pathlib import Path from .. import mlog from .. import mesonlib diff --git a/mesonbuild/dependencies/hdf5.py b/mesonbuild/dependencies/hdf5.py index 0d3db39..21f4e71 100644 --- a/mesonbuild/dependencies/hdf5.py +++ b/mesonbuild/dependencies/hdf5.py @@ -19,7 +19,7 @@ import os import re import shutil import subprocess -from .._pathlib import Path +from pathlib import Path from ..mesonlib import OrderedSet, join_args from .base import ( diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index f41abc8..15055aa 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -14,7 +14,7 @@ # This file contains the detection logic for miscellaneous external dependencies. -from .._pathlib import Path +from pathlib import Path import functools import re import sysconfig diff --git a/mesonbuild/dependencies/scalapack.py b/mesonbuild/dependencies/scalapack.py index f8b1ee1..0147e0b 100644 --- a/mesonbuild/dependencies/scalapack.py +++ b/mesonbuild/dependencies/scalapack.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .._pathlib import Path +from pathlib import Path import functools import os import typing as T diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 13d0ba5..95364cd 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -19,7 +19,7 @@ from enum import Enum from . import mesonlib from .mesonlib import EnvironmentException, MachineChoice, PerMachine, split_args from . import mlog -from ._pathlib import Path +from pathlib import Path _T = T.TypeVar('_T') diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 6896a4d..ebf3bff 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -36,7 +36,7 @@ from .modules import ModuleReturnValue, ExtensionModule from .cmake import CMakeInterpreter from .backend.backends import TestProtocol, Backend -from ._pathlib import Path, PurePath +from pathlib import Path, PurePath import os import shutil import uuid diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index aa6afb9..1e58207 100644 --- a/mesonbuild/mcompile.py +++ b/mesonbuild/mcompile.py @@ -21,7 +21,7 @@ import sys import shutil import typing as T from collections import defaultdict -from ._pathlib import Path +from pathlib import Path from . import mlog from . import mesonlib diff --git a/mesonbuild/mdist.py b/mesonbuild/mdist.py index f6ca0c0..6985ca9 100644 --- a/mesonbuild/mdist.py +++ b/mesonbuild/mdist.py @@ -21,7 +21,7 @@ import subprocess import hashlib import json from glob import glob -from ._pathlib import Path +from pathlib import Path from mesonbuild.environment import detect_ninja from mesonbuild.mesonlib import windows_proof_rmtree, MesonException from mesonbuild.wrap import wrap diff --git a/mesonbuild/mesondata.py b/mesonbuild/mesondata.py index b0515c0..d6fb10e 100644 --- a/mesonbuild/mesondata.py +++ b/mesonbuild/mesondata.py @@ -20,7 +20,7 @@ # TODO: Remember to remove this also from tools/gen_data.py -from ._pathlib import Path +from pathlib import Path import typing as T if T.TYPE_CHECKING: diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 352c5ca..0b614ba 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -13,7 +13,7 @@ # limitations under the License. """A library of random helper functionality.""" -from ._pathlib import Path +from pathlib import Path import sys import stat import time diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py index 38954fa..4a38313 100644 --- a/mesonbuild/minit.py +++ b/mesonbuild/minit.py @@ -14,7 +14,7 @@ """Code that creates simple startup projects.""" -from ._pathlib import Path +from pathlib import Path from enum import Enum import subprocess import shutil diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 924a103..d36927f 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -28,7 +28,7 @@ from . import mlog from .backend import backends from .mparser import BaseNode, FunctionNode, ArrayNode, ArgumentNode, StringNode from .interpreter import Interpreter -from ._pathlib import Path, PurePath +from pathlib import Path, PurePath import typing as T import os import argparse diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 46e2de1..4369148 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -19,7 +19,7 @@ import time import platform import typing as T from contextlib import contextmanager -from ._pathlib import Path +from pathlib import Path """This is (mostly) a standalone module used to write logging information about Meson runs. Some output goes to screen, diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py index 85088b7..5ba1e38 100644 --- a/mesonbuild/modules/fs.py +++ b/mesonbuild/modules/fs.py @@ -14,7 +14,7 @@ import typing as T import hashlib -from .._pathlib import Path, PurePath, PureWindowsPath +from pathlib import Path, PurePath, PureWindowsPath from .. import mlog from . import ExtensionModule diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 62e1c15..7e19d71 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -13,7 +13,7 @@ # limitations under the License. import os, types -from .._pathlib import PurePath +from pathlib import PurePath from .. import build from .. import dependencies diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index bb61475..ff0df2f 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -17,7 +17,7 @@ import json import shutil import typing as T -from .._pathlib import Path +from pathlib import Path from .. import mesonlib from ..mesonlib import MachineChoice, MesonException from . import ExtensionModule diff --git a/mesonbuild/modules/unstable_external_project.py b/mesonbuild/modules/unstable_external_project.py index fdc5cbf..7bb761f 100644 --- a/mesonbuild/modules/unstable_external_project.py +++ b/mesonbuild/modules/unstable_external_project.py @@ -13,7 +13,7 @@ # limitations under the License. import os, subprocess, shlex -from .._pathlib import Path +from pathlib import Path import typing as T from . import ExtensionModule, ModuleReturnValue diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py index 20639cb..4ab24d9 100755 --- a/mesonbuild/msubprojects.py +++ b/mesonbuild/msubprojects.py @@ -1,6 +1,6 @@ import os, subprocess import argparse -from ._pathlib import Path +from pathlib import Path from . import mlog from .mesonlib import quiet_git, verbose_git, GitException, Popen_safe, MesonException, windows_proof_rmtree diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 5804303..04c1a57 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -14,7 +14,7 @@ # A tool to run tests in many different ways. -from ._pathlib import Path +from pathlib import Path from collections import deque, namedtuple from copy import deepcopy import argparse diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 1eeb738..6d2b91a 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -28,7 +28,7 @@ import configparser import typing as T import textwrap -from .._pathlib import Path +from pathlib import Path from . import WrapMode from .. import coredata from ..mesonlib import quiet_git, GIT, ProgressBar, MesonException diff --git a/run_meson_command_tests.py b/run_meson_command_tests.py index 1375988..7bc6185 100755 --- a/run_meson_command_tests.py +++ b/run_meson_command_tests.py @@ -19,7 +19,7 @@ import tempfile import unittest import subprocess import zipapp -from mesonbuild._pathlib import Path +from pathlib import Path from mesonbuild.mesonlib import windows_proof_rmtree, python_command, is_windows from mesonbuild.coredata import version as meson_version diff --git a/run_mypy.py b/run_mypy.py index 51b74df..db578be 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -15,7 +15,6 @@ modules = [ 'mesonbuild/wrap', # specific files - 'mesonbuild/_pathlib.py', 'mesonbuild/arglist.py', # 'mesonbuild/coredata.py', 'mesonbuild/dependencies/boost.py', diff --git a/run_project_tests.py b/run_project_tests.py index 8bf6437..37d07cb 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -17,7 +17,7 @@ from concurrent.futures import ProcessPoolExecutor, CancelledError from enum import Enum from io import StringIO -from mesonbuild._pathlib import Path, PurePath +from pathlib import Path, PurePath import argparse import functools import itertools diff --git a/run_tests.py b/run_tests.py index eae7033..0f02636 100755 --- a/run_tests.py +++ b/run_tests.py @@ -25,7 +25,7 @@ import argparse from io import StringIO from enum import Enum from glob import glob -from mesonbuild._pathlib import Path +from pathlib import Path from unittest import mock from mesonbuild import compilers from mesonbuild import dependencies diff --git a/run_unittests.py b/run_unittests.py index d5f7f02..9a3659a 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -40,7 +40,7 @@ from unittest import mock from configparser import ConfigParser from contextlib import contextmanager from glob import glob -from mesonbuild._pathlib import (PurePath, Path) +from pathlib import (PurePath, Path) from distutils.dir_util import copy_tree import typing as T diff --git a/tools/gen_data.py b/tools/gen_data.py index 32a5347..2b84e9c 100755 --- a/tools/gen_data.py +++ b/tools/gen_data.py @@ -79,7 +79,7 @@ def main() -> int: # TODO: Remember to remove this also from tools/gen_data.py - from ._pathlib import Path + from pathlib import Path import typing as T if T.TYPE_CHECKING: |