question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Install dependencies from a local directory containing archives

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

Issue

Like “pip”, poetry should allow applications to install dependencies from a local directory containing archives. This would enable developers to compile Python wheels in the first stage of a Docker multi-stage build then depend on only the compiled archives in another stage. If you’re interested, please see my blog post outlining the reasons for this workflow.

The following configuration option could work but it’s just a starting suggestion:

 [[tool.poetry.source]]
name = "local-files"
path = "instance" # I'm the relevant option :)

[[tool.poetry.source]]
name = 'default'
url = 'https://pypi.org/'

[tool.poetry.dependencies]
python = "3.7"
requests = "^2.20.0"
uwsgi = "^2.0.17"

In the above example, projects could defer to the main package index if no correctly-formatted wheels / archives are found in an instance folder (in this case, relative to pyproject.toml).

See below for a sample Dockerfile (using pip for now, hopefully poetry in the future):

###########################################
# Throwaway image with C compiler installed
FROM python:3.6-alpine as bigimage

# install the C compiler
RUN apk add --no-cache linux-headers g++

# instead of installing, create a wheel
RUN pip wheel --wheel-dir=/root/wheels uwsgi==2.0.17.1

###########################################
# Image WITHOUT C compiler but WITH uWSGI
FROM python:3.6-alpine as smallimage

COPY --from=bigimage /root/wheels /root/wheels

# Ignore the Python package index
# and look for archives in
# /root/wheels directory
RUN pip install \
      --no-index \
      --find-links=/root/wheels \
      "uwsgi>=2.0.17.1"

Thanks again for all the work on this tool; Poetry looks like an amazing project and I look forward to being able to use it as a daily driver.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:37
  • Comments:12

github_iconTop GitHub Comments

8reactions
zachliucommented, Dec 19, 2018

I have exactly the same issue 😲

4reactions
boris99qcommented, Feb 4, 2020

This is still a relevant issue - It would be nice to have that feature. On big projects, when there are a lot of local packages installing via path and relative paths is disaster.

Example: ├── package a │ ├── src │ ├──── pyproject.toml ├── package b │ ├── src │ ├──── pyproject.toml

let’s say that package b has dependency on package a, the following pyproject need to be given:

.
.
. 
[tool.poetry.dependencies] 
package_a = { path="../../package_a"} 
.
.
.

This is just getting awful when discussing on much bigger projects.

more niter behavior would be:

[tool.poetry.dependencies] 
package_a = "*"

and a link to the local package would be given as same as given by the pip --find-links “<PACKAGE_A_PATH>”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing Python packages from local file system folder to ...
In this way you can install packages from local folder AND pypi with the same single call: pip install -r requirements/production.txt.
Read more >
How to download Python dependencies - ActiveState
Use the pipdeptree utility to gather a list of all dependencies, create a requirements.txt file listing all the dependencies, and then download ...
Read more >
pip install - pip documentation v22.3.1
Local directory (which must contain a setup.py , or pip will report an error). Local file (a sdist or wheel format archive, following...
Read more >
Installing Packages - Python Packaging User Guide - Python.org
Installing Packages¶. This section covers the basics of how to install Python packages. It's important to note that the term “package” in this...
Read more >
Install Packages from Repositories or Local Files - R
Source directories or file paths or URLs of archives may be specified with type = "source" , but some packages need suitable tools...
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