How to install code as a wheel
See original GitHub issueI’m trying to integrate poetry within my build and deploy process, and am having some difficulties with the latter.
So, build is working fine. I have code and a pyproject.toml file, and when I run poetry build -f wheel I get a wheel file, same as in my old build process. My next step would then consist of installing that wheel into a docker container, together with the dependent packages that I last tested it with. The dependency list would be the poetry.lock file, which I get for free, which is very nice. But I haven’t seen a way to install my code as a wheel.
For illustration, this is what I imagine my dockerfile to look like:
FROM python:3.7-alpine
COPY pyproject.toml .
COPY poetry.lock .
COPY dist/* dist/ # only wheel, no code files
RUN pip install poetry && poetry install --no-dev --no-interaction
The resulting container will happily install all dependencies, but not the wheel I send along.
I could of course fix it by just adding pip install dist/*, but it felt wrong to call pip by hand after using poetry up to now.
How do I tell poetry to install the code I’m deploying as a wheel? If that’s not possible, can I use pip to install the content of the poetry.lock file?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Related StackOverflow Question
Gotcha. Sounds like you’d probably want the
exportcommand from 1.0.0a0 then.Instead of manually activating the virtual environment that Poetry makes, you can do
poetry run pip install dist/*. But I wonder if that really does what you want/think, sincepoetry install --no-devstill installs your library, so if you try this, you’ll get:…which won’t actually install your wheel. For what you want, you’d probably need to do:
But that still feels kind of weird. This might not help if you have a specific reason for testing it the way you have in mind, but I think it would be more effective to split what you’re doing into two tests: