jazzband / pip-tools

A set of tools to keep your pinned Python dependencies fresh.
https://pip-tools.rtfd.io
BSD 3-Clause "New" or "Revised" License
7.67k stars 608 forks source link

Makes `compile` and `sync` directly runnable as modules #2022

Closed jamesbraza closed 9 months ago

jamesbraza commented 9 months ago

Before:

> python -m piptools.scripts.compile --help

After:

> python -m piptools.scripts.compile --help
Usage: python -m piptools.scripts.compile [OPTIONS] [SRC_FILES]...

  Compiles requirements.txt from requirements.in, pyproject.toml, setup.cfg,
  or setup.py specs.

Options:
  --version                       Show the version and exit.
...
Contributor checklist
Maintainer checklist
chrysle commented 9 months ago

Thanks! Could you add a functional test, please?

jamesbraza commented 9 months ago

@chrysle trying to do something like this, I am getting defeated by all the relative imports in compile.py. So I opened https://github.com/jazzband/pip-tools/pull/2024, then I can come back to this the test of __main__ behaviors

webknjaz commented 9 months ago

Is that instead of python -m piptools compile? Why?

jamesbraza commented 9 months ago

Oh yeah python -m piptools compile can work too actually, didn't know about that. I am not attached to this PR if there's an alternate path to the same solution. Feel free to close this out

webknjaz commented 9 months ago

Oh yeah python -m piptools compile can work too actually, didn't know about that. I am not attached to this PR if there's an alternate path to the same solution. Feel free to close this out

Yep. I think I discovered it by reading the code. It should probably be documented better.

webknjaz commented 9 months ago

Oh, it's actually mentioned here https://pip-tools.rtfd.io/en/latest/#example-usage-for-pip-compile.