Commit Graph

10544 Commits

Author SHA1 Message Date
Christopher Hunt 9ec3cfad20
Merge pull request #8329 from uranusjr/issue-template
Update issue template to nudge users
2020-07-07 22:07:56 -04:00
Chris Hunt cb540f30e3 Add basic test coverage configuration
This handles:

* Sub-processes within unit tests (thanks pytest-cov)
* Our pytest-fixture-based virtual environments and subprocesses
  therein
* Running with xdist (e.g. `-n auto`)
* Combining results from all of the above using paths rooted with
  `src/pip/*`

This doesn't handle:

* Platform-specific branches
* Python 2
* CI integration
2020-07-07 21:58:55 -04:00
Christopher Hunt 43ca0805ae
Merge pull request #8456 from McSinyx/lint-vendor-readme
Lint src/pip/_vendor/README.rst
2020-07-07 21:40:38 -04:00
Christopher Hunt b27956928f
Merge pull request #8553 from uranusjr/header-location-prefix
Header location prefix
2020-07-07 21:37:50 -04:00
Christopher Hunt 53aa1a932b
Merge pull request #8538 from McSinyx/parallel-test-teardown
Make utils.parallel tests tear down properly
2020-07-07 21:19:28 -04:00
Chris Hunt 8c7b9429cd Add news 2020-07-07 19:11:11 -04:00
Chris Hunt f878fcdeec Rename function that reject location install options
Since it no longer shows a deprecation warning, the previous name
doesn't fit.
2020-07-07 19:11:11 -04:00
Chris Hunt 89572a7d40 Throw CommandError on any location-related install options 2020-07-07 19:11:11 -04:00
Chris Hunt b46d8ab01a Refactor overriding test to not use disallowed option
Similar to our previous test refactoring, this removes the usage of
`--home` from the test command.

"Overriding" in the original test meant "placed after" in the
command-line arguments, which makes sense because setuptools will use
the last argument passed.
2020-07-07 19:11:02 -04:00
Chris Hunt 50d7b930d3 Create more robust test for isolated --install-option
The current test depends on passing `--home` to `--install-option`.
Since we would like that to fail, we need to use another argument. None
of the other possible arguments have a visible side-effect, so we just
write the provided arguments to a file and check that in the test.
2020-07-07 19:10:27 -04:00
Chris Hunt ffddab6986 Test that RECORD is populated correctly for data files 2020-07-07 09:25:16 -04:00
Chris Hunt a365764e57 Add test for RECORD population by make_wheel 2020-07-07 09:25:16 -04:00
Tzu-ping Chung 9cbefbb3fa Mention the breakage only happens in virtualenvs 2020-07-07 21:21:23 +08:00
Pradyun Gedam 04c861ec17
Merge pull request #8365 from deveshks/add-mypy-types-commands
Complete type annotations in "pip._internal.commands.{configuration,install}"
2020-07-07 17:13:45 +05:30
Tzu-ping Chung b85d5026e3 Fix header calculation when prefix is given 2020-07-07 18:53:33 +08:00
Tzu-ping Chung 600d5272e6 Add failing test for --prefix location 2020-07-07 18:53:33 +08:00
Nicole Harris 909f50aa8f Add news 2020-07-07 11:19:30 +01:00
Nicole Harris 3c38110700 Add resolver docs 2020-07-07 11:14:38 +01:00
Devesh Kumar Singh fb05730898 Align write_output types with logger.info 2020-07-07 15:23:05 +05:30
Devesh Kumar Singh 87249b9850 Assert target_temp_dir instead of if check 2020-07-07 15:06:27 +05:30
Devesh Kumar Singh 21ca1620d1 Change target_temp_dir type to TempDirectory 2020-07-07 14:57:42 +05:30
Devesh Kumar Singh 005cc1636c Add news entry 2020-07-07 14:57:42 +05:30
Devesh Kumar Singh 61f344b040 Add type annotations for pip._internal.commands.install 2020-07-07 14:57:42 +05:30
Devesh Kumar Singh e0d625ba93 Add type annotations for pip._internal.commands.configuration 2020-07-07 14:57:42 +05:30
Stéphane Bidoul 4bfc54df9b
Merge pull request #8552 from chrahunt/do-not-extract-wheel-in-prepare
Do not extract wheels in requirement preparation
2020-07-07 09:46:57 +02:00
Chris Hunt c9f87a645b Inline constant variable 2020-07-06 21:19:43 -04:00
Chris Hunt d3955e7837 Don't unpack wheels during preparation
For some time we have not needed to pre-emptively unpack wheels as part
of metadata processing, but kept the existing logic because the
behavior would start to diverge more for different package types. In
this case, though, removing the special cases for wheels makes this
logic a bit simpler, so it is worth doing.
2020-07-06 21:15:35 -04:00
Christopher Hunt 334f06e224
Merge pull request #8054 from deveshks/correct-package-name-while-install
Canonicalize req name while doing pre-install package search
2020-07-06 12:10:33 -04:00
Devesh Kumar Singh 6c1030ca95 Fix comment order for retrying module 2020-07-06 19:17:26 +05:30
Christopher Hunt 161ee7f852
Merge pull request #8548 from chrahunt/better-wheel-empty-dir-test
Refactor test for empty directory in wheel
2020-07-06 09:25:31 -04:00
Devesh Kumar Singh ac624f1e4f Reword news entry 2020-07-06 13:42:09 +05:30
Devesh Kumar Singh 04fedfe53c Create custom get_distribution function 2020-07-06 13:42:05 +05:30
Devesh Kumar Singh 2bdec6c9fd Parametrize unit test 2020-07-06 13:32:09 +05:30
Devesh Kumar Singh 40261a475f Add unit tests to verify pkg name normalization 2020-07-06 13:32:09 +05:30
Devesh Kumar Singh 782913725f Canonicalize req name while doing pre-install package search 2020-07-06 13:32:09 +05:30
Paul Moore 547a8e9f72
Merge pull request #8483 from uranusjr/new-resolver-no-reinstall-direct-url-if-same-version
Skip installing if the version matches locally
2020-07-06 07:57:40 +01:00
Tzu-ping Chung 01e0700e68 Skip installing if the version matches locally
This check only applies to explicit requirements since we avoid
downloading the dist from finder altogether when there is a matching
installation (although the check wouldn’t change the behaviour in that
case anyway).

