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

Poetry still fails to install in Docker #1227

Closed
3 tasks done
fralik opened this issue Jul 14, 2019 · 6 comments
Closed
3 tasks done

Poetry still fails to install in Docker #1227

fralik opened this issue Jul 14, 2019 · 6 comments

Comments

@fralik
Copy link

fralik commented Jul 14, 2019

  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Windows 10, Docker with python:3.7

  • Poetry version: 0.12.17

  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/fralik/26a0797e1cd940c89e871bccabcad982

Issue

I believe this is a similar issue to #512. That issue is marked as resolved, however I still see the error.

I am trying to use poetry in Docker with a custom packaging scheme (see my pyproject.toml file). If I build a package locally with poetry build, then I can see that Poetry finds modules and packages them successfully.

However, once I try to build a Docker image I get this exception:

[ValueError]                        
/app/src/sensortag does not contain any element  
                                                   
Exception trace:
 /root/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)

 /root/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /root/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)

 /root/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)

 /root/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)

 /root/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py in execute() at line 107
   return self.handle()

 /root/.poetry/lib/poetry/console/commands/install.py in handle() at line 61
   builder = EditableBuilder(self.poetry, self._env, NullIO())
 /root/.poetry/lib/poetry/masonry/builders/builder.py in __init__() at line 48
   includes=self._package.include,

 /root/.poetry/lib/poetry/masonry/utils/module.py in __init__() at line 62
   PackageInclude(self._path, package["include"], package.get("from"))
 /root/.poetry/lib/poetry/masonry/utils/package_include.py in __init__() at line 16
   self.check_elements()

 /root/.poetry/lib/poetry/masonry/utils/package_include.py in check_elements() at line 40
   "{} does not contain any element".format(self._base / self._include)

My Dockerfile is provided as well.

If I remove packages from pyproject.toml, then everything installs fine in docker.

@brycedrennan
Copy link
Contributor

You're trying to install the sensortag package but haven't included it's code in the docker image.

@bufke
Copy link

bufke commented Jan 13, 2020

Is there a better solve than adding the code to the docker image? Consider the Docker Compose getting started page.

Here we install packages (with pip) before the code is added to the image. Often times in development, the code is just mounted after build. However this can't be done with Poetry if the pyproject.toml references a package, which is often necessary for packaging.

@bufke
Copy link

bufke commented Jan 14, 2020

Adding --no-root to poetry install seems to fix this without needing to copy the source. This allows Docker builds to better cache a project that's in development where source frequently changes but packages do not.

b-kuch added a commit to b-kuch/fastapi-template-project that referenced this issue Oct 22, 2022
vipranarayan14 added a commit to vipranarayan14/try-sanstem that referenced this issue Jan 20, 2023
Doarakko added a commit to Doarakko/cloud-run-playground that referenced this issue Feb 23, 2023
@Edwardp17
Copy link

Edwardp17 commented Apr 1, 2023

@bufke I'm working on a project that requires similar logic and came across this thread. If i'm understanding correctly, adding --no-root would not install the developing package into the environment - what would be the benefit of that? Caching for Docker makes sense, but then the package is not able to be imported and used in the environment?

@systematicguy
Copy link

systematicguy commented May 2, 2023

@Edwardp17 for example in my case we want to cache poetry installing the dependencies, that sometimes are coming from private github source besides having a large number. Our code changes much more frequently than the set of dependencies. So we also make use of the poetry install --no-root feature.

To mitigate the issue of not being able to be imported, we do a poetry install --only-root before running tests.

Copy link

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.

@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
None yet
Projects
None yet
Development

No branches or pull requests

5 participants