Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add root-only install option #3648

Closed
wants to merge 1 commit into from

Conversation

calmdown13
Copy link

@calmdown13 calmdown13 commented Feb 5, 2021

Pull Request Check List

Resolves: #2166

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary

Adds an option to skip any dependency resolution and just install the root package.

Motivation

  • When developing inside a docker container its common to install dependencies during the docker build process (which can be done using poetry install --no-root), and then install the root package at runtime (once the code has been mounted in to the container). At the moment the poetry install command can take a long time (~1 minute) to resolve even though all dependencies are installed and up to date. Adding a --root-only option would enable a quick install of the root package in situations where you are confident that the dependencies are already up to date. This would have big impact on development speed and is in keeping with the no-dev and dev-only commands that are already present.
  • In the linked issue, others seem to have similar challenges with multistage docker builds. In particular in situations where there might not be network connectivity for all build steps or when developing extensions in other languages.

Notes

  • Happy to add tests, however, I couldn't see a tests/console/command/test_install.py so wasn't sure where to add them.

@abn abn added the status/needs-consensus Consensus among maintainers required label Feb 9, 2021
@calmdown13
Copy link
Author

@abn anything I can do to help this along? Is it worth me adding a new test script (test_install.py)?

@vberlier
Copy link

I'd be really interested in this too. It would make it possible to cache dependencies installation separately from package installation in CI.

@neersighted
Copy link
Member

I'm not convinced that this adds any benefit over pip install /path/to/project. As Poetry is a pip-compatible (PEP 517) backend, you should just be able to do pip install and get something like this:

Processing /home/neersighted/poetry
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: virtualenv in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (20.8.1)
Requirement already satisfied: cleo<2.0.0,>=1.0.0a4 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (1.0.0a4)
Requirement already satisfied: tomlkit<1.0.0,>=0.7.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (0.7.2)
Requirement already satisfied: cachy<0.4.0,>=0.3.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (0.3.0)
Requirement already satisfied: html5lib<2.0,>=1.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (1.1)
Requirement already satisfied: keyring>=21.2.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (22.3.0)
Requirement already satisfied: poetry-core<2.0.0,>=1.1.0a6 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (1.1.0a6)
Requirement already satisfied: packaging<21.0,>=20.4 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (20.9)
Requirement already satisfied: shellingham<2.0,>=1.1 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (1.4.0)
Requirement already satisfied: cachecontrol[filecache]<0.13.0,>=0.12.4 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (0.12.6)
Requirement already satisfied: entrypoints<0.4,>=0.3 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (0.3)
Requirement already satisfied: requests-toolbelt<0.10.0,>=0.9.1 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (0.9.1)
Requirement already satisfied: crashtest<0.4.0,>=0.3.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (0.3.1)
Requirement already satisfied: pkginfo<2.0,>=1.5 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (1.7.1)
Requirement already satisfied: pexpect<5.0.0,>=4.7.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (4.8.0)
Requirement already satisfied: requests<3.0,>=2.18 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from poetry==1.2.0a2) (2.26.0)
Requirement already satisfied: msgpack>=0.5.2 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from cachecontrol[filecache]<0.13.0,>=0.12.4->poetry==1.2.0a2) (1.0.2)
Requirement already satisfied: lockfile>=0.9 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from cachecontrol[filecache]<0.13.0,>=0.12.4->poetry==1.2.0a2) (0.12.2)
Requirement already satisfied: pylev<2.0.0,>=1.3.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from cleo<2.0.0,>=1.0.0a4->poetry==1.2.0a2) (1.4.0)
Requirement already satisfied: webencodings in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from html5lib<2.0,>=1.0->poetry==1.2.0a2) (0.5.1)
Requirement already satisfied: six>=1.9 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from html5lib<2.0,>=1.0->poetry==1.2.0a2) (1.16.0)
Requirement already satisfied: SecretStorage>=3.2 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from keyring>=21.2.0->poetry==1.2.0a2) (3.3.1)
Requirement already satisfied: jeepney>=0.4.2 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from keyring>=21.2.0->poetry==1.2.0a2) (0.7.1)
Requirement already satisfied: pyparsing>=2.0.2 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from packaging<21.0,>=20.4->poetry==1.2.0a2) (2.4.7)
Requirement already satisfied: ptyprocess>=0.5 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from pexpect<5.0.0,>=4.7.0->poetry==1.2.0a2) (0.7.0)
Requirement already satisfied: charset-normalizer~=2.0.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from requests<3.0,>=2.18->poetry==1.2.0a2) (2.0.6)
Requirement already satisfied: certifi>=2017.4.17 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from requests<3.0,>=2.18->poetry==1.2.0a2) (2021.10.8)
Requirement already satisfied: idna<4,>=2.5 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from requests<3.0,>=2.18->poetry==1.2.0a2) (3.2)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from requests<3.0,>=2.18->poetry==1.2.0a2) (1.26.7)
Requirement already satisfied: platformdirs<3,>=2 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from virtualenv->poetry==1.2.0a2) (2.4.0)
Requirement already satisfied: filelock<4,>=3.0.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from virtualenv->poetry==1.2.0a2) (3.3.0)
Requirement already satisfied: backports.entry-points-selectable>=1.0.4 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from virtualenv->poetry==1.2.0a2) (1.1.0)
Requirement already satisfied: distlib<1,>=0.3.1 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from virtualenv->poetry==1.2.0a2) (0.3.3)
Requirement already satisfied: cryptography>=2.0 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from SecretStorage>=3.2->keyring>=21.2.0->poetry==1.2.0a2) (35.0.0)
Requirement already satisfied: cffi>=1.12 in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from cryptography>=2.0->SecretStorage>=3.2->keyring>=21.2.0->poetry==1.2.0a2) (1.14.6)
Requirement already satisfied: pycparser in /home/neersighted/.cache/pypoetry/virtualenvs/poetry-lSqwFFbg-py3.9/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=2.0->SecretStorage>=3.2->keyring>=21.2.0->poetry==1.2.0a2) (2.20)
Building wheels for collected packages: poetry
  Building wheel for poetry (pyproject.toml) ... done
  Created wheel for poetry: filename=poetry-1.2.0a2-py3-none-any.whl size=191938 sha256=a0b3b15d5f96978fdc323f817b07864758b13f496e4aa156af2e6b57b8ce9bb4
  Stored in directory: /tmp/pip-ephem-wheel-cache-j2wlde8k/wheels/49/a2/8a/9e7e92e50c515f8f3438d84339ac69ea0dfca0c80a8e5323fc
Successfully built poetry
Installing collected packages: poetry
  Attempting uninstall: poetry
    Found existing installation: poetry 1.2.0a2
    Uninstalling poetry-1.2.0a2:
      Successfully uninstalled poetry-1.2.0a2
Successfully installed poetry-1.2.0a2

This was after a fresh poetry install -- notice that pip did nothing as all the requirements were already satisfied by Poetry itself -- it merely built a new root package and installed it into the virtualenv.

Docs changes to explain this use case are welcome -- I'd suggest a new PR with just the doc changes to document this command, if my example indeed works for the requested use-case.

Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/needs-consensus Consensus among maintainers required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --only-root option for install command.
4 participants