Commit Graph

75 Commits

Author SHA1 Message Date
Diego Ramirez 44b3c90bfd
Complete type annotations in pip/_internal/cli
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-06-27 08:36:35 +08:00
Pradyun Gedam 8b521e2cdd Rephrase the warning printed when run as root on Unix
The earlier warning phrasing has some awkwardness and doesn't clearly
explain why this action is potentially harmful. The change from
"you should" to "it is recommended" is also intentional, to take a
different tone.
2021-05-28 11:22:39 +01:00
Winson Luk c6933d5c5d
Add a warning when run as root (e.g., sudo pip) (#9394) 2021-03-06 12:59:39 +00:00
David Hewitt 838988cb44 Build local directories in-place with feature flag 2021-02-22 23:31:47 +00:00
Jon Dufresne 83c596ff70 Blacken src/pip/_internal/cli directory
In autocompletion.py, the should_list_installed boolean expression was
flipped to workaround upstream black bug:

https://github.com/psf/black/issues/1629

The bug makes black fail to stabilize formatting when the list isn't the
last piece of the expression.
2021-02-21 07:29:15 -08: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
Jon Dufresne c148bcc1aa Use short Python3 super() syntax 2020-12-24 15:11:51 -08:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Pradyun Gedam aae52d79b9
Change where the 2020 resolver warning is logged 2020-10-31 03:27:09 +05:30
Pradyun Gedam 0d8acc9000
Flip the switch in the new resolver
- Python 2 doesn't get the new shiny thing.
- Passing --use-deprecated=legacy-resolver uses the deprecated legacy
  resolver.
- Passing --use-feature=2020-resolver is now a no-op, that prints a
  warning that it's going to be removed.
- Using fast-deps without the new resolver will cause a warning to be
  printed.
2020-10-30 23:07:55 +05:30
Pradyun Gedam d012c7d4af
Add a warning to fast-deps with legacy resolver 2020-10-30 07:12:36 +05:30
Pradyun Gedam 385077a944
Factor out logic for determining resolver to use 2020-10-30 07:11:54 +05:30
Nguyễn Gia Phong 6887b0795b Merge usage of download_dir and wheel_download_dir
In every cases, at least one of them is None.  By doing this,
it is also possible to simplify wrapper codes around download_dir.
2020-10-07 13:42:21 +07:00
Pradyun Gedam 58c594c06b
Prepare isort for black 2020-09-23 21:47:47 +05:30
Nguyễn Gia Phong b46576d933 Give batch downloader a separate class 2020-08-12 16:07:27 +07:00
Nguyễn Gia Phong 487d00295c Define RequirementPreparer._session 2020-08-06 18:42:59 +07:00
Chris Hunt f0d4df10eb Propagate lazy_wheel option through RequirementPreparer
Reduces dependence on Candidate (and Resolver (and Factory)).
2020-08-02 18:40:11 -04:00
Chris Hunt e49dcfdc35 Move lazy_wheel warning out of Resolver
This warning just needs to be traced in one place for all commands,
there's no need for the resolver to know about it. Moving the warning
out of the Resolver will make it easier to change how we provide the
option.
2020-08-02 18:40:11 -04:00
Nguyễn Gia Phong 5d15291274 Use lazy wheel to obtain dep info for new resolver 2020-07-21 16:00:34 +07:00
Christopher Hunt 4ba51d2e9c
Merge pull request #8501 from uranusjr/refactor-create-link-collector
Tidy up link collector constructor imports
2020-07-05 21:44:31 -04:00
Pradyun Gedam 79de2c8911
Switch to --use-feature for determining which resolver to use
Also changes all invocations in the tests, to the new flag.
2020-07-03 18:49:56 +05:30
Tzu-ping Chung ec7324fba0 Tidy up link collector constructor imports
make_link_collector() was in self_outdated_check, a module responsible
for checking whether the currently-running pip is outdated, but is
imported by things that has nothing to do with this outdated check. Move
the function to be a class method in LinkCollector so the module
hierarchy makes more sense.
2020-06-26 17:31:28 +08:00
Stéphane Bidoul aa0c167498
Make sure user_supplied is propagated where needed 2020-05-31 18:33:51 +02:00
Stéphane Bidoul b9a19f6be0
Rename is_direct to user_supplied 2020-05-31 18:33:51 +02:00
Stéphane Bidoul a226f65cf5
A constraint is not a top level requirement 2020-05-31 18:33:51 +02:00
Tzu-ping Chung 8facc4cee1 Avoid RequirementSet before reaching the resolver
The RequirementSet implementation conflates requirements incorrectly in
a lot of places. This means the (new) resolver would get incomplete
requirements.

The removes all RequirementSet.add_requirement() calls outside of the
legacy resolver, so the new resolver can get the unmodified list of
requirements specified by the user, allowing for more sophisticated
requirement merging.
2020-05-04 01:24:19 +08:00
Tzu-ping Chung 6db0df928c Move wheel cache out of InstallRequirment 2020-03-30 17:36:03 +08:00
Tzu-ping Chung fc810d7353 Add --unstable-feature=resolver
This introduces a new general option --unstable-feature that can be used
to opt into "preview" features in pip not enabled by default. Currently
the only available feature is "resolver".

A stub resolver interface (which would fail on invocation) is provided
to respond to the flag.

The --unstable-feature option is hidden from --help since the resolver
does not yet work. This suppression should be removed when we release
the resolver for general/public testing.
2020-03-11 18:51:01 +08:00
Jason R. Coombs 6282a307dc 👹 Feed the hobgoblins (delint). 2020-03-06 12:43:10 -05:00
Jason R. Coombs 3511d3d493 Convert the remaining '%' formatters to '.format'. Fixes #6973. 2020-03-06 12:43:03 -05:00
Chris Hunt fd74d0362c Move legacy_resolve to resolution.legacy.resolver
This gives us a concrete place to put the new resolver code and
resolver-specific modules (`resolution.resolver`).

The reason for another level of hierarchy compared to other modules
is to allow us to move other modules here as they
become implementation details of the legacy resolver. Examples I
have in mind are: `req.req_set`, `req.req_install`,
`req.constructors`, and `operations.prepare`.
2020-02-25 09:04:06 -05:00
Paul Moore aac5d821f9 Move make_requirement to pip._internal.req.constructors (and rename it) 2020-02-14 12:22:50 +00:00
Paul Moore 90e4eb3eed Make parse_requirements return a ParsedRequirement 2020-02-14 11:52:53 +00:00
Chris Hunt e7998a3617 Rename populate_requirement_set to get_requirements 2020-02-05 22:30:07 -05:00
Chris Hunt de5ec7e884 Remove unused requirement_set argument 2020-02-05 22:30:07 -05:00
Chris Hunt e872d2bfb6 Make new RequirementSet in populate_requirement_set
Concentrates use of RequirementSet in individual commands so we can
eventually break it up.
2020-02-05 22:30:07 -05:00
Chris Hunt 5dcc562616 Return a list of InstallRequirement from populate_requirement_set
Next we can hide RequirementSet from the setup phase of the individual
commands.
2020-02-05 22:30:07 -05:00
Chris Hunt a814dc9f1f Centralize logic for getting 'all requirements' 2020-02-05 22:29:48 -05:00
Chris Hunt 34df623016 Globally manage EphemWheelCache temp directory 2020-02-04 23:11:25 -05:00
Chris Hunt bdde27bfd8 Add BuildEnvironment._temp_dir to tempdir registry
Similar to the InstallRequirement temp build dir, now we'll be able to
refactor this to be globally managed.
2020-02-04 20:31:34 -05:00
Chris Hunt 2f4bfc3efc Add InstallRequirement._temp_build_dir to tempdir registry
Now we can refactor this to be globally managed, and it will have the
same behavior as it does currently (if there is any
PreviousBuildDirError it will not be cleaned up).
2020-02-04 20:29:26 -05:00
Chris Hunt 7068e58b6f Configure tempdir registry
This mirrors the current logic within the individual requirement-related
commands (install, wheel) for setting options.no_clean, which is used to
determine whether we need to delete directories.

Next, we'll add the actual directories to track and remove them from
being managed by other objects.
2020-02-04 20:22:39 -05:00
Chris Hunt 0b4ec28a39 Centralize addition of no_clean argument
We want to rely on --no-clean being a valid option for
RequirementCommand types, so move it to one place close to the code that
will depend on it.
2020-02-04 20:22:39 -05:00
Stéphane Bidoul (ACSONE) 6fa3a2ee58
Remove redundant cache dir normalization in _build_session
Now the cache is normalized eagerly, this is not necessary here anymore.
assert the path is absolute to prevent regression.
2020-01-08 08:02:29 +01:00
Maxim Kurnikov 58e2a99ccf remove disallow_untyped_defs=False for most of pip._internal.cli modules 2019-12-13 09:58:52 +03:00
Chris Hunt 24d2f1e719 Remove unused arguments 2019-12-05 20:29:43 -05:00
Chris Hunt 7db57478a2 Construct Downloader outside RequirementPreparer
Reduces RequirementPreparer responsibilities, and will let us get rid of
some constructor arguments.
2019-12-05 20:26:53 -05:00
Pradyun Gedam c9606b86e1
Add use_user_site to RequirementPreparer 2019-11-10 13:51:29 +05:30
Pradyun Gedam 0612685e7e
Stop passing require_hashes to Resolver directly 2019-11-10 01:52:03 +05:30