Commit Graph

187 Commits

Author SHA1 Message Date
Damian Shaw 68529081c2
Enforce f-strings via Ruff (#12393) 2023-11-07 09:14:56 +00:00
Stéphane Bidoul 8f0ed32413 Redact URLs in Collecting... logs 2023-10-14 14:02:55 +02:00
Danny McClanahan 454e9768fb
incorporate review comments 2023-07-28 02:43:49 -04:00
Danny McClanahan eabefd4021
revert the traceback wrapping 2023-07-28 02:18:36 -04:00
Danny McClanahan eeb3d8fdff
synthesize a traceback to get a normal exc_info from an exception
- as per https://docs.python.org/3.12/whatsnew/3.12.html#shutil, we must expect only an exception
  and *not* the full exc_info from the new onexc function (the documentation of this is very
  misleading and still uses the label "excinfo":
  https://docs.python.org/3.12/library/shutil.html#shutil.rmtree)
2023-07-28 01:00:06 -04:00
Ales Erjavec 4ff65abdf7 Fix 'force' remove file without write permissions
Preserve existing mode flags, handle case where we even lack
permission to change the mode.
2023-07-17 15:15:41 +02:00
Ales Erjavec 660dafb37f Ignore errors in temporary directory cleanup
pip should not exit with an error when it fails to cleanup temporary
files after it has already successfully installed packages.
2023-07-17 15:15:41 +02:00
Shantanu 593b85f4ab
Use strict optional checking in misc.py (#11382) 2023-07-17 10:40:25 +01:00
Greg Roodt 9b47bc0fea Make black formatter happy 2023-07-10 22:04:46 +10:00
Greg Roodt 25f4e6eabf Fix deprecation warnings in Python 3.12 for usage of shutil.rmtree 2023-07-10 21:59:42 +10:00
Stéphane Bidoul 123e8a4c59
Merge pull request #11871 from sbidoul/always-use-pep517-when-wheel-absent-sbi
Always use pep 517 when the 'wheel' package is absent
2023-03-27 16:21:04 +02:00
Stéphane Bidoul 82f1ff0adb Fix type of config_settings arguments 2023-03-27 14:01:36 +02:00
Stéphane Bidoul 8a1a8d7915 Always use pep 517 when the 'wheel' package is absent 2023-03-27 11:55:20 +01:00
Tzu-ping Chung 095fd850fd Isolate EXTERNALLY-MANAGED parsing logic
This makes the parser easier to test.
2023-01-03 07:57:21 +08:00
Tzu-ping Chung e27a819883 Use ExternallyManagedEnvironment to show error
This moves most of the displaying logic into the exception class so it
can better leverage DiagnosticPipError and Rich functionalities.
2023-01-03 07:57:21 +08:00
Tzu-ping Chung 69cb3f8617 Check EXTERNALLY-MANAGED in install and uninstall
This implements the PEP 668 logic to 'pip install' and 'pip uninstall'.
Are there any other commands that may need it?

This implementation disables the check is any of --prefix, --home, or
--target is provided, since those can indicate the command does not
actually install into the environment. Note that it is still possible
the command is still modifying the environment, but we don't have a
way to stop the user *that* determined to break the environment anyway
(they can always just use those flags in a virtual environment).

Also not sure how best this can be tested.
2023-01-03 07:57:21 +08:00
Pradyun Gedam fa4b2efbab
Replace `pep517` with `pyproject_hooks`
The `pep517` package has been superseded by a new package.
2022-12-28 20:13:57 +00:00
Paul Moore 6da9b5c694 Call the PEP 517 backend with the requirement's config settings 2022-04-21 18:30:48 +01:00
q0w 3820b0e52c
Replace Iterator[T] with Generator[T,None, None] (#11007)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2022-04-09 16:11:58 +01:00
Pradyun Gedam 4912fdfa41
Use f-strings for executable names 2022-03-13 08:07:07 +00:00
Pradyun Gedam ce30e6c532
Fix the protect-pip-on-windows logic
The names for the executables does not contain a `.exe` suffix anymore.
2022-02-26 12:32:52 +00:00
Tzu-ping Chung cd01e4fd8f Remove pkg_resources usages from utils modules
Relevant functionalities are moved into pip._internal.metadata.
2021-12-04 17:57:33 +08:00
Stéphane Bidoul 2de1e5b1bf
Remove egg_link_path() 2021-09-21 11:18:02 +02:00
Stéphane Bidoul 5fa413d363
Extract egg_link* function to a separate module 2021-09-21 11:18:02 +02:00
Stéphane Bidoul d051a00fc5
Remove unused get_installed_distributions 2021-09-21 11:18:01 +02:00
Stéphane Bidoul 0fe8182363
Add PEP 610 editables support to BaseDistribution
Look for the editable flag in direct_url.json,
and fall back to the .egg-link search if there is
no direct_url.json.
2021-09-21 11:18:00 +02:00
Stéphane Bidoul 5d4ed8cced
Refactor egg_link_path/dist_is_editable
Make them work without using pkg_resource.
2021-09-21 11:18:00 +02:00
Jon Dufresne 44a034a131 Move all remaining type comments to annotations
Use the com2ann tool to convert remaining comments to annotations. Now,
no type comments remain.

https://github.com/ilevkivskyi/com2ann

Some types are not available at runtime (e.g. Literal) or require a
forward reference and so were quoted.
2021-08-27 19:02:57 -07:00
Jon Dufresne 973ac6a700 Replace AnyStr with str in src/pip/_internal/utils/misc.py
Using AnyStr previously existed as a Python 2 compatibility shim, but it
is no longer necessary.
2021-08-09 16:51:32 -07:00
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
Dirk Stolle b8e7a70fd5
Fix typos (#10001) 2021-06-03 16:44:42 +02:00
Tzu-ping Chung 1904e4d66d Relax installable dir check to allow cfg-only 2021-05-18 02:47:56 +08:00
Tzu-ping Chung 5457c6f399
Merge branch 'main' into switch-to-tenacity 2021-04-03 23:31:48 +08:00
Andrey Bienkowski 622f104694 Use f-strings for formatting
suggested by pyupgrade --py36-plus
2021-03-30 15:48:27 +03:00
Andrey Bienkowski cd7b50277e Use f-strings for formatting 2021-03-29 10:37:24 +03:00
Jon Dufresne 63ea2e8c08 Handle several mypy TODO comments and exceptions
Remove mypy exceptions that are straightforward to remove.
2021-02-22 16:53:54 -08:00
Jon Dufresne a9d4446dc4 Blacken src/pip/_internal/utils directory 2021-02-21 07:24:35 -08:00
cjc7373 64ecfc8476 switch from 'retrying' to 'tenacity' 2021-02-21 09:04:27 +08:00
Pradyun Gedam 8a949a1c52
Merge pull request #9415 from jdufresne/path_to_display
Remove Python 2 compat shim path_to_display()
2021-02-20 13:22:43 +00: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 3f6df167e0 Remove Python 2 compat shim path_to_display()
Per the function's type signature, this accepted either a str or None.
In both cases, the value was returned unaltered. Since dropping Python
2, it has been unnecessary.
2021-02-19 05:45:59 -08:00
Tzu-ping Chung 383934eb83 Incorporate get_installed_version() logic
All usages of it now use Environment.get_distribution() instead.

InstallRequirement.installed_version is also removed since it is no
longer used anywhere in the code base.
2021-02-19 13:34:16 +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 7afe0a7cd2
Merge pull request #8114 from uranusjr/importlib-metadata 2021-02-03 21:15:02 +08:00
Paul Moore 6739f56351 Use our own copy of strtobool, rather than the one from distutils 2021-01-20 15:42:29 +00:00
Tzu-ping Chung 11e37aa6e1 Separate default and ad-hoc environment APIs
pkg_resources performs annoying caching that needs to be worked around
in some parts of pip. This makes it easier to represent the difference
between environments backend by WorkingSet() and working_set.
2021-01-19 14:42:55 +08:00
Tzu-ping Chung 349bb730de Move dist-related logic from misc into metadata 2021-01-19 14:42:55 +08:00
Jon Dufresne 004b2cf9a8 Remove unused utility function consume()
Unused since e706af20fe.
2021-01-01 16:07:53 -08:00
Jon Dufresne 5150129f6b Replace compat.expanduser() with os.path.expanduser()
The upstream bug has been fixed and released in all supported Python
version: https://bugs.python.org/issue14768
2020-12-29 08:15:55 -08:00
Jon Dufresne b78f71216f Remove unnecessary "noqa" comments 2020-12-28 18:19:09 -08:00