Commit Graph

198 Commits

Author SHA1 Message Date
Tzu-ping Chung be60eaaa4f Uninstall existing dist before reinstallation 2020-04-08 17:17:25 +08:00
Tzu-ping Chung 90ce7c9edd Refactor to prepare for upgrade procedures 2020-04-08 17:17:25 +08:00
Tzu-ping Chung 591d476fca Note on why we don't implement equality 2020-04-08 16:38:47 +08:00
Tzu-ping Chung 018c051a8e Implement equality on candidate classes 2020-04-08 16:38:47 +08:00
Paul Moore bd912cf0de
Merge pull request #7993 from uranusjr/new-resolver-normal-test-progress
Canonicalise project name from InstallationCandidate
2020-04-08 09:12:50 +01:00
Tzu-ping Chung 6d40804b12 Add __repr__ to requirement/candidate models 2020-04-07 20:53:25 +08:00
Tzu-ping Chung b89e1c2fb4 Canonicalize InstallationCandidate name
Caught by test_single_download_from_requirements_file etc.
2020-04-07 19:05:26 +08:00
Tzu-ping Chung 2f36ac7587 Add assertion message for easier debugging 2020-04-07 19:02:17 +08:00
Tzu-ping Chung 74c5042052 Accept InsatllRequirement as comes_from 2020-04-05 12:17:25 +08:00
Tzu-ping Chung aead201fda No need to think about editable for installed dist 2020-04-04 21:53:04 +08:00
Tzu-ping Chung 05f7dbd0c8 Type hint hacks 2020-04-04 18:15:26 +08:00
Tzu-ping Chung 2430aba879 Implement editable candidate 2020-04-04 17:51:43 +08:00
Tzu-ping Chung 3b06cb6b53 Refactor ireq-related operations to base class 2020-04-03 21:33:16 +08:00
Paul Moore d53d3d6b24 Use the name/version from the InstallationCandidate 2020-04-03 11:23:35 +01:00
Tzu-ping Chung 7511737ee7 AlreadyInstalledCandidate 2020-04-03 01:27:34 +08:00
Tzu-ping Chung f061f3f691 Fetch install dist for a candidate if available
The candidate creation logic is further moved into the factory. The
factory would use pkg_resources.get_distribution() to find a matching
distribution for a givan InstallationCandidate. If found, the Candidate
would be created based on that found distribution, instead of the link.

--ignore-installed is implemented as to always use the link to create
candidates, even if an installed distribution is found.
2020-04-03 00:36:26 +08:00
Tzu-ping Chung 9ca2240530 More clarification on the name 2020-04-02 21:42:29 +08:00
Tzu-ping Chung 65ffd338f4 Explain how Requires-Python matching works 2020-04-02 19:02:20 +08:00
Tzu-ping Chung 190c424b1e Implement Python as a dependency
If a dist contains Requires-Python metadata, it is converted into a
Requirement for the resolver based on whether the Requires-Python
is compatible or not.

If it is compatible, an ExplicitRequirement is returned to hold the
Python information (either sys.version_info, or the user-supplied
--python-version).

If it is incompatible, a special NoMatchRequirement is returned, which
never matches to anything, generating a ResolutionImpossible to report
the Python version incompatibility.

The --ignore-requires-python flag is implemented as to not return a
Requirement for Requires-Python at all.
2020-04-02 18:36:08 +08:00
Tzu-ping Chung d29c86af98 Add method to create requirement from spec 2020-04-01 16:53:39 +08:00
Tzu-ping Chung 4491f38047 Return Requirement directly from get_dependencies
This is possible now we have the factory construct.
2020-04-01 15:31:52 +08:00
Tzu-ping Chung e06048cb8b Aggregate helper usages into factory object
This prevents us from having to hold multiple references of
finder/preparer/make_install_req in each requirement/candidate class.
Instead we just pass around the factory object, and let others use the
instances on it.
2020-04-01 15:31:52 +08:00
Tzu-ping Chung 6db0df928c Move wheel cache out of InstallRequirment 2020-03-30 17:36:03 +08:00
Tzu-ping Chung 4ae50f9af7 Remove unused preparer from SpecifierRequirement 2020-03-27 19:00:27 +08:00
Tzu-ping Chung 07563847b0 Decouple candidate and requirement modules
This introduces a new module "factory" that contains all methods dealing
with producing candidates/requirements from an input
requirement/candidate. This allows both models to know nothing about
each other, and simply rely on the intermediate to produce the other.

