shlex.split, used to split options in requirements.txt files, might
raise a ValueError when the input string is not well formed. Catch the
ValueError and re-raise it as a RequirementsFileParseError instead.
The pip-specific Path implementation has been removed, and all its
usages replaced by pathlib.Path. The tmpdir and tmpdir_factory fixtures
are also removed, and all usages are replaced by tmp_path and
tmp_path_factory, which use pathlib.Path.
The pip() function now also accepts pathlib.Path so we don't need to put
str() everywhere. Path arguments are coerced with os.fspath() into str.
The pretend library was used by very few tests. In all cases, it is
simple enough to switch to stdlib unitest.mock.
Using stdlib means there is one fewer library to install before running
tests. It can also simplify mypy usage via typeshed.
Functions like urllib.parse.urlsplit() parses a file:// URL created from
a non-UNC Windows absolute path with a leading slash in the path
component:
>>> from pathlib import Path
>>> from urllib.parse import urlsplit
>>> path = Path("C:/Users/VssAdministrator")
>>> parsed = urlsplit(path.as_posix())
>>> parsed.path
'/C:/Users/VssAdministrator'
This value unfortunately does not play well with path functions like
open(), so we performs some additional cleanup to strip that leading
slash.
This commit also contains some minor cleanup to unify how Windows is
detected, and how a file:// URL is fetched.
Rust is becoming more popular for writing Python extension modules in, this information would be valuable for package maintainers to assess the ecosystem, in the same way glibc or openssl version is.
Use pyupgrade to convert simple string formatting to use f-string
syntax. pyupgrade is intentionally timid and will not create an f-string
if it would make the expression longer or if the substitution parameters
are anything but simple names or dotted names.
We explicitly propagate --use-feature options from req files upwards.
This is not strictly necessary for the option to be enabled, because
of the default value is a global list, but that implicit behaviour is
certainly accidental, so we make it explicit, with a test.
This patch adds support for `--use-feature` in requirements files
so that a project that wants all contributors using the same pip
features can specify it in the requirements file. For example, to ensure
a requirements file uses the new resolver:
```
--use-feature=2020-resolver
boto3
boto3==1.13.13
```
This is a new version of #8293.