We can do this when we build the `ExplicitRequirement` instead, like how
we did for `SpecifierRequirement`, but that would require us to resolve
the direct requirement’s version eagerly, which I don’t want to.

The implemented approach checks the version only after resolution, at
which point the distribution is already built anyway and the operation
is cheap.
2020-07-06 11:06:14 +08: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
Chris Hunt 5e4c1a96a2 Remove unused argument 2020-07-05 20:16:36 -04:00
Chris Hunt ba96ba3b08 Reduce empty directory test coupling to implementation
Our previous test required that the implementation use a temporary
directory and unpack the wheel in-place. Now we just provide a
conventional empty directory in the wheel file itself.
2020-07-05 20:16:36 -04:00
Chris Hunt a9c7f229b0 Create sample project wheel inline 2020-07-05 20:16:36 -04:00
Pradyun Gedam cf418d7290
Merge pull request #8544 from sbidoul/req_file-typing-sbi 2020-07-06 02:39:02 +05:30
Stéphane Bidoul df79ae4233
Enable strict typing in req_file.py 2020-07-05 19:11:41 +02:00
Stéphane Bidoul caad983734
Fix docstring typo 2020-07-05 19:11:41 +02:00
Christopher Hunt 1f8a4dde26
Merge pull request #8541 from chrahunt/refactor/compile-file-next-steps
Byte-compile files after installation
2020-07-05 12:56:39 -04:00
Stéphane Bidoul c2350444e1
Merge pull request #8322 from deveshks/mypy-internal-ops
Complete type annotations in "pip._internal.operations.{check,freeze}" and "pip._internal.utils.subprocess"
2020-07-05 16:51:16 +02:00
Chris Hunt 452e683eda Move byte-compilation after installing wheel files
There are a few changes here:

1. The byte-compilation now occurs after we copy the root-scheme files
   and files from any wheel data dirs
1. Instead of iterating over the files in the unpacked wheel directory,
   we iterate over the installed files as they exist in the installation
   path