I *believe* this also helps us reduce merge conflicts due to adding
arguments to those producer functions, since now we only need to modify
the factory, and exactly one of candidate/requirement.

This is only part of a big scheme--the plan is to also move
Candidate.get_dependencies() and Requirement.find_matches() into the
factory class, so they can avoid holding and passing around finder,
preparer, and make_install_req. This is also necessary to change the
return type of Candidate.get_dependencies() to Requirement without
hard-coupling.
2020-03-27 03:14:51 +08:00
Paul Moore fea9766fa2 Merge branch 'master' into new_resolver_extras 2020-03-26 15:49:43 +00:00
Paul Moore a68345e81c Warn if invalid extras are given 2020-03-26 14:53:24 +00:00
Paul Moore 7e97cf6426 Ignore invalid extras 2020-03-26 11:57:34 +00:00
Paul Moore 67bf5890ea Document the ExtrasCandidate class 2020-03-26 11:56:46 +00:00
Paul Moore ffb56db5dd Allow candidates to not have an associated install requirement 2020-03-26 11:19:10 +00:00
Paul Moore d79aacc61c Forgot to run lint before pushing again :-( 2020-03-25 12:39:21 +00:00
Paul Moore bd0f7fe346 Add an ExtrasCandidate class 2020-03-25 12:27:24 +00:00
Paul Moore 76de49bc24 Make a proper get_install_requirement method for candidates 2020-03-25 12:27:24 +00:00
Tzu-ping Chung 3cb7a08f0d Implement ignore_dependencies in new resolver
If this flag is set, simply report every candidate has no dependencies.
2020-03-24 02:02:36 +08:00
Tzu-ping Chung 5af542ccac Use named arguments for clarity 2020-03-24 02:00:08 +08:00
Tzu-ping Chung ff35f7f26a Remove stale TODO comment 2020-03-23 17:15:55 +08:00
Paul Moore c83505b848 Remove an obsolete comment 2020-03-20 13:57:45 +00:00
Paul Moore ffe553638c Address review requirements 2020-03-19 10:55:33 +00:00
Paul Moore a23e936bc7 Ensure candidate name is canonicalised 2020-03-18 14:54:15 +00:00
Paul Moore f1b4be892a Fix bug in get_dependencies() passing Requirement object rather than string 2020-03-18 14:53:04 +00:00
Paul Moore 1ebe1e0935 Integrate the new provider with --unstable-feature=resolver 2020-03-18 14:49:49 +00:00
Paul Moore 7d2eb544b5 Implement PipProvider 2020-03-18 14:42:16 +00:00
Tzu-ping Chung dad77a9e4d Better handle root vetices in graph
ResolveLib *should* always produce a graph with only one root vertice,
which is None. But we don't really need to rely on that implementation
detail. Vertices without any parents can be assigned 0 in all cases.
2020-03-15 23:01:58 +08:00
Tzu-ping Chung ffb3692e00 Add simple tests for get_installation_order()
The implementation is improved a bit to make the sorting result more
predictable for easier testing.
2020-03-15 23:01:57 +08:00
Tzu-ping Chung 53775279c4 Fix graph-walking terminal condition
The weight mapping should have size `len(packages) + 1` because it needs
to contain a "sentinel" node (None).
2020-03-15 22:25:26 +08:00
Tzu-ping Chung a3f6c17d36 Implement resolver methods on provider interface
This is using a temporary PipProvider class, which should be replaced by
the actual implementation after it is merged.
2020-03-15 15:25:38 +08:00
Paul Moore 9b10b93503 Implement the resolvelib Requirement class 2020-03-11 11:37:56 +00: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