1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
Commit graph

2047 commits

Author SHA1 Message Date
Chris Hunt 77dbd27703 Customize interpreter for packaging.tags.generic_tags 2020-01-07 19:00:23 -05:00
Chris Hunt 281273dac3 Use packaging.tags.generic_tags
As with cpython_tags and compatible_tags, we assume this function covers
our use cases in the no-argument case and will customize our arguments
for it in a few steps.
2020-01-07 19:00:18 -05:00
Chris Hunt fa1ec40ce0 Remove unused abi3 branch in _generic_tags
Since this function is only called for non-CPython interpreters, the
abi3-related branches are not relevant.
2020-01-07 19:00:14 -05:00
Chris Hunt 1574872162 Inline packaging.tags.cpython_tags 2020-01-07 19:00:09 -05:00
Chris Hunt 56840c30c5 Make packaging.tags.cpython_tags unconditional 2020-01-07 19:00:04 -05:00
Chris Hunt fecfadb810 Customize platforms for packaging.tags.cpython_tags 2020-01-07 19:00:00 -05:00
Chris Hunt 05045e7903 Customize abis for packaging.tags.cpython_tags 2020-01-07 18:59:55 -05:00
Chris Hunt 147680a613 Customize python_version for packaging.tags.cpython_tags 2020-01-07 18:59:50 -05:00
Chris Hunt 5dbef5debe Use packaging.tags.cpython_tags
We assume this function improves the status quo over the current
`_cpython_tags`, so we use it when no arguments need to be customized.

Since `packaging.tags` has its own tests and derives defaults
differently than pep425tags, we also remove the applicable tests that
were testing against the result of a plain call to
`pep425tags.get_supported()`.
2020-01-07 18:59:44 -05:00
Chris Hunt e388df6c59 Remove impl from _cpython_tags
We only call this function when the user or platform-provided
implementation is "cp", so we can inline the literal in place of the
parameter. This will make refactoring easier.
2020-01-07 18:57:55 -05:00
Chris Hunt 8f1c60ead0 Only use _cpython_tags for CPython
Since the behavior for both of these functions is the same, there is no
behavior change here. This will let us simplify `_cpython_tags` a bit.
2020-01-07 18:57:50 -05:00
Chris Hunt b91286c38d Inline packaging.tags.compatible_tags 2020-01-07 18:57:45 -05:00
Chris Hunt c514c6b35f Make packaging.tags.compatible_tags unconditional 2020-01-07 18:57:41 -05:00
Chris Hunt 2de0b7c560 Customize platforms for packaging.tags.compatible_tags 2020-01-07 18:57:36 -05:00
Chris Hunt 72d00ddcc1 Customize interpreter for packaging.tags.compatible_tags 2020-01-07 18:57:31 -05:00
Chris Hunt 750abcab04 Customize python_version for packaging.tags.compatible_tags 2020-01-07 18:57:26 -05:00
Chris Hunt 4659a78935 Use packaging.tags.compatible_tags
We assume this function improves on our existing behavior, so use it
as-is. We will customize the arguments over the next few commits.

Since packaging.tags internally calculates platforms when not provided,
we skip the tests which patch functions assuming that manylinux
compatibility determination depends on them.
2020-01-07 18:55:26 -05:00
Chris Hunt 480911bc8e Remove unused abi arg from _compatible_tags 2020-01-07 17:00:40 -05:00
Chris Hunt 1c8c481214 Only calculate py-compatible tags in one place
Since `_compatible_tags` is the function that will be responsible for
generating the non-interpreter-specific tags, we remove the
corresponding sections from `_cpython_tags` and `_generic_tags`. The
resulting tags in `get_supported` are equivalent because these were
the last tags to be computed in those functions, and `_compatible_tags`
is executed after them (so any non-duplicate tags it produces will be
last).

