Commit Graph

2933 Commits

Author SHA1 Message Date
Xavier Fernandez 3ce1872aaf Actually test user_config_dir in TestUserConfigDir 2020-02-28 10:58:54 +01:00
Xavier Fernandez b42a069920 utils.appdirs: drop unused user_data_dir function
The vendored appdir's user_data_dir function is used inside
user_config_dir which is itself tested.
2020-02-28 10:58:54 +01:00
sinscary 716c9202ee Raise error if --user and --target arguments are used together 2020-02-27 12:22:56 +05:30
Pradyun Gedam 3fa356a772
Update references to pep425tags 2020-02-26 10:24:43 -08:00
Chris Hunt 8362c20da5 Rename legacy resolver unit tests
It's a little long, but better to be consistent with our other test file
naming conventions until we come up with better ones.
2020-02-25 09:04:07 -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
Chris Hunt 40bc4ea8fe Move network unit tests to align with subpackage names 2020-02-23 16:22:30 -05:00
Christopher Hunt 40523794d8
Merge pull request #7747 from pfmoore/parsed_requirement
Refactor parse_requirements to be independent of InstallRequirement
2020-02-24 00:21:28 +08:00
Anudit Nagar 082c0f01d2
Update old-style formatting to new-style formatting (#7762) 2020-02-21 21:48:14 +05:30
Nitesh Sharma ce1e0f470a
Move UI helpers to cli subpackage (#6727) 2020-02-21 14:01:13 +05:30
Pradyun Gedam e648e00dc0
pip is spelt all-lowercase 2020-02-18 10:55:16 +05:30
Paul Moore f085bb0e0e Merge branch 'master' into parsed_requirement 2020-02-14 20:34:44 +00: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
Pradyun Gedam cdae7277ef
Merge pull request #7596 from uranusjr/6446-link-url-quoting
Fix incorrect quoting Link.url
2020-02-14 16:00:43 +05:30
Paul Moore e2a57fd1e6 Refactor to reduce coupling.
* Make ParsedLine record the type of line
* Split handle_line to allow passing arguments only where needed
* Remove unneeded attributes from ParsedRequirement
2020-02-14 09:56:42 +00:00
Paul Moore f2e49b3946 Use a new ParsedRequirement class to communicate between handle_line and parse_requirements 2020-02-13 10:39:17 +00:00
Pradyun Gedam 313740f6ee
Merge pull request #7593 from uranusjr/hg-under-git
Detect all registered VCS and choose inner-most
2020-02-08 17:34:31 +05:30
Paul Moore 6f154f5546
Merge pull request #7707 from pfmoore/refactor_options
Pass individual options to InstallRequirement rather than an options object
2020-02-07 14:22:10 +00:00
Paul Moore a9f1d8562b Pass individual options to InstallRequirement rather than an options object 2020-02-06 16:05:11 +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 9c58aa7eb5 Do not use InstallRequirement in warn_deprecated_install_options
This only needed a list of requirements, so give it just that.
2020-02-05 22:30:07 -05:00
Chris Hunt fd815bc1fa Pass in a plain list of InstallRequirement to Resolver.resolve
Further simplifies the Resolver interface, and will give us the
opportunity to remove any knowledge of RequirementSet from the
individual commands.
2020-02-05 22:30:05 -05:00
Chris Hunt 550ae907bd Parameterize check_supported_wheels to Resolver.resolve
This reduces our dependence on the input RequirementSet.
2020-02-05 22:29:46 -05:00
Chris Hunt 58c06299db Return a different RequirementSet from Resolver.resolve
This makes the resolver interface simpler by returning a brand new
RequirementSet vs mutating the one that was input to the function, and
will let us specialize RequirementSet for the different use cases.
2020-02-05 22:29:30 -05:00
Chris Hunt 98cd193727 Remove delete_marker_file writing in tests
Nothing checks for this file, so no need to write it.
2020-02-05 20:14:44 -05:00
Chris Hunt 8197a4bbc5 Do not write delete marker file to track source_dir delete preference
Previously we were writing a delete marker file which is checked in
InstallRequirement.remove_temporary_source which is only invoked if the
user did not pass --no-clean (and a PreviousBuildDirError was not
raised). Since our TempDirectory machinery now respects these conditions
we can just wrap our source directory in that instead of using this
ad-hoc mechanism for tracking our delete preference.

This will let us clean up a lot of dead code that only existed for this
use case.
2020-02-05 20:14:44 -05:00
Chris Hunt b8c0d0175d Do not test unpack_http_url or unpack_file_url
The tests for unpack_{file,http}_url relies on these functions to both
retrieve and unpack. We want to move unpacking out, so call unpack_url
instead.
2020-02-04 21:49:40 -05:00
Chris Hunt 39d1c51fdb Globally-manage BuildEnvironment._temp_dir 2020-02-04 20:32:27 -05:00
Christopher Hunt f537db5021
Merge pull request #7651 from chrahunt/refactor/wheel-builder-helper-2
Add new wheel builder test helper
2020-02-03 23:45:23 +08:00
Bhavam Vidyarthi 7534dccd6c
Removed tests/scripts folder with its contents (#7680) 2020-02-03 05:17:02 +08:00
Chris Hunt 667dc392e5 Remove unused futurewheel fixture 2020-01-31 19:33:51 -05:00
Chris Hunt e83e134f5f Use wheel_builder for future wheel functional test 2020-01-31 19:33:48 -05:00
Chris Hunt 6d8a58f7e1 Add wheel builder test helper
As we introduce stricter metadata parsing, we will need to ensure that
the wheel files used in our tests are compliant (except in the specific
way that we're testing against).

Currently we have a large number of test cases relying on undocumented or
under-documented wheel files that have various inconsistencies
(incorrect name, missing fields) that are unrelated to the features
actually under test.

With a new wheel builder helper function, we will be able to replace all
of our instances of pre-built wheel test fixtures with dynamically-generated
files in code that are correct by default.
2020-01-31 19:30:19 -05:00
Chris Hunt f2af7df453 Use tempdir_registry to control auto-deleted files globally
Next we can actually transition some files to be globally-managed that
are only deleted conditionally.
2020-01-29 23:04:26 -05:00
Chris Hunt 45991bcc1e Use explicit default value for TempDirectory delete flag
Now we can opt-in to globally-managed + globally-configured file
deletion for pre-existing directories by passing an explicit `None`.
2020-01-29 23:04:14 -05:00
Chris Hunt dd8753cdee Mitigate Windows test failures due to PAX-format wheel release 2020-01-29 08:53:23 -05:00
Deepak Sharma b242c3979a String formatting updated 2020-01-23 18:09:59 +05:30
Christopher Hunt f1cd4cb48e
Merge pull request #7608 from uranusjr/global-cleanup
Delay TempDirectory.delete resolution to cleanup
2020-01-22 18:25:05 +08:00
Stéphane Bidoul (ACSONE) 0e1e0ef566 _should_cache does not depend on check_binary_allowed
_should_cache is only called by _get_cache_dir.

In pip install mode, _get_cache_dir is never called when
check_binary_allowed returns False because in that case
should_build_for_install_command has returned False before
and the build was skipped.

In pip wheel mode, check_binary_allowed always returns True
(because it is not passed to the build function).

So _should_cache can use _always_true for check_binary_allowed.

*Alternative*

Alternatively, we could have passed check_binary_allowed
to build in pip wheel mode. The only difference is that wheels built
locally from *legacy* packages would then not be cached,
when pip wheel is used with --no-binary.
2020-01-20 10:41:48 +01:00
Tzu-ping Chung 35377c995c Add test for tempdir registry lazy eval 2020-01-19 18:22:14 +07:00
Pradyun Gedam f1cf84e2f8
Merge pull request #7542 from sbidoul/normalize-cache-dir-sbi
Eagerly normalize cache directory
2020-01-18 22:38:59 +05:30
Pradyun Gedam 8bc1024a13
Touch command may not be available on Windows (#7601) 2020-01-15 16:08:17 +00:00
Paul Moore 3288d902e6 Touch command may not be available on Windows 2020-01-15 15:14:22 +00:00
Tzu-ping Chung 2dc061d960 Normailze case in tests 2020-01-15 17:50:41 +08:00
Christopher Hunt f2bb7c4e57
Merge pull request #7588 from uranusjr/reinstall-test
Delete a file to let --force-reinstall fix it
2020-01-15 11:48:27 +08:00
Tzu-ping Chung 8b1f4d80c1 Modify test to unify site_packages path usages 2020-01-14 21:56:23 +08:00
Tzu-ping Chung d301cbeb4e Add marker to Mercurial test 2020-01-14 18:00:49 +08:00
Tzu-ping Chung 284352a42c Add test to verify freeze output 2020-01-14 17:54:54 +08:00
Tzu-ping Chung e5c43ed6af Add tests for get_repository_root 2020-01-14 16:45:28 +08:00
Tzu-ping Chung cdd7821d92 Fix incorrect quoting Link.url
Cherry-picked manually from atugushev:fix-issue-6446.

Co-Authored-By: Albert Tugushev <albert@tugushev.ru>
2020-01-14 16:12:11 +08:00
Christopher Hunt cf722df4f9
Merge pull request #7581 from chrahunt/refactor/split-install-tests
Split relative requirement install tests
2020-01-14 01:40:29 +08:00
Pradyun Gedam b411cdbdf5
Azure Pipelines: Test Windows on Python 3.8 (#7320) 2020-01-13 12:33:43 +00:00
Tzu-ping Chung 2d3f2cdba5 Delete a file to let --force-reinstall fix it 2020-01-13 18:04:52 +08:00
Christopher Hunt 7e65a5a40f
Merge pull request #7578 from uranusjr/test-uppercase-console-scripts
Add test for uppercase script name
2020-01-13 09:42:38 +08:00
Chris Hunt 8d92e40c1f Use USERPROFILE in expanduser test
In Python 3.8, expanduser on Windows no longer respects HOME, per
https://bugs.python.org/issue36264.
2020-01-12 19:44:43 -05:00
Tzu-ping Chung 8e72502118 Add test for uppercase script name 2020-01-12 17:16:52 +08:00
Tzu-ping Chung 4def73ca3a Refactor test to remove unneeded network dep 2020-01-12 17:12:08 +08:00
Tzu-ping Chung 10022df906 Rename test to make its intention clearer 2020-01-12 17:03:28 +08:00
Chris Hunt e53d10db01 Remove unnecessary uninstall
Since a new temporary script path is used for each test, no need to do
uninstall.
2020-01-11 19:39:12 -05:00
Chris Hunt f89013daa4 Parametrize editable for relative install tests 2020-01-11 19:37:10 -05:00
Chris Hunt 2801de5825 Parametrize long relative install tests
This lets us make better use of parallelization and will let us remove
the unnecessary uninstallation from these individual tests.
2020-01-11 19:32:44 -05:00
Chris Hunt 0a57e4e9f2 Manage temp directory deletion centrally
This gives us a global toggle that we can use to control whether
temporary directories get deleted from one place (ideally, in the
commands taking --no-clean).
2020-01-10 11:08:05 +01:00
Tzu-ping Chung facf5c8894 Add comments to unicode workarounds 2020-01-09 13:11:30 +05:30
Tzu-ping Chung 7a80acaf44 Tell shutil.make_archive to use Unicode paths
By default, make_archive uses str paths on Python 2, which causes it to
skip files with unencodable names. By passing in a unicode base_dir
explicitly, it is smart enough to use unicode all the way down instead.
2020-01-09 13:01:31 +05:30
Tzu-ping Chung 37f97140af Also use rmtree to remove tmpdir_factory
Same as e2c3451001
2020-01-09 13:00:49 +05:30
Xavier Fernandez fe3e892a93
Merge pull request #7354 from chrahunt/maint/use-packaging-tags
Use packaging.tags for doing compatible wheel tag calculation
2020-01-08 22:41:35 +01:00
Tzu-ping Chung e2c3451001 Delete tmpdir with rmtree to handle Unicode paths
pytest (rather py.path.local) does not handle non-ASCII paths properly
on Windows with Python 2, but Python's builtin shutil.rmtree() does.

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2020-01-08 18:26:42 +05:30
Stéphane Bidoul (ACSONE) 8ce0859012
Remove redundant expanduser in WheelCache
Path normalization, which includes expanduser is now
done eagerly. Assert this when initializing
WheelCache.
2020-01-08 08:02:29 +01:00
Chris Hunt 896317d13d Remove unused abi functions
Previously, these were used when the user did not provide an explicit
ABI. Now this is handled internally in `packaging.tags` (by
`_cpython_abi` and `_generic_abi`).
2020-01-07 19:01:05 -05:00
Chris Hunt 7aaa705c15 Remove unused glibc functions
The remaining glibc-related functions are required to allow us to put
the libc version in the pip user agent (for stats).
2020-01-07 19:01:00 -05:00
Chris Hunt 2455977bc8 Remove unused manylinux auto-deduction functions 2020-01-07 19:00:55 -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 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
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
Pradyun Gedam 4ee779f79e
Drop no longer valid tests 2020-01-07 12:25:11 +05:30
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
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
Pradyun Gedam d9d801f818
Drop no-suffix checks for pip-from-PATH 2020-01-06 19:29:56 +05:30
Stéphane Bidoul (ACSONE) f04e6ab7b5
Split should_build test
Separately test should_build_for_wheel_command
and should_buid_for_install_command.
The tests are simpler and this open the door
for reasoning about both functions independently.
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) 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) 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) 4bdca1a09a
Remove now useless build_wheels function 2020-01-05 23:52:40 +01: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 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
Christopher Hunt c3ab0a0b13
Merge pull request #7552 from chrahunt/refactor/cleanup-wheel-install-tests
Make wheel install test packages more explicit
2020-01-05 08:46:07 +08: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
Chris Hunt b58205ea01 Use valid wheel for functional download tests
Previously we were copying an existing wheel to a file with a
different distribution name. When using stricter metadata parsing this
would fail, so now we use a more conformant dummy wheel function.
2020-01-04 23:08:43 +01:00
Chris Hunt b65bd4c31a Remove unused args parameter from _git_commit 2020-01-03 19:24:22 -05:00
Chris Hunt 5665b94a5b Make explicit argument for git commit -a 2020-01-03 19:21:36 -05:00
Chris Hunt f9bf1a7004 Make explicit argument for git commit --allow-empty 2020-01-03 19:19:18 -05:00
Chris Hunt 79eaf132fc Remove unnecessary expect_stderr from _git_commit
This simplifies our interface to git, which will make it easier to trade
out our subprocess-based invocations in the future.
2020-01-03 19:13:08 -05:00
Chris Hunt f5684ed7ae Use shared_data fixture in wheel install tests
shared_data avoids copying the entire data directory, so use it in cases
where we know pip won't have any opportunity to edit the data files
(where we're passing tmpdir for --find-links).
2020-01-03 18:25:02 -05:00
Chris Hunt d468da2796 Explicitly copy required packages to tmpdir for wheel install tests
Any test using --find-links data.packages is potentially using several
packages. By copying specifically the packages we need, we can more
easily see the packages that each test depends on and avoid using the
`data` fixture.
2020-01-03 18:23:48 -05:00
Chris Hunt 4e5d854456 Normalize --find-links argument format in wheel install tests 2020-01-03 17:58:40 -05:00
Chris Hunt 7af9371176 Remove redundant expect_error=False in tests
This is the default, so there is no need to specify it explicitly.
2020-01-03 14:25:36 +01: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) c93acfb20b
Test legacy clean not attempt after PEP 517 build failure 2020-01-02 12:14:03 +01:00
Tzu-ping Chung 5ffc6bd468 Add tests for global path options 2020-01-02 18:58:42 +08: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 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 452acd5e76 Add files in .dist-info directory tests
Since zips don't typically contain directory entries, we want to
only operate on files. Adding files to the .dist-info tests means we
will be able to reuse them for both cases, while they coexist.
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
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 32115b55af Extract getting wheel .dist-info directory into a separate function 2020-01-01 12:10:22 -05: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
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
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
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) 261c286de9
Make wheel_cache an argument of build() 2019-12-29 18:51:45 +01:00
Stéphane Bidoul (ACSONE) 3828699ddc
Move build options from WheelBuilder to build function 2019-12-29 18:49:54 +01: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 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 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
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) 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
Pradyun Gedam 37f3fd7087
Move legacy wheel build process 2019-12-25 17:52:39 +05:30
Christopher Hunt 0292938f89
Merge pull request #7501 from uranusjr/appdirs-patch 2019-12-24 23:30:55 +08:00
Tzu-ping Chung c98c0ad79c Default to /etc/xdg if XDG_CONFIG_DIRS if empty 2019-12-23 14:33:17 +08:00
Christopher Hunt 92da786643
Merge pull request #7494 from chrahunt/refactor/wheel-metadata-retrieval
Only allow one top-level .dist-info directory in wheels
2019-12-23 05:41:30 +08:00
Christopher Hunt 3f4bb75fa4
Merge pull request #7499 from chrahunt/feature/add-old-entrypoints
Add old pip entrypoints
2019-12-23 05:40:10 +08:00
Chris Hunt e5495cf6a1 Raise UnsupportedWheel when .dist-info doesn't match name
This aligns with the previous behavior that would have enforced the
found .dist-info directory starting with the name of the package.

We raise UnsupportedWheel because it looks better in output than the
AssertionError (which includes traceback).
2019-12-21 21:27:49 -05:00
Chris Hunt 0d865d8fe3 Add test for multiple .dist-info in wheel 2019-12-21 10:51:57 -05:00
Pradyun Gedam c06874c471
Merge pull request #7490 from sbidoul/legacy-cache-bug-sbi
Fix cache bug with legacy cache entries
2019-12-21 07:27:46 +00:00
Chris Hunt 38585adaec Add warning when using old console script wrappers
We use sys.stderr instead of our `deprecated` helper because logging is
not set up at the time this is executed.
2019-12-20 22:01:25 -05:00
Tzu-ping Chung 2ccc5c055d Match site_config_dirs for empty XDG_CONFIG_DIRS 2019-12-20 14:36:30 +08:00
Chris Hunt 241679e6c2 Setup old entrypoints in pip module
This should make everything "just work" with respect to combinations of
PATH, sys.path, and multiple Python installs. Later we can add a warning
here to help guide users to better understanding.
2019-12-19 21:20:51 -05:00
Tzu-ping Chung 204887da03 Apply changes from bundled appdirs to vendored
* Convert Windows app data directory values to bytes on Python 2, so the
  output type is consistent across platforms (pypa/pip#4000)
* Also look in ~/.config for user config on macOS (pypa/pip#4100)
* Remove pywin32 dependency, only use ctypes and winreg for directory
  lookup on Windows (pypa/pip#2467)
* Always use os.path.join() instead of os.sep.join() so cross-platform
  tests work as expected (pypa/pip#3275)
2019-12-19 17:15:03 +08:00
Chris Hunt 82a2651f93 Move pip._internal.main to cli submodule
Moving this out of the way gives us the flexibility to define wrappers
that will redirect requests to our old entrypoints to our new one.
2019-12-18 21:09:22 -05:00
Christopher Hunt ab12706aaa
Merge pull request #7478 from chrahunt/refactor/make-functional-download-tests
Make unpack_* unit tests into functional tests
2019-12-17 07:55:29 +08:00
Stéphane Bidoul (ACSONE) 36ff884673
Fix WheelCache.get in presence of legacy cache keys 2019-12-15 23:43:36 +01:00
Stéphane Bidoul (ACSONE) 80bfba3302
Improve WheelCache.get test 2019-12-15 23:41:03 +01:00
Stéphane Bidoul (ACSONE) 9c74c0214a
Add failing test for legacy cache keys 2019-12-15 23:41:03 +01:00
Christopher Hunt d6491fe666
Merge pull request #7483 from chrahunt/refactor/install-packed-wheel
Add downloaded/local archive path to InstallRequirement
2019-12-15 23:50:36 +08:00
victorvpaulo 81805a5776 Add option to silence warnings related to deprecation of Python versions (#6739)
* Add option to silence warnings related to deprecation of Python versions

* Move skip_if_python2 and skip_if_not_python2 decorator declaratios to test/lib/__init__.py and use them in test_warning.py

* Add tests to ensure that python version deprecation warning is shown correctly and can be silenced by a flag.

* Add new test to ensure that --no-python-version-warning flag does nothing if python version is not 2
2019-12-15 09:59:34 +08:00
Chris Hunt c565d7a1b2 Switch to install_wheel in unit tests
Since it tests install_unpacked_wheel, the coverage should be the same.
2019-12-14 11:38:31 -05:00
Stéphane Bidoul (ACSONE) 32cabbf716
Add test for pip wheel with non-absolute cache dir 2019-12-14 12:47:14 +01:00
Chris Hunt 9faa9aef29 Make download_http_url existing bad file test functional
Reduces coupling between tests and code.
2019-12-13 20:30:45 -05:00
Chris Hunt d3920f299f Make unpack_file_url existing bad file test functional
Reduces coupling between tests and code.
2019-12-13 20:30:45 -05:00
Chris Hunt fe24c7fc16 Make unpack_file_url existing matching file test functional
Reduces coupling between tests and code.
2019-12-13 20:30:45 -05:00
Chris Hunt 30c2d979b0 Make unpack_file_url download test to functional
This and the next several changes will uncouple the tests from the
current implementation, allowing us to factor the actual file download
out of `unpack_file_url` and `unpack_http_url`.
2019-12-13 20:30:45 -05:00
Chris Hunt 50efb55072 Add tests.lib.path.Path.read_bytes
To be used in some upcoming tests.
2019-12-13 20:30:45 -05:00
Pradyun Gedam 8e7a87bf4b
Factor out pep517 wheel build function (#7473) 2019-12-13 04:26:44 +00:00
Christopher Hunt d7eaede434
Revert "Add new option: pip wheel --save-wheel-names (#6377)" (#7420)
This reverts commit bcad1b1cb5, reversing
changes made to f86490317a.

As discussed, we should rethink the interface of this command output as
part of larger CLI usability review. In the interim, the same
functionality can be achieved using straightforward shell commands.
2019-12-13 07:57:05 +08:00
Stéphane Bidoul (ACSONE) 2eff06e7cc
Make WheelBuilder should_unpack argument explicit 2019-12-12 23:46:05 +01:00
Pradyun Gedam ce5edd4841
Better workaround for cache poisoning (#3025, #7319) 2019-12-12 11:28:57 +00:00
Chris Hunt 6343e8093f Replace atexit with globally-managed tempdir 2019-12-09 06:06:37 +08:00
Chris Hunt 0457826bd0 Add global TempDirectory manager
In cases where there is not a clear scope, or where enforcing a scope
and passing a temp directory to callees creates unnecessary coupling
between components, this will let us tie the lifetime of temporary
directories to the lifetime of the application without using e.g.
atexit or finalizers.

This has the benefit of being easier to test and reason about.
2019-12-09 06:06:37 +08: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
Chris Hunt 762e4a0817 Move parse_content_disposition to network.download 2019-12-04 18:31:53 -05:00
Chris Hunt 32b0fc23ab Move sanitize_content_filename to network.download 2019-12-04 18:31:53 -05:00
Chris Hunt 3fbc991f0c Move _prepare_download to network.download 2019-12-04 18:31:53 -05:00
Chris Hunt db766f3c95 Move helper mock classes to dedicated module
When we factor out tests these will be needed in both sets, and it's
easier to refactor tests later if we avoid creating a dependency between
test files.
2019-12-04 18:30:21 -05:00
Christopher Hunt 830e29e189
Move wheel to operations.install.wheel (#7421)
* Update documentation

For now just fixing the paths and adding a sub-package docstring.
2019-12-04 06:02:39 +08:00
Stéphane Bidoul (ACSONE) 824dca1060
Better support for unicode cache entries 2019-12-02 12:07:19 +01:00
Stéphane Bidoul (ACSONE) 66ba51ca7d
Use legacy cache entries when they exist.
Pip 20 changes the cache key format to include the
interpreter name. To avoid invalidating all existing caches,
we continue using existing cache entries that were computed
with the legacy algorithm. This should not regress issue #3025
because wheel cached in such legacy entries should have
the python implementation tag set.
2019-12-02 12:07:19 +01:00
Stéphane Bidoul (ACSONE) c4ef6163e5
New cache key generation algorithm
Instead of building an URL-ish string that could be
complex to describe and reproduce, generate a dictionary that is
hashed with a simple algorithm.
2019-12-02 12:07:19 +01:00
Stéphane Bidoul (ACSONE) e0165e7b30
Remove unused wheel_builder python_tag argument 2019-12-02 12:07:18 +01:00
Stéphane Bidoul (ACSONE) 178cd3f244
Better workaround for cache poisoning #3025
Make sure ``pip wheel`` never outputs pure python wheels with a
python implementation tag. Better fix/workaround for
`#3025 <https://github.com/pypa/pip/issues/3025>`_ by
using a per-implementation wheel cache instead of caching pure python
wheels with an implementation tag in their name.

Fixes #7296
2019-12-02 12:07:18 +01:00
Chris Hunt b8c16a0dc8 Move Wheel tests 2019-12-02 11:52:51 +08:00
Chris Hunt 60f6ed9387 Move wheel.Wheel to models.wheel.Wheel
This aligns more closely with how the class is used and makes it easier
to move the rest of the wheel module to a dedicated module for
installation.
2019-12-02 11:52:51 +08:00
Chris Hunt bf26185d55 Import Wheel in tests directly 2019-12-02 11:52:51 +08:00
Chris Hunt 1abf978e88 Move format_tag to pep425tags
This is a more appropriate place for the function, since it is more
related to tags than wheels, and will make it easier to refactor Wheel
into its own module.
2019-12-02 11:52:51 +08:00
Chris Hunt b8f626ace6 Deprecate install-location-related options in --install-option 2019-11-30 17:42:48 -05:00
Chris Hunt 55a943e556 Add distutils args helpers
The utils.distutils_args.parse_args function can recognize distutils
arguments so we can deprecate their usage.
2019-11-30 17:39:56 -05:00
Christopher Hunt 5ba702894a
Remove old workaround for Debian Python patch (#7401) 2019-11-26 11:58:46 +08:00
Xavier Fernandez db1a2754bb Fix logging of cached response
Cached responses often (always ?) provide a length meaning they were
never logged as such.
2019-11-25 23:15:00 +01:00
Paul Moore 4f6a965f14
Merge pull request #7394 from takluyver/i6599
Fix building packages with backend-path in pyproject.toml
2019-11-25 21:40:33 +00:00
Xavier Fernandez 95576102c5
Tweak format_size utility function to include a space (#7399) 2019-11-25 22:09:10 +01:00
Xavier Fernandez 8114003e62 Add basic tests for format_size 2019-11-25 14:53:23 +01:00
Chris Hunt 8d38b37052 Ignore WARNING emitted by setuptools during test 2019-11-23 16:17:35 -05:00
Thomas Kluyver 59550aaec3 Add an integration test of installing a project with a local PEP 517 backend 2019-11-23 18:45:09 +00:00
Thomas Kluyver 400cf8d71e Add a test combining local PEP 517 backend with external dependency 2019-11-23 16:57:24 +00:00
Thomas Kluyver edc525add9 Remove leftover debugging code 2019-11-23 16:53:01 +00:00
Thomas Kluyver 81f6ba3fc1 Default None instead of [] 2019-11-23 16:52:24 +00:00
Thomas Kluyver dd7b1ee5c3 Fix building packages with backend-path in pyproject.toml
Closes gh-6599
2019-11-23 14:38:27 +00:00
Christopher Hunt 3ff2513537
Merge pull request #7384 from chrahunt/refactor/cleanup-prepare-3
Cleanup operations.prepare more
2019-11-22 20:52:33 +08:00
Chris Hunt 19806574e5 Move Downloader out of unpack_http_url
Reduces scope of session and progress_bar.
2019-11-21 19:11:46 -05:00
Chris Hunt 4be0a5445a Move Downloader up out of _download_http_url
Reduces exposure of session and progress_bar.
2019-11-21 19:11:46 -05:00
Chris Hunt 1daa8b2fd9 Add mock server wrapper and replace network calls in a test 2019-11-17 17:36:36 -05:00
Chris Hunt bf7ad4a2a1 Remove unnecessary wrapping of tests
The cited issue https://bugs.python.org/issue3210 is fixed in all the
versions of Python that we test against.
2019-11-17 16:12:17 -05:00