Skip to content

Commit

Permalink
Move wheel to operations.install.wheel (#7421)
Browse files Browse the repository at this point in the history

* Update documentation

For now just fixing the paths and adding a sub-package docstring.
  • Loading branch information
chrahunt authored Dec 3, 2019
1 parent ca43dac commit 830e29e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion docs/html/development/architecture/anatomy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ Within ``src/``:
* ``locations.py``
* ``models/`` *[in-process refactoring! Goal: improve how pip internally models representations it has for data -- data representation. General overall cleanup. Data reps are spread throughout codebase….link is defined in a class in 1 file, and then another file imports Link from that file. Sometimes cyclic dependency?!?! To prevent future situations like this, etc., Pradyun started moving these into a models directory.]*
* ``operations/`` -- a bit of a weird directory….. ``Freeze.py`` used to be in there. Freeze is an operation -- there was an operations.freeze. Then “prepare” got added (the operation of preparing a pkg). Then “check” got added for checking the state of an env.] [what’s a command vs an operation? Command is on CLI; an operation would be an internal bit of code that actually does some subset of the operation the command says. ``install`` command uses bits of ``check`` and ``prepare``, for instance. In the long run, Pradyun’s goal: ``prepare.py`` goes away (gets refactored into other files) such that ``operations`` is just ``check`` and ``freeze``..... … Pradyun plans to refactor this. [how does this compare to ``utils``?]

* ``install/`` -- for modules related to installing projects of various kinds

* ``wheel.py`` is a file that manages installation of a wheel file. This handles unpacking wheels -- “unpack and spread”. There is a package on PyPI called ``wheel`` that builds wheels -- do not confuse it with this.

* ``pep425tags.py`` -- getting refactored into packaging.tags (a library on PyPI) which is external to pip (but vendored by pip). :pep:`425` tags: turns out lots of people want this! Compatibility tags for built distributions -> e.g., platform, Python version, etc.
* ``pyproject.py`` -- ``pyproject.toml`` is a new standard (:pep:`518` and :pep:`517`). This file reads pyproject.toml and passes that info elsewhere. The rest of the processing happens in a different file. All the handling for 517 and 518 is in a different file.
* ``req/`` *[*\ **A DIRECTORY THAT NEEDS REFACTORING. A LOT**\ *\ …… Remember Step 3? Dependency resolution etc.? This is that step! Each file represents … have the entire flow of installing & uninstalling, getting info about packages…. Some files here are more than 1,000 lines long! (used to be longer?!) Refactor will deeply improve developer experience.]*
* ``resolve.py`` -- This is where the current dependency resolution algorithm sits. Pradyun is `improving the pip dependency resolver`_. Pradyun will get rid of this file and replace it with a directory called “resolution”. (this work is in git master…. There is further work that is going to be in a branch soon)
* ``utils/`` *[everything that is not “operationally” pip ….. Misc functions and files get dumped. There’s some organization here. There’s a models.py here which needs refactoring. Deprecation.py is useful, as are other things, but some things do not belong here. There ought to be some GitHub issues for refactoring some things here. Maybe a few issues with checkbox lists.]*
* ``vcs/`` *[stands for Version Control System. Where pip handles all version control stuff -- one of the ``pip install`` arguments you can use is a version control link. Are any of these commands vendored? No, via subprocesses. For performance, it makes sense (we think) to do this instead of pygitlib2 or similar -- and has to be pure Python, can’t include C libraries, because you can’t include compiled C stuff, because you might not have it for the platform you are running on.]*
* ``wheel.py`` is a file that manages installation of a wheel file. This handles unpacking wheels -- “unpack and spread”. There is a package on PyPI called ``wheel`` that builds wheels -- do not confuse it with this.

* ``_vendor/`` *[code from other packages -- pip’s own dependencies…. Has them in its own source tree, because pip cannot depend on pip being installed on the machine already!]*

Expand Down
2 changes: 2 additions & 0 deletions src/pip/_internal/operations/install/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""For modules related to installing packages.
"""
File renamed without changes.
5 changes: 3 additions & 2 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
from pip._vendor.packaging.version import parse as parse_version
from pip._vendor.pep517.wrappers import Pep517HookCaller

from pip._internal import pep425tags, wheel
from pip._internal import pep425tags
from pip._internal.build_env import NoOpBuildEnvironment
from pip._internal.exceptions import InstallationError
from pip._internal.locations import get_scheme
from pip._internal.models.link import Link
from pip._internal.operations.build.metadata import generate_metadata
from pip._internal.operations.build.metadata_legacy import \
generate_metadata as generate_metadata_legacy
from pip._internal.operations.install.wheel import install_unpacked_wheel
from pip._internal.pyproject import load_pyproject_toml, make_pyproject_path
from pip._internal.req.req_uninstall import UninstallPathSet
from pip._internal.utils.deprecation import deprecated
Expand Down Expand Up @@ -486,7 +487,7 @@ def move_wheel_files(
pycompile=True # type: bool
):
# type: (...) -> None
wheel.install_unpacked_wheel(
install_unpacked_wheel(
self.name,
wheeldir,
scheme=scheme,
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pkg_resources import parse_version

import pip._internal.pep425tags
import pip._internal.wheel
from pip._internal.exceptions import (
BestVersionAlreadyInstalled,
DistributionNotFound,
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
from mock import patch
from pip._vendor.packaging.requirements import Requirement

from pip._internal import wheel
from pip._internal.commands.wheel import WheelCommand
from pip._internal.exceptions import UnsupportedWheel
from pip._internal.locations import get_scheme
from pip._internal.models.scheme import Scheme
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.misc import hash_file
from pip._internal.utils.unpacking import unpack_file
from pip._internal.wheel import (
from pip._internal.operations.install import wheel
from pip._internal.operations.install.wheel import (
MissingCallableSuffix,
_raise_for_invalid_entrypoint,
)
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.misc import hash_file
from pip._internal.utils.unpacking import unpack_file
from pip._internal.wheel_builder import get_legacy_build_wheel_path
from tests.lib import DATA_DIR, assert_paths_equal

Expand Down

0 comments on commit 830e29e

Please sign in to comment.