To reinforce the reponsibility of `_compatible_tags` we also remove the
abi-related tag generation, which is already handled in `_cpython_tags`
and `_generic_tags`.
2020-01-07 17:00:40 -05:00
Chris Hunt 54db17c976 Use _cpython_tags, _generic_tags, and _compatible_tags
Since these functions are copies of the existing code, there is no
behavior change except each tag will now be present 3 times. To
accommodate this we remove all but the first duplicate tag from the
set of all tags.

We put `_compatible_tags` last because it will provide the lowest
priority tags. The order of `_cpython_tags` and `_generic_tags`
here is not significant - when we start customizing them we will
introduce a condition so that they are mutually exclusive.
2020-01-07 17:00:40 -05:00
Chris Hunt d386bb2fff Copy get_supported into packaging.tags-like functions
packaging.tags provides a simple `sys_tags` function for getting
applicable tags for the running interpreter, but it does not allow
customization of arguments.

packaging.tags provides three functions for getting custom tags:

1. `cpython_tags` - for CPython only
2. `generic_tags` - for any non-CPython Python implementation
3. `compatible_tags` - tags that are not specific to an interpreter
   implementation

Since pip allows users to provide explicit impl, platform, abi, and
version, we have to use these functions.

`cpython_tags` and `generic_tags` are mutually exclusive, and return tags
that are the highest priority. These capture the most specific tags.

`compatible_tags` are always applicable, and a lower priority since they
may just be compatible with e.g. the Python language version, but lack
any optimizations available in the interpreter-specific tags.

To be able to do a meaningful comparison between our current
implementation and the above functions, we need to segment the pip code
into pieces that look like them.

To that end, we now have copies of the current `get_supported` function,
one for each of the functions provided by packaging.tags, and will walk
through converting them to rely on packaging.tags. For each
simplification step, if desired, we can compare the implementation in
the packaging.tags function with what we're replacing in pip.

Specifically, for each function in turn, we will:

1. Refactor it locally, taking into account its new, more limited,
   responsibilities
2. Introduce the packaging.tags function for the case where there are no
   custom arguments provided
3. Customize arguments one-by-one and delegate to the packaging.tags
   function
4. When there is no pip-specific logic left, remove the intermediate
   function and use the packaging.tags function directly in
   `get_supported`

