diff options
author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-01-24 00:49:17 +0000 |
---|---|---|
committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-01-24 01:14:45 +0000 |
commit | 5e7b76f786e8a8fbfc3bfa4755033a8d9c2e06d8 (patch) | |
tree | 6af90381dbdde44223e64d973f24455a094544a6 /setuptools/command | |
parent | 99b7b6450f4a71eed229607ccc1b8d567b59bf02 (diff) | |
download | python-setuptools-git-5e7b76f786e8a8fbfc3bfa4755033a8d9c2e06d8.tar.gz |
Replace/move _normalization.path with/to _path.samepath and _path.normpath
Diffstat (limited to 'setuptools/command')
-rw-r--r-- | setuptools/command/develop.py | 22 | ||||
-rw-r--r-- | setuptools/command/editable_wheel.py | 15 |
2 files changed, 21 insertions, 16 deletions
diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 5f9690f6..08ae7f0d 100644 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -6,8 +6,8 @@ import glob import io from setuptools.command.easy_install import easy_install +from setuptools import _path from setuptools import namespaces -from setuptools import _normalization import setuptools @@ -63,20 +63,17 @@ class develop(namespaces.DevelopInstaller, easy_install): if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) - target = _normalization.path(self.egg_base) - egg_path = _normalization.path( - os.path.join(self.install_dir, self.egg_path) - ) - if egg_path != target: + egg_path = os.path.join(self.install_dir, self.egg_path) + if not _path.same_path(egg_path, self.egg_base): raise DistutilsOptionError( "--egg-path must be a relative path from the install" - " directory to " + target + f" directory to {self.egg_base}" ) # Make a distribution for the package's source self.dist = pkg_resources.Distribution( - target, - pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)), + self.egg_base, + pkg_resources.PathMetadata(self.egg_base, os.path.abspath(ei.egg_info)), project_name=ei.egg_name, ) @@ -96,15 +93,16 @@ class develop(namespaces.DevelopInstaller, easy_install): path_to_setup = egg_base.replace(os.sep, '/').rstrip('/') if path_to_setup != os.curdir: path_to_setup = '../' * (path_to_setup.count('/') + 1) - resolved = _normalization.path( + resolved = _path.normpath( os.path.join(install_dir, egg_path, path_to_setup) ) - if resolved != _normalization.path(os.curdir): + curdir = _path.normpath(os.curdir) + if resolved != curdir: raise DistutilsOptionError( "Can't get a consistent path to setup script from" " installation directory", resolved, - _normalization.path(os.curdir), + curdir, ) return path_to_setup diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index 1875641f..a3c7bd79 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -35,7 +35,14 @@ from typing import ( Union, ) -from .. import Command, SetuptoolsDeprecationWarning, errors, namespaces, _normalization +from .. import ( + Command, + SetuptoolsDeprecationWarning, + _normalization, + _path, + errors, + namespaces, +) from ..discovery import find_package_path from ..dist import Distribution from .build_py import build_py as build_py_cls @@ -568,7 +575,7 @@ def _simple_layout( return set(package_dir) in ({}, {""}) parent = os.path.commonpath([_parent_path(k, v) for k, v in layout.items()]) return all( - _normalization.path(Path(parent, *key.split('.'))) == _normalization.path(value) + _path.same_path(Path(parent, *key.split('.')), value) for key, value in layout.items() ) @@ -697,11 +704,11 @@ def _is_nested(pkg: str, pkg_path: str, parent: str, parent_path: str) -> bool: >>> _is_nested("b.a", "path/b/a", "a", "path/a") False """ - norm_pkg_path = _normalization.path(pkg_path) + norm_pkg_path = _path.normpath(pkg_path) rest = pkg.replace(parent, "", 1).strip(".").split(".") return ( pkg.startswith(parent) - and norm_pkg_path == _normalization.path(Path(parent_path, *rest)) + and norm_pkg_path == _path.normpath(Path(parent_path, *rest)) ) |