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

Issue #1525 Preinstall from requirements file #1536

Closed

Conversation

yolabingo
Copy link

  • I have added a news fragment under changelog.d/ (if the patch affects the end users)

Summary of changes

Test plan

Confirm venv includes packages specified in requirements files

Tested by running

$ echo "httpx==0.27.0" > /tmp/httpx-req.txt
$ echo "attrs==23.1.0" > /tmp/attrs-req.txt
$ pipx install -v --preinstall-from-file /tmp/httpx-req.txt --preinstall-from-file /tmp/attrs-req.txt dunk
pipx >(setup:1119): pipx version is 0.1.dev811+gfd6d5e5
pipx >(setup:1120): Default python interpreter is '/usr/bin/python3.9'
pipx >(package_name_from_spec:381): Determined package name: dunk
pipx >(package_name_from_spec:382): Package name determined in 0.0s
pipx >(create_venv:164): Creating virtual environment
creating virtual environment...
pipx >(run_subprocess:175): running /usr/bin/python3.9 -m venv --without-pip /home/yolabingo/.local/share/pipx/venvs/dunk
pipx >(run_subprocess:175): running <checking pip's availability>
pipx >(run_subprocess:175): running /home/yolabingo/.local/share/pipx/venvs/dunk/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:175): running /home/yolabingo/.local/share/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:175): running /home/yolabingo/.local/share/pipx/venvs/dunk/bin/python --version
pipx >(install_packages_from_file:350): Preinstalling requirements from '['/tmp/httpx-req.txt', '/tmp/attrs-req.txt']'
Preinstalling requirements from '['/tmp/httpx-req.txt', '/tmp/attrs-req.txt']'...
pipx >(run_subprocess:175): running /home/yolabingo/.local/share/pipx/venvs/dunk/bin/python -m pip --no-input install --no-deps --requirement /tmp/httpx-req.txt --requirement /tmp/attrs-req.txt
pipx >(_parsed_package_to_package_or_url:139): cleaned package spec: dunk
pipx >(install_package:247): Installing dunk
installing dunk...
pipx >(run_subprocess:175): running /home/yolabingo/.local/share/pipx/venvs/dunk/bin/python -m pip --no-input install dunk
pipx >(run_subprocess:175): running <fetch_info_in_venv commands>
pipx >(get_venv_metadata_for_package:361): get_venv_metadata_for_package: 65ms
pipx >(_parsed_package_to_package_or_url:139): cleaned package spec: dunk
  installed package dunk 0.4.0a0, installed using Python 3.9.2
  These apps are now globally available
    - dunk

$ ${HOME}/.local/share/pipx/venvs/dunk/bin/python -m pip freeze
attrs==23.1.0
commonmark==0.9.1
dunk==0.4.0a0
httpx==0.27.0
pkg_resources==0.0.0
Pygments==2.18.0
rich==12.6.0
unidiff==0.7.5

@yolabingo yolabingo changed the title Preinstall from requirements file Issue #1525 Preinstall from requirements file Sep 6, 2024
@uranusjr
Copy link
Member

uranusjr commented Sep 6, 2024

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?

@yolabingo
Copy link
Author

yolabingo commented Sep 7, 2024

@uranusjr thanks for the prompt feedback. Trade-offs abound of course.

Perhaps we should consider this a POC, and we can hash out the details on the issue
allow 'pipx install' to preinstall from requirements.txt files #1525
I will gladly defer to the maintainers as far implementation details, and I can resubmit a new PR adhering to the maintainers' decisions.

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

Successfully merging this pull request may close these issues.

2 participants