Commit Graph

111 Commits

Author SHA1 Message Date
Tzu-ping Chung 288bffc43c Unify Python project root detection logic
A Python project root is now defined as containing a pyproject.toml, or
a setup.py (pre-PEP-517 legacy layout). After this patch, this logic
applies to all checks except parse_editable, where we check for setup.py
and setup.cfg instead since non-setuptools PEP 517 projects cannot be
installed as editable right now.
2021-06-19 15:29:04 +08:00
Tzu-ping Chung b38b925400
Merge pull request #9822 from bwoodsend/fix-pip-freeze-git 2021-06-04 18:58:15 +08:00
bwoodsend 8b8fa2bd5f Explicitly recognise SCP-shorthand git remotes. 2021-06-03 17:52:25 +01:00
bwoodsend f533671b0c Fix pip freeze to use modern format for git repos (#9822)
Pip dropped support for `git+ssh@` style requirements (see #7554)
in favour of `git+ssh://` but didn't propagate the change to
 `pip freeze` which resultantly returns invalid requirements.
Fix this behaviour.

Fixes #9625.
2021-06-03 17:45:56 +01:00
Pradyun Gedam ca832b2836
Don't split git references on unicode separators
Previously, maliciously formatted tags could be used to hijack a
commit-based pin. Using the fact that the split here allowed for
all of unicode's whitespace characters as separators -- which git allows
as a part of a tag name -- it is possible to force a different revision
to be installed; if an attacker gains access to the repository.

This change stops splitting the string on unicode characters, by forcing
the splits to happen on newlines and ASCII spaces.
2021-04-24 10:19:03 +01:00
Stéphane Bidoul ecdcfeb8d6 Remove now unused VCS export code 2021-04-03 15:44:00 +02:00
Jon Dufresne 0945809afc Remove typing.TYPE_CHECKING guards
The typing module has been available since Python 3.5. Guarding the
import has been unnecessary since dropping Python 2.

Some guards remain to either:

- Avoid circular imports
- Importing objects that are also guarded by typing.TYPE_CHECKING
- Avoid mypy_extensions dependency
2021-02-19 18:34:21 -08:00
Jon Dufresne a6392bd62e Replace pip._internal.utils.typing with stdlib typing
The stdlib module has been available since Python 3.5 and the
TYPE_CHECKING constant has been available since 3.5.2.

By using stdlib, this removes the need for pip to maintain its own
Python 2 typing compatibility shim.
2021-02-18 19:09:13 -08:00
Tzu-ping Chung 503e6d6f33
Merge pull request #9413 from jdufresne/type-vcs
Complete type annotations for the vcs package
2021-02-18 18:41:03 +08:00
Stéphane Bidoul 78b891a6d1
Remove unused VCS schemes
These schemes without + are support in an ad-hoc fashion in
parse_editable_requirement.
2021-01-18 09:11:08 +01:00
Jon Dufresne c985454b42 Complete type annotations for the vcs package 2021-01-12 18:59:08 -08:00
Pradyun Gedam 9b83654de8
Merge pull request #9331 from sbidoul/7969-revert-sbi
Revert #7969 and fix VCS stdout/stderr capture
2021-01-09 21:09:04 +00:00
Jon Dufresne c513c5e890 Harmonize return type of VersionControl.get_revision in subclasses
Previously, the Subversion subclass violated the parent's type signature
by returning an int, but it is now coerced to a str to match the
expected signature.
2020-12-30 11:25:29 -08:00
Stéphane Bidoul b3d348d6e7
Merge remote-tracking branch 'upstream/master' into 7969-revert-sbi 2020-12-27 17:01:58 +01:00
Stéphane Bidoul 74369e860e
vcs: capture subprocess stdout only 2020-12-27 16:54:57 +01:00
Stéphane Bidoul bcc412c44a
Additional revert of 7969
Revert additional changes that were made
after 7969 and depended on it.
2020-12-27 16:54:57 +01:00
Stéphane Bidoul 6693a71e0a
Revert "Remove show_stdout from run_command args"
This reverts commit 94882fd1ed.
2020-12-27 16:54:56 +01:00
Stéphane Bidoul 6480bed441
Revert "Remove on_returncode parameter from call_subprocess"
This reverts commit ab3ee7191c.
2020-12-27 16:54:56 +01:00
Hugo van Kemenade a3e246f7d0 Cleanup: replace 'from urllib import xyz as urllib_xyz' with import urllib.xyz 2020-12-27 16:18:44 +02:00
Pradyun Gedam 86afa89043
Merge pull request #9361 from jdufresne/f-strings
Use f-strings for simple string formatting
2020-12-26 10:24:18 +00:00
Jon Dufresne cdcf74fb8e Use f-strings for simple string formatting
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.
2020-12-25 16:21:20 -08:00
Jon Dufresne 0b761a164c Harmonize type signature of VersionControl.get_remote_url() subclasses
In the base class, the signature is defined as:

    type: (str) -> str

Further, the docstring says:

    Raises RemoteNotFoundError if the repository does not have a remote
    url configured.

However, some subclasses were returning None instead of raising
RemoteNotFoundError. This violated the type signature and forced calling
code to handle multiple error paradigms.

Now, all subclasses implement the base's signature.

This allowed simplifying some call sites as they can assume None will
not be returned.

This mismatch was noticed while trying to remove "mypy:
disallow-untyped-defs=False" comments.
2020-12-25 13:45:17 -08:00
Jon Dufresne c148bcc1aa Use short Python3 super() syntax 2020-12-24 15:11:51 -08:00
Jon Dufresne f32adaf09b Remove __future__ imports
Unnecessary since dropping Python 2.
2020-12-24 08:38:09 -08:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Pradyun Gedam 25ab172b55
Update linter: isort 2020-09-23 19:52:28 +05:30
Nguyễn Gia Phong cca500f053 Remove unused definitions 2020-09-04 17:37:43 +07:00
Stéphane Bidoul 3aa0c2ed91
Git fetch more aggressively
Before we were fetching only revisions starting with refs/.
Now we also fetch revisions that look like commit that we
don't have locally.
2020-08-30 11:52:06 +02:00
Devesh Kumar Singh ab3ee7191c Remove on_returncode parameter from call_subprocess 2020-05-23 19:13:13 +05:30
Devesh Kumar Singh 94882fd1ed Remove show_stdout from run_command args 2020-05-23 19:13:13 +05:30
Tzu-ping Chung 6e2e74ac29 Normalize path returned by VCS on return 2020-01-15 16:37:05 +08:00
Tzu-ping Chung 85654a9eb8 Minor code formatting and logging 2020-01-14 18:08:00 +08:00
Tzu-ping Chung e0781159c6 Strip the repo root output 2020-01-14 16:40:48 +08:00
Tzu-ping Chung 2d3e8f72e6 Detect all registered VCS and choose inner-most 2020-01-14 00:30:27 +08:00
Stéphane Bidoul (ACSONE) a20395d0db
Be extra safe in caching Git urls
Do not cache in case a branch/tag has the
same name as a commit sha.
2019-11-03 22:54:34 +01:00
Stéphane Bidoul (ACSONE) 9cad519521
Cache wheels built from immutable Git requirements
Cache wheels that are built from Git requirements
that contain an immutable revision (i.e. a sha).
2019-11-03 22:54:33 +01:00
tbeswick f197479dc8 Fixed LF getting converted to CRLF in last commit. 2019-10-11 14:30:30 +13:00
tbeswick f81f3c902c Removed `get_repo_root_dir()`, this functionality is now included in `Git.get_subdirectory()` and `Mercurial.get_subdirectory()`.
Added `find_path_to_setup_from_repo_root()` function to perform the
common parts of `get_subdirectory()`.
2019-10-11 12:27:17 +13:00
tbeswick f7b44a82fe Removed unused import. 2019-10-09 09:45:41 +13:00
tbeswick a0cbe4c440 Fixing bad merge. 2019-10-09 09:11:58 +13:00
TonyBeswick bcbaee7aa5
Merge branch 'master' into master 2019-10-08 18:39:08 +13:00
tbeswick c6906f1a38 - Abstracted out common `get_subdirectory()` code in `Git` and `Mercurial`, adding `get_repo_root_dir()` for the vcs specific code.
- Reverted behaviour of `Git.controls_location()` and `Mercurial.controls_location()` to call the vcs command if the base `VersionControl.controls_location()` doesn't detect the vcs directory.
- Added `log_failed_cmd` argument `VcsSupport.run_command()` to allow vcs commands to be tried without logging errors if they aren't present.
- Corrected indentation.
- Removed `expect_stderr=True` in `test_freeze_mercurial_clone_srcdir` as its not required.
2019-10-08 18:15:22 +13:00
Pradyun Gedam 2eafb0218b
Update all the imports as needed 2019-09-30 11:15:24 +05:30
Maxim Kurnikov 3692097cca add per-file disallow_untyped_defs=False, and set it to True globally 2019-09-29 23:31:15 +02:00
tbeswick b2bae62641 Fixed problem where vcs commands were being called even if they're not installed, causing errors to be logged. 2019-09-25 11:40:38 +12:00
Chris Jerdonek 7783c47131
Hide security-sensitive strings in VCS command log messages (#6890) 2019-08-21 03:22:57 -07:00
Chris Jerdonek 393f626276 Add type annotations to VCS methods passing an url to run_command(). 2019-08-16 16:20:56 -07:00
Pradyun Gedam 537b0fca12
Change isort multi_line_output to 3 2019-07-22 10:15:27 +05:30
Chris Jerdonek 36430e2a43
Merge pull request #6639 from sbidoul/imp_looks_like_hash-sbi
Be stricter in identiying git commit hashes
2019-06-23 08:49:11 -07:00
Stéphane Bidoul (ACSONE) 28fa08688c Be stricter in identiying git commit hashes 2019-06-23 12:00:57 +02:00