Skip to content

Commit

Permalink
Merge branch 'master' into remove_legacy_resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMino authored Feb 24, 2021
2 parents 42e64ae + baaf66f commit c48a7f7
Show file tree
Hide file tree
Showing 177 changed files with 2,045 additions and 2,640 deletions.
11 changes: 7 additions & 4 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,30 @@ about: Something is not working correctly.
title: ""
labels: "S: needs triage, type: bug"
issue_body: true # default: true, adds a classic WSYWIG textarea, if on
inputs:
- type: description
body:
- type: markdown
attributes:
value: |
If you're reporting an issue for `--use-feature=2020-resolver`,
use the "Dependency resolver failures / errors" template instead.
- type: description
- type: markdown
attributes:
value: "**Environment**"
- type: input
attributes:
label: pip version
validations:
required: true
- type: input
attributes:
label: Python version
validations:
required: true
- type: input
attributes:
label: OS
validations:
required: true
- type: textarea
attributes:
Expand Down Expand Up @@ -72,7 +75,7 @@ inputs:
Read the [PSF Code of Conduct][CoC] first.
[CoC]: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
choices:
options:
- label: I agree to follow the PSF Code of Conduct
required: true
...
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ repos:
exclude: |
(?x)
^docs/|
^src/pip/_internal/cli|
^src/pip/_internal/commands|
^src/pip/_internal/distributions|
^src/pip/_internal/index|
^src/pip/_internal/models|
^src/pip/_internal/network|
^src/pip/_internal/operations|
^src/pip/_internal/req|
^src/pip/_internal/resolution|
^src/pip/_internal/utils|
^src/pip/_internal/vcs|
^src/pip/_internal/\w+\.py$|
^src/pip/__main__.py$|
Expand All @@ -47,7 +43,6 @@ repos:
^tests/functional/test_install|
# Files in the root of the repository
^setup.py|
^noxfile.py|
# A blank ignore, to avoid merge conflicts later.
^$
Expand All @@ -74,6 +69,7 @@ repos:
- id: mypy
exclude: docs|tests
args: ["--pretty"]
additional_dependencies: ['nox==2020.12.31']

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
Expand Down
8 changes: 2 additions & 6 deletions docs/docs_feedback_sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
from __future__ import annotations

from itertools import chain
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Dict, List, Union

from sphinx.application import Sphinx
from typing import Dict, List, Union

from sphinx.application import Sphinx

DEFAULT_DOC_LINES_THRESHOLD = 250
RST_INDENT = 4
Expand Down
10 changes: 9 additions & 1 deletion docs/html/reference/pip_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,15 @@ You can install local projects by specifying the project path to pip:
During regular installation, pip will copy the entire project directory to a
temporary location and install from there. The exception is that pip will
exclude .tox and .nox directories present in the top level of the project from
being copied.
being copied. This approach is the cause of several performance and correctness
issues, so it is planned that pip 21.3 will change to install directly from the
local project directory. Depending on the build backend used by the project,
this may generate secondary build artifacts in the project directory, such as
the ``.egg-info`` and ``build`` directories in the case of the setuptools
backend.

To opt in to the future behavior, specify the ``--use-feature=in-tree-build``
option in pip's command line.


.. _`editable-installs`:
Expand Down
6 changes: 3 additions & 3 deletions docs/pip_sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class PipOptions(rst.Directive):

