Commit Graph

10507 Commits

Author SHA1 Message Date
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
Chris Hunt 0a3a558e38 Use compileall.compile_file instead of compileall.compile_dir
We want to move towards having more control over the generation of pyc
files, which will allow us to provide deterministic installs and
generate pyc files without relying on an already-extracted wheel.

To that end, here we are stripping away one layer of abstraction,
`compileall.compile_dir`. `compileall.compile_dir` essentially recurses
through the provided directories and passes the files and args verbatim
to `compileall.compile_file`, so removing that layer means that we
directly call `compileall.compile_file`.

We make the assumption that we can successfully walk over the
source file tree, since we just wrote it, and omit the per-directory
traversal error handling done by `compileall.compile_dir`.
2020-07-05 09:37:45 -04:00
Pradyun Gedam 8db4fc8224
Merge pull request #8530 from pradyunsg/rollout-flags 2020-07-05 01:50:25 +05:30
Pradyun Gedam 107ec292c2
Merge pull request #8539 from pradyunsg/warn-on-unsupported-use-of-constraints 2020-07-05 01:48:54 +05:30
Pradyun Gedam 28592d4c31
Allow for the deprecation warning in tests 2020-07-05 01:01:02 +05:30
Chris Hunt b5f02f9dd8 Check that expected text is written in include files
This is a little more specific than checking that we happened to create
an already-empty file, and is a better mirror for reality.
2020-07-04 14:23:10 -04:00
Chris Hunt 0b0d53e8fa Use wheel helper function instead of pre-created wheel file 2020-07-04 14:22:15 -04:00
Chris Hunt 00191b2db1 Explicitly test that header file was created as-expected
Since this is the special part of this test. This gives us more
confidence that we're doing the right thing when removing the standalone
wheel file next.
2020-07-04 14:22:15 -04:00
Pradyun Gedam 6437bec269
Warn on to-be-removed forms of constraints 2020-07-04 18:01:38 +05:30
Pradyun Gedam 20431888cb
Move check_invalid_constraint_type to req_install.py 2020-07-04 18:01:28 +05:30
Pradyun Gedam ace5485836
Change reject_invalid_constraint_types to be reusable 2020-07-04 17:50:42 +05:30
Nguyễn Gia Phong 512221e1c1 Make utils.parallel tests tear down properly 2020-07-04 15:07:38 +07:00
Christopher Hunt feb2a24f14
Merge pull request #8537 from chrahunt/refactor/read-record-from-wheel
Read RECORD from wheel file directly during install
2020-07-03 22:00:34 -04:00
Christopher Hunt 196f5487f9
Merge pull request #8535 from chrahunt/refactor/extract-console-script-spec-source
Extract console script spec calculation from install_unpacked_wheel
2020-07-03 21:58:57 -04:00
Chris Hunt d7b5a776b3 Move record_path closer to first use 2020-07-03 20:53:56 -04:00
Chris Hunt d441f9518b Get wheel RECORD directly from wheel file
This reduces our dependence on disk files, and removes some complexity
around Python 2/3 compatibility with the csv module.
2020-07-03 20:49:16 -04:00
Christopher Hunt 231211a7ab
Merge pull request #8531 from chrahunt/simplify-get-entrypoints
Get entrypoints directly from wheel during installation
2020-07-03 20:26:29 -04:00
Chris Hunt 0433200135 Move dest_info_dir construction closer to first use
Reducing the scope of variables makes it easier to refactor, since
we can extract whole contiguous chunks of code later.
2020-07-03 19:46:45 -04:00
Chris Hunt 3930e4b063 Drop unused argument 2020-07-03 19:46:45 -04:00
Chris Hunt 479154b4ae Get Wheel entrypoints from Distribution instead of file
Since the Distribution pulls its data directly from the Wheel file,
without extracting intermediate files to disk, this brings us closer to
installing from Wheels without extracting everything.
2020-07-03 19:46:45 -04:00
Chris Hunt d49d97f19f Pass Wheel distribution to install.wheel.get_entrypoints
Right now we're just wiring up the arguments. Next we will actually use
them.
2020-07-03 19:46:45 -04:00
Chris Hunt a953787152 Extract entrypoint test text construction into variable
We need this to construct the new argument to `get_entrypoints`.
2020-07-03 19:46:45 -04:00
Christopher Hunt dd38d81a6e
Merge pull request #8536 from chrahunt/add-no-entrypoint-test
Test `wheel.get_entrypoints` when none are expected
2020-07-03 19:40:22 -04:00
Pradyun Gedam 0acdbf8943
Merge pull request #8504 from McSinyx/list-speed-up-nw
Parallelize pip list --outdated and --uptodate
2020-07-04 03:31:26 +05:30
Chris Hunt 3fad029b77 Test `get_entrypoints` when none are expected 2020-07-03 17:49:56 -04:00
Chris Hunt 94421cfb1a Extract console script spec calculation from install_wheel
This big chunk of code was independent of the rest of our wheel
installation process. Moving it out enforces that there are no
dependencies between it and the original function, and makes it easier
to read the original function.
2020-07-03 17:43:33 -04:00
Christopher Hunt e2bcc56f71
Merge pull request #8533 from chrahunt/read-record-separately
Expect a plain list in get_csv_rows_for_installed
2020-07-03 17:05:43 -04:00
Chris Hunt dcd5cadcfd Expect a plain list in get_csv_rows_for_installed
This makes get_csv_rows_for_installed simpler, because it is not
modifying its arguments. We can also more easily refactor RECORD file
reading since it is now decoupled from getting the installed RECORD file
rows.
2020-07-03 12:25:12 -04:00
Christopher Hunt ea7ee7d8e0
Merge pull request #8526 from chrahunt/reduce-dependence-on-files
Reduce dependence on disk files during Wheel installation
2020-07-03 11:32:38 -04:00
Christopher Hunt e3ba8d9a49
Merge pull request #8529 from chrahunt/optimize-wheel-subdir-getter
Simplify and optimize getting zip subdirs
2020-07-03 11:30:46 -04:00
Pradyun Gedam 49b793cd03
Set correct envvar for new-resolver tests 2020-07-03 20:11:36 +05:30
Pradyun Gedam a8eaf11d7f
Use the correct flag name
Co-authored-by: Stéphane Bidoul <stephane.bidoul@acsone.eu>
2020-07-03 19:20:58 +05:30
Pradyun Gedam 26e29aa70e
Disallow --unstable-feature, pointing to --use-feature instead 2020-07-03 18:49:57 +05:30
Pradyun Gedam 79de2c8911
Switch to --use-feature for determining which resolver to use
Also changes all invocations in the tests, to the new flag.
2020-07-03 18:49:56 +05:30
Pradyun Gedam cd95531951
Add --use-feature and --deprecated-feature flags 2020-07-03 18:49:51 +05:30
Christopher Hunt cba5f11057
Merge pull request #8524 from chrahunt/remove-always-applicable-comments
Remove encouraging comments
2020-07-03 09:17:53 -04:00
Christopher Hunt 8097de5364
Merge pull request #8528 from chrahunt/simplify-get-entrypoints
Remove redundant entrypoint text normalization
2020-07-03 09:10:10 -04:00
Chris Hunt 8259528ed9 Simplify and optimize getting zip subdirs
Since we only care about the first path part, we can stop at 1 split. We
do not need a list, so the unnecessary conversion has been dropped.
2020-07-03 09:02:30 -04:00