2. In addition to asserting that pyc files were created, we also add
   them to the list of installed files, so they will be included in RECORD

By compiling after installation, we no longer depend on a separate
temporary directory - this brings us closer to installing directly from
wheel files.

By compiling with source files as they exist in the installation output
directory, we no longer generate pyc files with an embedded randomized
temp directory - this means that wheel installs can be deterministic.
2020-07-05 09:38:35 -04:00
Chris Hunt 42c01ae97e Normalize Path to str in wheel tests
In our next commit we will use the scheme path to locate files to
byte-compile. If the scheme path is a `Path`, then that causes
`compileall.compile_file` (via `py_compile.compile`) to fail with:

```
.tox/py38/lib/python3.8/site-packages/pip/_internal/operations/install/wheel.py:615: in install_unpacked_wheel
    success = compileall.compile_file(
../../../.pyenv/versions/3.8.0/lib/python3.8/compileall.py:157: in compile_file
    ok = py_compile.compile(fullname, cfile, dfile, True,
../../../.pyenv/versions/3.8.0/lib/python3.8/py_compile.py:162: in compile
    bytecode = importlib._bootstrap_external._code_to_timestamp_pyc(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

code = <code object <module> at 0x7fa7e274f500, file "/tmp/user/1000/pytest-of-chris/pytest-37/test_std_install_with_direct_u0/dest/lib/sample/__init__.py", line 1>, mtime = 1593910285.2200587, source_size = 134

>   ???
E   ValueError: unmarshallable object
```

Debugging in gdb shows that the error is set due to the `Path` object
being present in the code object, which `marshal.dumps` can't handle
(frame 1):

```
 0  w_complex_object (v=<optimized out>, flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:564
 1  w_object (v=<Path at remote 0x7fffee51f120>, p=0x7fffffff7160) at Python/marshal.c:370
 2  w_complex_object (v=<code at remote 0x7fffee591710>, flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:544
 3  w_object (v=<code at remote 0x7fffee591710>, p=0x7fffffff7160) at Python/marshal.c:370
 4  w_complex_object (v=('1.2.0', <code at remote 0x7fffee591710>, 'main', None), flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:475
 5  w_object (v=('1.2.0', <code at remote 0x7fffee591710>, 'main', None), p=0x7fffffff7160) at Python/marshal.c:370
 6  w_complex_object (v=<code at remote 0x7fffee591ea0>, flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:539
 7  w_object (p=0x7fffffff7160, v=<code at remote 0x7fffee591ea0>) at Python/marshal.c:370
 8  PyMarshal_WriteObjectToString (version=<optimized out>, x=<code at remote 0x7fffee591ea0>) at Python/marshal.c:1598
 9  marshal_dumps_impl (module=<optimized out>, version=<optimized out>, value=<code at remote 0x7fffee591ea0>) at Python/marshal.c:1739
 10 marshal_dumps (module=<optimized out>, args=<optimized out>, nargs=<optimized out>) at Python/clinic/marshal.c.h:124
```

In the interest of easy git bisects, we commit this fix before the code
that would expose the bug.
2020-07-05 09:38:08 -04:00
Chris Hunt 2ece73cc86 Confirm that pyc files are written during installation
In order to add generated pyc files to the RECORD file for our package,
we need to know their path! To raise confidence that we're doing this
correctly, we assert the existence of the expected 'pyc' files while
still using the old installation logic.

Some valid reasons why pyc files may not be generated:

1. Syntax error in the installed Python files
2. There is already a pyc file in-place that isn't writable by the
   current user

We don't fail installation in those cases today, and we wouldn't want to
change our behavior here, so we only assert that the pyc file was
created if `compileall.compile_file` indicates success.
2020-07-05 09:38:07 -04:00
Chris Hunt 4cb6f729ab Filter to files actually processed by compileall.compile_file
`compileall.compile_file` returns a success parameter, but can return
"successful" without actually generating a pyc file if the input file
was filtered out and compilation was not attempted.

In our file processing we mirror that logic, to ensure that a truthy
success returned by `compileall.compile_file` actually indicates a file
was written.
2020-07-05 09:37:47 -04:00