How to install code as a wheel

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
mtkennerlycommented, Apr 2, 2019

Gotcha. Sounds like you’d probably want the export command from 1.0.0a0 then.

2reactions
mtkennerlycommented, Apr 1, 2019

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, since poetry install --no-dev still installs your library, so if you try this, you’ll get:

$ poetry run pip install dist/*.whl
Requirement already satisfied: foo==0.1.0 from file:///C:/tmp/foo/dist/foo-0.1.0 -py3-none-any.whl in c:\tmp\foo

…which won’t actually install your wheel. For what you want, you’d probably need to do:

RUN pip install poetry && \
    poetry install --no-dev --no-interaction && \
    poetry run pip uninstall -y bookie && \
    poetry run pip install dist/*

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:

  • Install with Poetry and exact pinned dependencies. This ignores the wheel and tests the known good setup.
  • Install the wheel with Pip and take all latest dependencies, not using Poetry. This tests the wheel and that the upper version ranges from pyproject.toml are valid.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to install, download and build Python wheels - ActiveState
How to install, download and build Python wheels. Python wheels. Try a faster and easier way to build Python from source code.
Read more >
Create a Python Wheel File to Package and Distribute Custom ...
In this article, we will explore how to create a python wheel file using Visual Studio Code, load it to a Databricks Cluster...
Read more >
Packaging and distributing projects
The wheel package will detect that the code is pure Python, and build a wheel that's named such that it's usable on any...
Read more >
What Are Python Wheels and Why Should You Care?
env/bin/activate $ python -m pip install -U pip wheel setuptools ... That includes not only Python code but also the source code of...
Read more >
Installation — wheel 0.38.4 documentation - Read the Docs
If you do not have pip installed, see its documentation for installation instructions. If you prefer using your system package manager to install...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found