def _format_option(self, option, cmd_name=None):
bookmark_line = (
".. _`{cmd_name}_{option._long_opts[0]}`:"
f".. _`{cmd_name}_{option._long_opts[0]}`:"
if cmd_name else
".. _`{option._long_opts[0]}`:"
).format(**locals())
f".. _`{option._long_opts[0]}`:"
)
line = ".. option:: "
if option._short_opts:
line += option._short_opts[0]
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions news/9091.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add a feature ``--use-feature=in-tree-build`` to build local projects in-place
when installing. This is expected to become the default behavior in pip 21.3;
see `Installing from local packages <https://pip.pypa.io/en/stable/user_guide/#installing-from-local-packages>`_
for more information.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
68 changes: 42 additions & 26 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""Automation using nox.
"""

# The following comment should be removed at some point in the future.
# mypy: disallow-untyped-defs=False

import glob
import os
import shutil
import sys
from pathlib import Path
from typing import Iterator, List, Tuple

import nox

# fmt: off
sys.path.append(".")
from tools.automation import release # isort:skip # noqa
sys.path.pop()
# fmt: on

nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ["lint"]
Expand All @@ -34,20 +34,22 @@


def run_with_protected_pip(session, *arguments):
# type: (nox.Session, *str) -> None
"""Do a session.run("pip", *arguments), using a "protected" pip.
This invokes a wrapper script, that forwards calls to original virtualenv
(stable) version, and not the code being tested. This ensures pip being
used is not the code being tested.
"""
env = {"VIRTUAL_ENV": session.virtualenv.location}
# https://github.com/theacodes/nox/pull/377
env = {"VIRTUAL_ENV": session.virtualenv.location} # type: ignore

command = ("python", LOCATIONS["protected-pip"]) + arguments
kwargs = {"env": env, "silent": True}
session.run(*command, **kwargs)
session.run(*command, env=env, silent=True)


def should_update_common_wheels():
# type: () -> bool
# If the cache hasn't been created, create it.
if not os.path.exists(LOCATIONS["common-wheels"]):
return True
Expand All @@ -72,30 +74,34 @@ def should_update_common_wheels():
# -----------------------------------------------------------------------------
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "pypy3"])
def test(session):
# type: (nox.Session) -> None
# Get the common wheels.
if should_update_common_wheels():
# fmt: off
run_with_protected_pip(
session,
"wheel",
"-w", LOCATIONS["common-wheels"],
"-r", REQUIREMENTS["common-wheels"],
)
# fmt: on
else:
msg = (
"Re-using existing common-wheels at {}."
.format(LOCATIONS["common-wheels"])
)
msg = f"Re-using existing common-wheels at {LOCATIONS['common-wheels']}."
session.log(msg)

# Build source distribution
sdist_dir = os.path.join(session.virtualenv.location, "sdist")
# https://github.com/theacodes/nox/pull/377
sdist_dir = os.path.join(session.virtualenv.location, "sdist") # type: ignore
if os.path.exists(sdist_dir):
shutil.rmtree(sdist_dir, ignore_errors=True)

# fmt: off
session.run(
"python", "setup.py", "sdist",
"--formats=zip", "--dist-dir", sdist_dir,
"python", "setup.py", "sdist", "--formats=zip", "--dist-dir", sdist_dir,
silent=True,
)
# fmt: on

generated_files = os.listdir(sdist_dir)
assert len(generated_files) == 1
generated_sdist = os.path.join(sdist_dir, generated_files[0])
Expand All @@ -117,14 +123,17 @@ def test(session):

@nox.session
def docs(session):
# type: (nox.Session) -> None
session.install("-e", ".")
session.install("-r", REQUIREMENTS["docs"])

def get_sphinx_build_command(kind):
# type: (str) -> List[str]
# Having the conf.py in the docs/html is weird but needed because we
# can not use a different configuration directory vs source directory
# on RTD currently. So, we'll pass "-c docs/html" here.
# See https://github.com/rtfd/readthedocs.org/issues/1543.
# fmt: off
return [
"sphinx-build",
"-W",
Expand All @@ -134,13 +143,15 @@ def get_sphinx_build_command(kind):
"docs/" + kind,
"docs/build/" + kind,
]
# fmt: on

session.run(*get_sphinx_build_command("html"))
session.run(*get_sphinx_build_command("man"))


@nox.session
def lint(session):
# type: (nox.Session) -> None
session.install("pre-commit")

if session.posargs:
Expand All @@ -154,18 +165,23 @@ def lint(session):

@nox.session
def vendoring(session):
# type: (nox.Session) -> None
session.install("vendoring>=0.3.0")

if "--upgrade" not in session.posargs:
session.run("vendoring", "sync", ".", "-v")
return

def pinned_requirements(path):
for line in path.read_text().splitlines():
one, two = line.split("==", 1)
# type: (Path) -> Iterator[Tuple[str, str]]
for line in path.read_text().splitlines(keepends=False):
one, sep, two = line.partition("==")
if not sep:
continue
name = one.strip()
version = two.split("#")[0].strip()
yield name, version
version = two.split("#", 1)[0].strip()
if name and version:
yield name, version

vendor_txt = Path("src/pip/_vendor/vendor.txt")
for name, old_version in pinned_requirements(vendor_txt):
Expand Down Expand Up @@ -208,6 +224,7 @@ def pinned_requirements(path):
# -----------------------------------------------------------------------------
@nox.session(name="prepare-release")
def prepare_release(session):
# type: (nox.Session) -> None
version = release.get_version_from_arguments(session)
if not version:
session.error("Usage: nox -s prepare-release -- <version>")
Expand All @@ -219,9 +236,7 @@ def prepare_release(session):
session.log(f"# Updating {AUTHORS_FILE}")
release.generate_authors(AUTHORS_FILE)
if release.modified_files_in_git():
release.commit_file(
session, AUTHORS_FILE, message=f"Update {AUTHORS_FILE}",
)
release.commit_file(session, AUTHORS_FILE, message=f"Update {AUTHORS_FILE}")
else:
session.log(f"# No changes to {AUTHORS_FILE}")

Expand All @@ -243,6 +258,7 @@ def prepare_release(session):

@nox.session(name="build-release")
def build_release(session):
# type: (nox.Session) -> None
version = release.get_version_from_arguments(session)
if not version:
session.error("Usage: nox -s build-release -- YY.N[.P]")
Expand All @@ -267,21 +283,22 @@ def build_release(session):

tmp_dist_paths = (build_dir / p for p in tmp_dists)
session.log(f"# Copying dists from {build_dir}")
os.makedirs('dist', exist_ok=True)
os.makedirs("dist", exist_ok=True)
for dist, final in zip(tmp_dist_paths, tmp_dists):
session.log(f"# Copying {dist} to {final}")
shutil.copy(dist, final)


def build_dists(session):
# type: (nox.Session) -> List[str]
"""Return dists with valid metadata."""
session.log(
"# Check if there's any Git-untracked files before building the wheel",
)

has_forbidden_git_untracked_files = any(
# Don't report the environment this session is running in
not untracked_file.startswith('.nox/build-release/')
not untracked_file.startswith(".nox/build-release/")
for untracked_file in release.get_git_untracked_files()
)
if has_forbidden_git_untracked_files:
Expand All @@ -302,6 +319,7 @@ def build_dists(session):

@nox.session(name="upload-release")
def upload_release(session):
# type: (nox.Session) -> None
version = release.get_version_from_arguments(session)
if not version:
session.error("Usage: nox -s upload-release -- YY.N[.P]")
Expand All @@ -320,15 +338,13 @@ def upload_release(session):
f"Remove dist/ and run 'nox -s build-release -- {version}'"
)
# Sanity check: Make sure the files are correctly named.
distfile_names = map(os.path.basename, distribution_files)
distfile_names = (os.path.basename(fn) for fn in distribution_files)
expected_distribution_files = [
f"pip-{version}-py3-none-any.whl",
f"pip-{version}.tar.gz",
]
if sorted(distfile_names) != sorted(expected_distribution_files):
session.error(
f"Distribution files do not seem to be for {version} release."
)
session.error(f"Distribution files do not seem to be for {version} release.")

session.log("# Upload distributions")
session.run("twine", "upload", *distribution_files)
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ per-file-ignores =
tests/*: B011

[mypy]
follow_imports = silent
ignore_missing_imports = True
disallow_untyped_defs = True
disallow_any_generics = True
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# The following comment should be removed at some point in the future.
# mypy: disallow-untyped-defs=False

import os
import sys

from setuptools import find_packages, setup


def read(rel_path):
# type: (str) -> str
here = os.path.abspath(os.path.dirname(__file__))
# intentionally *not* adding an encoding option to open, See:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
with open(os.path.join(here, rel_path), 'r') as fp:
with open(os.path.join(here, rel_path)) as fp:
return fp.read()


def get_version(rel_path):
# type: (str) -> str
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
# __version__ = "0.9"
Expand Down
Loading

0 comments on commit c48a7f7

Please sign in to comment.