In the end all these functions will be gone again and we'll be left with
an implementation that relies solely on the tag generation in
packaging.tags.
2020-01-07 17:00:40 -05:00
Chris Hunt 3ada01fb51 Convert return values in pep425tags.get_supported
Now we can incrementally use utility functions from pep425tags without
switching everything at once or converting in multiple places.
2020-01-07 17:00:40 -05:00
Tzu-ping Chung 1ea7a05df6 One more found by grepping 2020-01-07 20:49:55 +05:30
Tzu-ping Chung 555d05ce0d Use logger to log instead of logging 2020-01-07 20:40:36 +05:30
Xavier Fernandez 9c64c82186
Merge pull request #7561 from chrahunt/maint/use-packaging-tags-mac-versions
Switch to packaging.tags.mac_version for macOS wheel tag backfilling
2020-01-07 14:39:01 +01:00
Pradyun Gedam 52309f98d1
Merge pull request #7532 from uranusjr/pip-upgrade-prompt-message
Use sys.executable to format upgrade message
2020-01-07 12:34:54 +00:00
Pradyun Gedam ea27521359
Custom optparse.Option type that calls expanduser (#7534) 2020-01-07 12:26:38 +00:00
Pradyun Gedam 6c515125c2
Merge pradyunsg:revert/6864 into master (#7557)
Revert addition of un-suffixed pip CLI entry points for invocation check on Windows
2020-01-07 08:16:38 +00:00
Chris Hunt bc20a983da Use packaging.tags.mac_platforms
This function takes care of the version iteration AND architecture
determination internally.
2020-01-07 02:16:57 -05:00
Chris Hunt 687a00b3e1 Sort pep425tags typing imports
Makes the next change easier to review.
2020-01-07 02:16:28 -05:00
Chris Hunt 58f175fdf2 Remove unused format_tag
Since we delegate tag formatting to packaging.tags.Tag, we don't need
this function or its tests.
2020-01-07 01:42:42 -05:00
Chris Hunt 80b2c82d0c Use packaging.tags.Tag in place of Tuple
This is the standard type used by packaging.tags. Making this change
throughout the code lets us start switching over to using its
tag-generating functions in get_supported().

We also get rid of a test, since it was superseded by `__str__` in
packaging.tags.Tag.
2020-01-07 01:42:42 -05:00
Christopher Hunt f526f13a76
Merge pull request #7562 from chrahunt/maint/use-packaging-tags-interpreter-functions
Use interpreter_name and interpreter_version from packaging.tags
2020-01-07 14:39:54 +08:00
Tzu-ping Chung 32ecd727d5 Rename custom option class for future expansion 2020-01-07 10:50:53 +05:30
Chris Hunt 838d64d865 Extract platform list into separate function
Simplifies get_supported without changing any behavior.
2020-01-06 22:28:55 -05:00
Chris Hunt 893faa9e44 Replace get_abbr_impl with interpreter_name
This reduces the amount of code we have to manage.

interpreter_name is calculated differently, defaulting to the
long name of the interpreter rather than "cp", but that is more
conformant.
2020-01-06 18:27:51 -05:00
Chris Hunt 4b5614c9e2 Replace get_impl_ver with interpreter_version 2020-01-06 18:27:27 -05:00
Chris Hunt c750c1d82a Update packaging to 20.0 2020-01-06 14:04:07 -05:00
Chris Hunt 8460394c47 Update packaging version and include py.typed
Since the new packaging has types, it includes a py.typed. No harm in
including this in our package, and it may facilitate debug tool usage on
an installed pip by signaling that pip._vendor.packaging is
type-annotated.
2020-01-06 14:03:34 -05:00
Pradyun Gedam d9d801f818
Drop no-suffix checks for pip-from-PATH 2020-01-06 19:29:56 +05:30
Stéphane Bidoul (ACSONE) 5aa3b3d2f0
Remove unused build() argument 2020-01-05 23:52:42 +01:00
Stéphane Bidoul (ACSONE) 66e010980a
Remove WheelBuilder
build is now a function
2020-01-05 23:52:42 +01:00
Stéphane Bidoul (ACSONE) 9729273ca8
Make should_build and should_cache "private" 2020-01-05 23:52:42 +01:00
Stéphane Bidoul (ACSONE) c0aca12123
Clarify should_cache a bit 2020-01-05 23:52:42 +01:00
Stéphane Bidoul (ACSONE) 25521f29b5
should_build always returns a boolean 2020-01-05 23:52:41 +01:00
Stéphane Bidoul (ACSONE) 6e7d0e5a05
_collect_buildset becomes _get_cache_dir
The only purpose of _collect_buildset is now
to compute the cache directory to use
for a given requirements. This is better
computed one by one in the build loop.
2020-01-05 23:52:41 +01:00
Stéphane Bidoul (ACSONE) 870106b9bb
Simplify _collect_buildset
Since filtering of what to build has been
done beforehand, there is no need to filter
again here anymore.
2020-01-05 23:52:41 +01:00
Stéphane Bidoul (ACSONE) 212ee12474
Filter requirements to build beforehand in install command
One more step so build() becomes only concerned with building.
2020-01-05 23:52:41 +01:00
Stéphane Bidoul (ACSONE) 8ca8e9bf61
Extend should_build scope wrt legacy requirements
We don't build legacy requirements
when wheel is not installed because
we'll fallback to a legacy install in such case.
2020-01-05 23:52:40 +01:00
Stéphane Bidoul (ACSONE) 3ae13f7d28
Move is_wheel_installed to utils 2020-01-05 23:52:40 +01:00
Stéphane Bidoul (ACSONE) e45005f4bb
Filter requirements to build beforehand in wheel command
One more step so build() becomes only concerned with building.
2020-01-05 23:52:40 +01:00
Stéphane Bidoul (ACSONE) 3de4765ec7
Add should_build function for wheel and install commands 2020-01-05 23:52:40 +01:00
Stéphane Bidoul (ACSONE) 4bdca1a09a
Remove now useless build_wheels function 2020-01-05 23:52:40 +01:00
Stéphane Bidoul (ACSONE) 10ff58d7be
Simplify install by calling build once
We filter what to build beforehand so we
can call build once. We then filter failures
to detect PEP 517 failures.
2020-01-05 23:52:38 +01:00
Stéphane Bidoul (ACSONE) 8601bb5d06
Make build_wheels return all failures
Check for PEP 517 build failures by
filtering failures.
2020-01-05 23:52:03 +01:00
Stéphane Bidoul (ACSONE) 8784fb419a
Make build_wheels return successes too
In preparation for moving the unpacking
out of WheelBuilder.build
2020-01-05 18:47:52 +01:00
Chris Hunt a94fb53dad Don't unpack wheel files after building for install
Actual installation has been using the wheel file directly for some
time. The last piece that required an unpacked wheel was metadata. Now
that it uses the wheel file directly, we can remove the unpacking after
build.
2020-01-05 10:57:15 -05:00
Chris Hunt 33043ba22f Use pkg_resources.Distribution derived from wheel directly
We now extract all metadata files from the wheel directly into memory
and make them available to the wrapping pkg_resources.Distribution via
the DictMetadata introduced earlier.
2020-01-05 10:57:14 -05:00
Chris Hunt ed65393840 Extract reading wheel file from wheel_metadata into separate function 2020-01-04 20:50:17 -05:00
Chris Hunt ae34781826 Parameterize wheel file path for metadata extraction 2020-01-04 20:50:17 -05:00
Chris Hunt 20706eb93f Add DictMetadata for adapting zip data to Distribution
pkg_resources.Distribution classes delegate to the IMetadataProvider
implementation provided at construction. This is the one we'll use for
adapting a ZipFile to pkg_resources.DistInfoDistribution.
2020-01-04 20:49:41 -05:00
Chris Hunt b263fcc105 Move parse_wheel and supporting functions to utils.wheel
In order to parse metadata from wheel files directly we want to reuse
parse_wheel. Moving it out helps avoid creating an unnecessary
dependence on operations.install.wheel.
2020-01-04 23:11:51 +01:00
Stéphane Bidoul (ACSONE) 9cbe7f90d6
Reference the git+git@ removal issue
in the deprecation message
2020-01-04 12:50:38 +01:00
Stéphane Bidoul (ACSONE) 8415011774
Clarify git+git@ replacements 2020-01-04 12:50:06 +01:00
Stéphane Bidoul (ACSONE) cf071dee55
Deprecate git+git@ form of VCS url 2020-01-02 19:20:29 +01:00
Tzu-ping Chung 9c04298d5b Revert expanduser on options that accept URL 2020-01-02 20:46:14 +08:00
Pradyun Gedam 08f61a9b73
Do not attempt setup.py clean for failed pep517 builds (#7477) 2020-01-02 12:11:32 +00:00
Stéphane Bidoul (ACSONE) 8d1d20de8c
Do not attempt setup.py clean for failed pep517 builds
Fixes #6642
2020-01-02 12:14:03 +01:00
Tzu-ping Chung 2e24041ca5 Custom optparse.Option type that calls expanduser 2020-01-02 15:30:54 +08:00
Chris Hunt 2f92826081 Extract basic wheel parsing into separate function
This functions as a guard for the rest of our wheel-handling code,
ensuring that we will only get past this point if we have a wheel that
we should be able to handle version-wise.

We return a tuple instead of bundling up the result in a dedicated type
because it's the simplest option. The interface will be easy to update
later if the need arises.
2020-01-01 17:51:25 -05:00
Chris Hunt d5b4c15105 Remove dead code from wheel_metadata
Since we don't pass the source directory anymore, remove the tests
and implementation.
2020-01-01 17:51:24 -05:00
Chris Hunt a2af0f9468 Get WHEEL metadata from wheel file directly 2020-01-01 17:26:20 -05:00
Chris Hunt 2519e9740c Split try block in wheel_metadata
Makes it simpler to substitute in zip-derived WHEEL extraction.
2020-01-01 17:26:20 -05:00
Chris Hunt 62721eb5da Remove dead code
Since we don't pass the source dir anymore, we can simplify the tests
and implementation for wheel_dist_info_dir.
2020-01-01 17:26:20 -05:00
Chris Hunt cd5400ceb9 Determine .dist-info directory from wheel file directly
First example of transitioning a directory-aware function to using a
zipfile directly. Since we will not need to maintain the unpacked dir
going forward, we don't need to worry about making wheel_dist_info_dir
"generic", just that the same tests pass for both cases at each commit.

To do this neatly we use pytest.fixture(params=[...]), which
generates a test for each param. Once we've transitioned the
necessary functions we only need to replace the fixture name and remove
the dead code.
2020-01-01 17:26:20 -05:00
Chris Hunt 513a3162de Pass open zip file for wheel into install_unpacked_wheel
With this parameter we can incrementally update code to rely on the zip
file instead of the unpacked source directory.
2020-01-01 17:26:20 -05:00
Christopher Hunt b2f596ba2b
Merge pull request #7536 from chrahunt/refactor/extract-wheel-info-functions
Refactor wheel info extraction during install
2020-01-02 06:25:33 +08:00
Stéphane Bidoul (ACSONE) 68e49b9613 Remove redundant expanduser for download_dir in preparer
Since
- download_dir is only set by the download command
- download_dir is
normalized at the beginning of the download command
- path normalization includes expanduser
Therefore expanduser in the preparer is redundant
2020-01-01 18:54:08 +01:00
Chris Hunt 010c24d64c Take .dist-info dir directly in wheel_metadata
Since retrieval of the .dist-info dir already ensures that a
distribution is found, this reduces responsibility on wheel_metadata and
lets us remove a few tests already covered by the tests for
test_wheel_dist_info_dir_*.
2020-01-01 12:25:01 -05:00
Chris Hunt 6c56557fbe Remove unused req_description from wheel_dist_info_dir 2020-01-01 12:25:01 -05:00
Chris Hunt e1c7de8861 Raise UnsupportedWheel instead of AssertionError, and let caller add name 2020-01-01 12:25:01 -05:00
Chris Hunt a539c8dfe0 Normalize exception message for dist_info_dir check 2020-01-01 12:25:01 -05:00
Chris Hunt 32115b55af Extract getting wheel .dist-info directory into a separate function 2020-01-01 12:10:22 -05:00
Chris Hunt c51f020b98 Read WHEEL from .dist-info instead of using has_metadata
This will make it easier to transition to the already-determined
dist-info directory and reduces some of our dependence on pkg_resources.

Despite the name, the `egg_info` member is also populated for
.dist-info dirs.

ensure_str uses encoding='utf-8' and errors='strict' for Python 3
by default, which matches the behavior in
`pkg_resources.NullProvider.get_metadata`.
2020-01-01 12:10:20 -05:00
Tzu-ping Chung 6c2ffcd0ce
Update src/pip/_internal/self_outdated_check.py
Co-Authored-By: Christopher Hunt <chrahunt@gmail.com>
2020-01-02 00:00:59 +08:00
Christopher Hunt ab7e4769db
Merge pull request #7520 from chrahunt/maint/cross-platform-lints
Run linters/docs on Windows and macOS
2020-01-01 23:48:56 +08:00
Xavier Fernandez 6896dfcd83
Merge pull request #7524 from sbidoul/wheel-download-dir-sbi
Ensure wheel download dir is present at the beginning of wheel command
2020-01-01 16:13:38 +01:00
Tzu-ping Chung ed40706534 Use sys.executable to format upgrade message 2020-01-01 22:12:12 +08:00
Chris Hunt c9b0742508 Remove old root_is_purelib
The _invalidversion_ tests are not applicable to the new function since
we do not use a regex to find the applicable folder.
2019-12-31 12:49:08 -05:00
Chris Hunt 42c6dd78b9 Use WHEEL metadata to determine Root-Is-Purelib 2019-12-31 12:47:01 -05:00
Chris Hunt d66bc398be Split wheel_metadata from wheel_version
This will let us re-use the wheel_metadata for other parts of
processing, and by parameterizing checks in terms of metadata we will be
able to substitute in metadata derived directly from the zip.
2019-12-31 12:35:52 -05:00
Chris Hunt 918b154518 Move info_dir calculation up
This will let us use the value for later processing.
2019-12-31 12:12:17 -05:00
Christopher Hunt 69143848b0
Make WHEEL file errors more explicit (#7529)
* Raise exception on exception in finding wheel dist

We plan to replace this code with direct extraction from a zip, so no
point catching anything more precise.

* Raise exception if no dist is found in wheel_version
* Catch file read errors when reading WHEEL

get_metadata delegates to the underlying implementation which tries
to locate and read the file, throwing an IOError (Python 2) or OSError
subclass on any errors.

Since the new explicit test checks the same case as brokenwheel in
test_wheel_version we remove the redundant test.

* Check for WHEEL decoding errors explicitly

This was the last error that could be thrown by get_metadata, so we can
also remove the catch-all except block.

* Move WHEEL parsing outside try...except

This API does not raise an exception, but returns any errors on the
message object itself. We are preserving the original behavior, and can
decide later whether to start warning or raising our own exception.

* Raise explicit error if Wheel-Version is missing

`email.message.Message.__getitem__` returns None on missing values, so
we have to check for ourselves explicitly.

* Raise explicit exception on failure to parse Wheel-Version

This is also the last exception that can be raised, so we remove
`except Exception`.

* Remove dead code

Since wheel_version never returns None, this exception will never be
raised.
2019-12-31 23:17:41 +08:00
Stéphane Bidoul (ACSONE) a6d212383b
Remove redundant path normalization in preparer
wheel_download_dir is normalized at the
beginning of the wheel command
2019-12-31 05:32:42 +01:00
Christopher Hunt ea7bbff713
Merge pull request #7496 from pradyunsg/refactor/move-legacy-install-process
Move logic for legacy installs to dedicated module
2019-12-31 12:00:23 +08:00
Christopher Hunt e8ded43035
Merge pull request #7523 from sbidoul/wheel-builder-disentangle-7-sbi
Further reduce responsibility of WheelBuilder
2019-12-31 08:32:29 +08:00
Christopher Hunt 8c888a2287
Simplify getting info directories for wheel installation (#7526)
* Edit subdirs of top-level instead of checking in each directory

Previously, we were checking whether the top of the relative path ended
with .data. Now, we do not recurse into those directories, so there's no
need to check every time.

* Store info_dir in separate variable

Instead of working with a list everywhere, we use the single info_dir.

* Separate variables for info_dir and the destination path
* Use destination .dist-info dir only when needed

By initially storing just the name of the folder we ensure our code is
agnostic to the destination, so it'll be easier to install from a zip
later.

* Use os.listdir instead of os.walk for wheel dir population

Since we only execute any code when basedir == '', we only need the
top-level directories.

* Inline data_dirs calculation
* Inline info_dirs calculation
2019-12-30 23:59:23 +08:00
Stéphane Bidoul (ACSONE) f55819787d
Normalize wheel dir at the beginning of wheel command
Similar to what is done in the download command.
2019-12-30 09:53:08 +01:00
Stéphane Bidoul (ACSONE) 9da9f6050b
In Resolver, assume wheel_download_dir exists
This is ensured at the beginning of the wheel
command, which is the only command that
sets wheel_download_dir.

This is also similar to what is done for download_dir
in the download command.
2019-12-30 09:53:08 +01:00
Stéphane Bidoul (ACSONE) d8374b86f9
wheel: ensure wheel dir is present earlier
Similar to what is done for download_dir
in the download command
2019-12-30 09:53:08 +01:00