-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Enable offline installations: poetry install --download-only; poetry install --offline #2184
Comments
@finswimmer I don't think this is feature-worthy:
|
I think you misunderstood the intention of Download the idea is that poetry with the switch does instead: Download For 2, you are right. For my specific use case I'm not in a containerized environment but I can do something similar:
It does not work for local repositories, though. Since the line in the requirements file end up being |
I think another way to look at this would be as an optimization request. As stated, Poetry does appear to download and cache packages in the users home folder already, but for some reason it doesn't seem to re-use the files in this cache when re-installing the packages ... or at the very least it is doing some additional network operation to look up package data or something prior to installing from the cache. When installing to a workspace that has a lock file available Poetry should be able to see the full list of dependencies and versions of those dependencies that are required. Then it should be able to do a direct lookup in the local cache to see if those exact packages are available. If they are then the tool should proceed to install the package directly with no additional network IO needed. IMO this should be the default behavior of the tool and should not need any additional flags or command line options to customize that behavior. I will admit that I am making some assumptions here because I have not dug deeply into the source for Poetry, but the reason I believe the tool is still doing some sort of network IO during such install operations is because network IO is super slow for me while working over a corporate VPN so individual package lookups can take many seconds or more, so it can take a considerable amount of time to pull package metadata over the wire. If the tool was not performing any network IO in this case then I would expect installs from the local cache to be extremely fast, but they take pretty much the same amount of time as doing a fresh install when the cache has been fully purged / deleted. To put it into perspective as to the performance concerns I have here, one of my smaller projects has about 80 dependencies total - transitive and direct - and it takes nearly 90 seconds to generate a lock file for that dependency tree. And that does not include the time it takes to download the actual package files btw. So any efforts that can be made to optimize the network bandwidth here would be of great benefit to users in my situation. |
I neglected to mention in my last comment that it takes 2-3 minutes to install the dependencies for the sample project I mentioned, even after the poetry.lock file has been generated and the local poetry package cache has been fully populated. If we could shave off 90+ seconds of that by eliminating superfluous network lookups that would be an amazing time saver. |
+1 I come from a java and maven background where
I'm relatively new to python but I haven't found a way to ensure that except by removing the dev-dependencies before running pylint. So I'd love to install all dependencies, run my unit tests, remove dev-dependencies, run pylint (or the other way around), but doing this means adding minutes to the build currently. The best I can come up with is maintaining 2 different venvs and play with the POETRY_VIRTUALENVS_PATH value between commands. |
+1 Another use case: we have a company internal package repo, that is configured in the pyproject.toml. But we build our Docker images in google cloud builder, that does not have access to that. So we'd like to download all packages first, then upload them to google cloud builder and install them there from the downloads. With pip this is possible with the |
+1 plenty of use cases for protected, non-internet connected environments |
Hey @python-poetry
@roniemartinez It's not enough to have local cache per machine, because then we mix all the dependencies from different projects. If I want to copy my project with all just my dependencies I don't want to copy the entire my cache folder. Although we can use it and do not download what's already been downloaded. Another point that I miss now in poetry is offline installation. This will allow ship my project with all the dependencies anywhere and create the proper environment there. So I think these 2 changes can bring some very useful features. |
npm and yarn both have --prefer-offline options which only hit the network if it is not found in the local cache. I don't really care what the option is called --prefer-offline vs --download and --offline. Whatever you want. So long as it speeds up my life |
Just a comment that it would be nice if a e.g. in pip this would look something like this:
|
Currently i'm doing this:
With this packages are only installed within the correct Environment.
But still having some issues, as i have relative dependencies within my poetry project. These relative dependencies are not resolved by pip and the requirements.txt |
Howdy. I'm trying to just add a local folder as an installation package
Our project is big and the tests folder has a lot of test files (unit, integration system), and I want them to be available as a python module. Yet, that single command tells poetry to try to update every single package in my project and it just takes a lot of time. |
Just wondering what the conclusion is here. It seems this case was silently buried with no definite solution (as far as I can tell from the related issue trackers). I was looking for a simple solution to install offline wheel files, similar to: |
From the perspective of continuous integration and continuous deployments, this is also a desirable feature, I'd even say an expectable feature from a dependency manager. In a CI/CD environment I want my build process to result in an artifact that's as atomically deployable as possible. To me this means including the resulting wheel file, but also all dependencies in exact versions as were used during this process. Aside from ensuring a 1:1 behavior/feature match of CI/CD and deployed status, this also helps prevent incomplete deployments due to networking issues. It's possible that the package repositories become unavailable between the CI/CD process run and the deployment, either due to service outages, or deployment into an environment without public network access. Additionally collecting the dependencies means rollbacks to previous versions (of the build) is largely atomic when those contain the dependencies at that time. While extremely uncommon for public repositories such as PyPI, it's technically still possible for package contents in the repository to change regardless of versioning schemes. Hashing and checking those only help in detecting such situations, but doesn't help with content changing in-between download, installation of dependencies and having deployable artifacts. Again this is much less an issue with (mostly) immediate build -> deploy processes, but very relevant for rollbacks to previous build results. Even if users here have provided a workaround, it feels like a project dependency management tool should provide this functionality. |
Download public and private packages for offline installTo expand upon the # Download all packages (public and private)
poetry export --with-credentials > requirements.txt
poetry run pip download -r requirements.txt -d packages/ Using Beware that this does mean the generated Install packages offlineTo perform the offline install, I prefer to run a local PyPI server on the offline machine so that I can use First install pypiserver on the offline machine, then copy over the # Run the local PyPI server
pypi-server run . It's then necessary to modify the # Install as normal, but from the local PyPI server
poetry install This will emit |
Motivation
After poetry has resolved the dependencies and written the lock file, it proceeds to download and install the dependencies one by one. This could be a problem for systems which are not containerized and just checkout a repo and update their dependencies to update the code. If the internet connection breaks in the middle of the process neither the old code or the new code are fully deployed.
Feature Request (simple)
A
--download-then-install
flag that would make poetry first download all the dependencies and then proceed to install the already downloaded dependencies could solve this use case.The use would simply be:
If any of the required dependencies could not be downloaded, poetry should not attempt to install neither remove anything and just fail. If all required dependencies had been downloaded successfully, then the installation / removal / updates are preformed using only the information in the local filesystem.
Feature Request (robust)
A combination of flags to separate both processes could also work, such as:
These command would be used in succession and the flags are exclusive.
poetry install --offline
should first look at the contents of thepoetry.lock
file to make sure the packages are stored in the local filesystem before performing the installation / removal / update.The text was updated successfully, but these errors were encountered: