Commit Graph

8966 Commits

Author SHA1 Message Date
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 fc48a17206 Simplify positive wheel_version unit test 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 ca729c89de Simplify wheel_version tests 2019-12-31 12:35:53 -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
Stéphane Bidoul (ACSONE) 261c286de9
Make wheel_cache an argument of build() 2019-12-29 18:51:45 +01:00
Stéphane Bidoul (ACSONE) c8d4277535
Convert _build_one from method to function
It does not rely on WheelBuilder anymore.
2019-12-29 18:51:44 +01:00
Stéphane Bidoul (ACSONE) 3828699ddc
Move build options from WheelBuilder to build function 2019-12-29 18:49:54 +01:00
Pradyun Gedam b24a6d09fc
Merge pull request #7522 from pradyunsg/refactor/move-pep517-wheel-build-process
Move PEP-517 wheel build logic into operations.build
2019-12-29 17:44:01 +00:00
Christopher Hunt dc860e865e
Merge pull request #7519 from chrahunt/bugfix/restrict-two-dist-info-dirs-toplevel-only
Only check for .dist-info directories at the top-level
2019-12-29 20:16:25 +08:00
Christopher Hunt b3741acb8e
Merge pull request #7510 from chrahunt/refactor/operations-prepare-move-download-up
Move download copying out of unpacking functions
2019-12-29 20:15:19 +08:00
Pradyun Gedam ccfef67016
Move PEP-517 wheel build logic into operations.build 2019-12-29 16:57:02 +05:30
Pradyun Gedam 2721712c2b
Getting Started: Remove a duplicate word (#7521) 2019-12-29 09:58:27 +00:00
Christopher Hunt 711cf4deaf
Merge pull request #7517 from sbidoul/wheel-builder-disentangle-6-sbi
Move final wheel builder copy operation to wheel command
2019-12-29 13:46:02 +08:00
Chris Hunt 8dc6919875 Fix mypy checks on Windows
Previously we were making unguarded calls to non-Windows-only APIs. Mypy
only automatically excludes these from platform-specific checks when
inside conditions.
2019-12-29 00:33:28 -05:00
Chris Hunt c9ab34a945 Fix docs build on Windows
Sphinx expects the "document name" field to be normalized with respect
to slashes (all /), so we now do this in a portable way for Windows.
2019-12-28 18:21:46 -05:00
Eitan Adler 98543b2caa getting_started: remove a a duplicate word 2019-12-28 15:08:39 -08:00
Chris Hunt 4d1fd08d45 Run linters/docs on Windows and macOS
This ensures that contributors on any of the major platforms can run our
linting and doc building checks without any changes.
2019-12-28 17:43:10 -05:00
Chris Hunt 93900e1199 Only check for .dist-info directories at the top-level
Previously we were restricting to a single .dist-info directory anywhere
in the unpacked wheel directory. That was incorrect since only a
top-level .dist-info directory indicates a contained "package". Now we
limit our restriction to top-level .dist-info directories.
2019-12-28 15:49:08 -05:00
Pradyun Gedam 7420629800
Effectively disable the wheel cache if not writable (#7489) 2019-12-28 18:56:05 +00:00
Pradyun Gedam 7d9b392fc0
Move legacy wheel build process into "operations.build" (#7513) 2019-12-28 18:55:06 +00:00
Stéphane Bidoul (ACSONE) 1f39950f3a
Add news file explaining the new pip wheel behavior 2019-12-28 16:18:10 +01:00
Stéphane Bidoul (ACSONE) 7c2c58442f
Update docstring 2019-12-28 16:18:10 +01:00
Pradyun Gedam d4b5392b7a
Merge pull request #7516 from chrahunt/refactor/remove-unnecessary-cleanup
Remove unnecessary InstallRequirement cleanup in install_given_reqs
2019-12-28 12:42:01 +00:00
Stéphane Bidoul (ACSONE) 1ee270a8d4
Check that the cache is writable in _main()
This avoid code duplication (for the wheel and http
cache) and repeated warnings.
2019-12-28 13:04:54 +01:00
Stéphane Bidoul (ACSONE) 865539bdad
Test that pip wheel succeeds when cache dir is not writeable 2019-12-28 13:04:40 +01:00
Stéphane Bidoul (ACSONE) 158ae67910
Remove unused _wheel_dir in WheelBuilder 2019-12-26 21:43:57 +01:00
Stéphane Bidoul (ACSONE) 9909b4069a
Move final copy operation from wheel_builder to wheel command 2019-12-26 21:43:57 +01:00
Stéphane Bidoul (ACSONE) cf21401fd7
Make wheelbuilder.build return successes too
Also, pluralize variable names for readability and consistency with
similar variables in callers.
2019-12-26 21:43:57 +01:00