Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow 'pipx install' to preinstall from requirements.txt files #1525

Open
yolabingo opened this issue Aug 30, 2024 · 1 comment
Open

allow 'pipx install' to preinstall from requirements.txt files #1525

yolabingo opened this issue Aug 30, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@yolabingo
Copy link

How would this feature be useful?

Allows package maintainers and installers to pin specific versions of dependencies.

Describe the solution you'd like

pipx install --preinstall-from-file requirements.txt mypkg-0.1.2-py3-none-any.whl
or something like that

Describe alternatives you've considered

Trying to specify many packages individually using
pipx install --preinstall kubernetes==28.1.0 [--preinstall xxx==v]
exceeds command line length limit for packages with many dependencies.

@yolabingo yolabingo changed the title allow 'pipx install' to pre-install from requirements.txt file allow 'pipx install' to preinstall from requirements.txt file Aug 30, 2024
@Gitznik Gitznik added the enhancement New feature or request label Sep 2, 2024
@yolabingo yolabingo changed the title allow 'pipx install' to preinstall from requirements.txt file allow 'pipx install' to preinstall from requirements.txt files Sep 5, 2024
yolabingo added a commit to yolabingo/pipx that referenced this issue Sep 5, 2024
yolabingo added a commit to yolabingo/pipx that referenced this issue Sep 6, 2024
@yolabingo
Copy link
Author

yolabingo commented Sep 7, 2024

PR #1536 provides this feature by adding a new option
pipx install --preinstall-from-file

pipx install --help
usage: pipx install [-h] [--quiet] [--verbose] [--global] [--include-deps] [--force] [--suffix SUFFIX]
                    [--python PYTHON] [--fetch-missing-python] [--preinstall PREINSTALL]
                    [--system-site-packages] [--index-url INDEX_URL] [--editable] [--pip-args PIP_ARGS]
                    [--preinstall-from-file PREINSTALL_FROM_FILE]
                    package_spec [package_spec ...]
options:
  --preinstall PREINSTALL
                        Optional package to be installed into the Virtual Environment before installing the
                        main package. Use this flag multiple times if you want to preinstall multiple packages.
  --preinstall-from-file PREINSTALL_FROM_FILE
                        Absolute path to requirements file listing optional packages to be preinstalled into
                        the Virtual Environment before installing the main package. Use this flag multiple
                        times for multiple files.

@uranusjr suggested another approach

I wonder if it’d be possible to merge this with the regular preinstall syntax. Since the regular dependency specification syntax is quite limiting, maybe we can easily detect special formats like requirements::path/to/requirements.txt? Not sure what kind of syntax is best.

Or maybe even something like pipx install app --preinstall '-r requirements.txt' can be reasonable?

Soliciting for any other suggestions on how best to proceed.

I agree that extending the functionality of --preinstall initially feels cleaner. I decided to add a new option instead for a few reasons:

  1. no need to modify existing --preinstall behavior or tests
  2. seems in the spirit of "explicit is better than implicit"
  3. adding a new option allows for clearly conveying the new behavior in pipx install --help, otherewise the help text for --preinstall became unwieldy

I will gladly defer to the pipx maintainers on what you want this to look like and submit a PR adhering to your suggestions. Thanks for your ongoing efforts. Pipx is awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants