-
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
poetry install with nested packages with "--no-root-nested" or similar option to improve docker builds #3671
Comments
A possible workaround could be done using # install dependencies, cached build
COPY pyproject.toml poetry.lock ./
RUN bash -c "pip install -r <(poetry export)" # optionally --without-hashes
# Actually install the app
COPY . .
RUN poetry install --no-dev |
I have found a temporary workaround right now by only copying "pypoject.toml" and "poetry.lock" for each subproject. Additionally in order for this to work one needs a project subfolder with an _init_.py in it. After all dependencies got resolved and installed in docker I copy the rest of the files into the docker image. This way we get somewhat nice caching behaviour: # copy only the pyproject.toml and lockfile in order to make sure they are cached
# as graphengine depends on myprojectlibrary we also copy the myprojectlibrary pyproject.toml and poetry.lock directly
# to the dockerfile.
COPY ./myproject/pyproject.toml ./myproject/poetry.lock "$PROJECT_DIR/myproject/"
COPY ./myprojectlibrary/pyproject.toml ./myprojectlibrary/poetry.lock "$PROJECT_DIR/myprojectlibrary/"
WORKDIR "$PROJECT_DIR/myproject"
# now we can do the installation without the actual packages which
# enables us to make use of the docker-cache. We will
# pull in the actual project files at a later stage
# In order for this to work we also need to create a "fake" myprojectlibrary directory
# we can install the project "normally" because we don't have the actual project files included here
RUN mkdir "$PROJECT_DIR/myprojectlibrary/myprojectlibrary" &&\
touch "$PROJECT_DIR/myprojectlibrary/myprojectlibrary/__init__.py" &&\
mkdir "$PROJECT_DIR/myproject/myproject" &&\
touch "$PROJECT_DIR/myproject/myproject/__init__.py" &&\
POETRY_VIRTUALENVS_IN_PROJECT=true poetry install --no-dev -vvv
COPY . $PROJECT_DIR where "myproject" depends on "myprojectlibrary" like this in the pyporject.toml file:
|
So given that the above method works, it would probably be sufficient for poetry to simply ignore the library folder inside a python project when called with a flag like the one I mentioned above ( |
What is being asked for right now is very unclear to me, but as best I can tell this is a sub-ask for #2270 -- if that is not correct, please update this issue with a clear explanation of what, from a environment/technical level, is being requested. |
This would be fixed exactly by #6845 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
Right now it is possible to install only the dependencies of a package with the
poetry install --no-root --no-dev
options. This is great to improve docker builds (cache behaviour for example).it would be great to extend that functionality to nested packages. Something like
poetry install --no-root --no-dev --no-root-nested
which would tell poetry to only install the dependencies of the nested package, but
not the package itself. This would greatly improve the caching behaviour of docker builds as we would only need
to copy the pyproject.toml and poetry.lock files into the docker machine which causes much better caching behaviour.
The text was updated successfully, but these errors were encountered: