Skip to content

Commit

Permalink
Format with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 27, 2019
1 parent 752e853 commit c27b3f3
Show file tree
Hide file tree
Showing 10 changed files with 543 additions and 623 deletions.
33 changes: 11 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,27 @@
def read(*parts):
# intentionally *not* adding an encoding option to open, See:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
with codecs.open(os.path.join(here, *parts), 'r') as fp:
with codecs.open(os.path.join(here, *parts), "r") as fp:
return fp.read()


def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file,
re.M,
)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)

raise RuntimeError("Unable to find version string.")


long_description = read('README.rst')
long_description = read("README.rst")

setup(
name="pip",
version=find_version("src", "pip", "__init__.py"),
description="The PyPA recommended tool for installing Python packages.",
long_description=long_description,

license='MIT',
license="MIT",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand All @@ -52,17 +47,12 @@ def find_version(*file_paths):
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
url='https://pip.pypa.io/',
keywords='distutils easy_install egg setuptools wheel virtualenv',

author='The pip developers',
author_email='pypa-dev@groups.google.com',

url="https://pip.pypa.io/",
keywords="distutils easy_install egg setuptools wheel virtualenv",
author="The pip developers",
author_email="pypa-dev@groups.google.com",
package_dir={"": "src"},
packages=find_packages(
where="src",
exclude=["contrib", "docs", "tests*", "tasks"],
),
packages=find_packages(where="src", exclude=["contrib", "docs", "tests*", "tasks"]),
package_data={
"pip._vendor.certifi": ["*.pem"],
"pip._vendor.requests": ["*.pem"],
Expand All @@ -74,9 +64,8 @@ def find_version(*file_paths):
"pip=pip._internal.main:main",
"pip%s=pip._internal.main:main" % sys.version_info[:1],
"pip%s.%s=pip._internal.main:main" % sys.version_info[:2],
],
]
},

zip_safe=False,
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*",
)
5 changes: 1 addition & 4 deletions src/pip/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

# We ignore certain warnings from urllib3, since they are not relevant to pip's
# usecases.
from pip._vendor.urllib3.exceptions import (
DependencyWarning,
InsecureRequestWarning,
)
from pip._vendor.urllib3.exceptions import DependencyWarning, InsecureRequestWarning

import pip._internal.utils.inject_securetransport # noqa

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main(args=None):
# Needed for locale.getpreferredencoding(False) to work
# in pip._internal.utils.encoding.auto_decode
try:
locale.setlocale(locale.LC_ALL, '')
locale.setlocale(locale.LC_ALL, "")
except locale.Error as e:
# setlocale can apparently crash if locale are uninitialized
logger.debug("Ignoring error %s when setting locale", e)
Expand Down
11 changes: 6 additions & 5 deletions src/pip/_internal/operations/generate_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ def _generate_metadata_legacy(install_req):
# type: (InstallRequirement) -> None
req_details_str = install_req.name or "from {}".format(install_req.link)
logger.debug(
'Running setup.py (path:%s) egg_info for package %s',
install_req.setup_py_path, req_details_str,
"Running setup.py (path:%s) egg_info for package %s",
install_req.setup_py_path,
req_details_str,
)

# Compose arguments for subprocess call
Expand All @@ -42,9 +43,9 @@ def _generate_metadata_legacy(install_req):
egg_base_option = [] # type: List[str]
if not install_req.editable:
egg_info_dir = os.path.join(
install_req.unpacked_source_directory, 'pip-egg-info',
install_req.unpacked_source_directory, "pip-egg-info"
)
egg_base_option = ['--egg-base', egg_info_dir]
egg_base_option = ["--egg-base", egg_info_dir]

# setuptools complains if the target directory does not exist.
ensure_dir(egg_info_dir)
Expand All @@ -53,7 +54,7 @@ def _generate_metadata_legacy(install_req):
call_subprocess(
base_cmd + ["egg_info"] + egg_base_option,
cwd=install_req.unpacked_source_directory,
command_desc='python setup.py egg_info',
command_desc="python setup.py egg_info",
)


Expand Down
34 changes: 18 additions & 16 deletions src/pip/_internal/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@

def _is_list_of_str(obj):
# type: (Any) -> bool
return (
isinstance(obj, list) and
all(isinstance(item, six.string_types) for item in obj)
return isinstance(obj, list) and all(
isinstance(item, six.string_types) for item in obj
)


def make_pyproject_path(unpacked_source_directory):
# type: (str) -> str
path = os.path.join(unpacked_source_directory, 'pyproject.toml')
path = os.path.join(unpacked_source_directory, "pyproject.toml")

# Python2 __file__ should not be unicode
if six.PY2 and isinstance(path, six.text_type):
Expand All @@ -36,7 +35,7 @@ def load_pyproject_toml(
use_pep517, # type: Optional[bool]
pyproject_toml, # type: str
setup_py, # type: str
req_name # type: str
req_name, # type: str
):
# type: (...) -> Optional[Tuple[List[str], str, List[str]]]
"""Load the pyproject.toml file.
Expand Down Expand Up @@ -86,9 +85,7 @@ def load_pyproject_toml(
raise InstallationError(
"Disabling PEP 517 processing is invalid: "
"project specifies a build backend of {} "
"in pyproject.toml".format(
build_system["build-backend"]
)
"in pyproject.toml".format(build_system["build-backend"])
)
use_pep517 = True

Expand Down Expand Up @@ -136,19 +133,24 @@ def load_pyproject_toml(
# Specifying the build-system table but not the requires key is invalid
if "requires" not in build_system:
raise InstallationError(
error_template.format(package=req_name, reason=(
"it has a 'build-system' table but not "
"'build-system.requires' which is mandatory in the table"
))
error_template.format(
package=req_name,
reason=(
"it has a 'build-system' table but not "
"'build-system.requires' which is mandatory in the table"
),
)
)

# Error out if requires is not a list of strings
requires = build_system["requires"]
if not _is_list_of_str(requires):
raise InstallationError(error_template.format(
package=req_name,
reason="'build-system.requires' is not a list of strings.",
))
raise InstallationError(
error_template.format(
package=req_name,
reason="'build-system.requires' is not a list of strings.",
)
)

backend = build_system.get("build-backend")
check = [] # type: List[str]
Expand Down
Loading

0 comments on commit c27b3f3

Please sign in to comment.