python-poetry / python-poetry/poetry-plugin-export

poetry export -f requirements.txt -o requirements.txt --without-hashes --tree --size

Open
#41 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
335
Forks
57
Avg merge
1h 23m
Merged PRs (30d)
3

Description

Motivation:
I am building a docker image using script:
https://github.com/tchaton/sagemaker-torch-template

from jinja2 import Template

CMD = "RUN pip install "

requirements = []
with open("requirements.txt") as file_:
    for l in file_:
        if ';' in l:
            requirements.append(CMD + l.split(';')[0] + '\n')
        else:
            requirements.append(CMD + l)
with open("docker_template.jinja2") as file_:
    template = Template(file_.read())
rendered = template.render(requirements=''.join(requirements))
with open("Dockerfile", "w") as file_:
    file_.write(rendered)

I noticed it was faster to build and push when each RUN pip install {{package}} as its own line.

However, the dependencies generated by poetry are ordered by alphabetical order.

I think we could have more options here as a --tree, --size, --date

  • --tree options. By ordering packages using hierarchical tree dependencies (c.f poetry show --tree), so it will reduce layers probability to be uncached if new package are added.
  • Add a --size. Order parent package by size, so heavier ones are deeper.
  • Add a --date. Order parent package by added date to poetry
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the export command that produces requirements.txt and compare its current ordering with the hierarchy shown by poetry show --tree. Review the generated requirements.txt and Dockerfile use case, then define how the --tree, --size, and --date options should order packages. Done means the options are implemented with tests covering their output ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.