Closed johnziebro closed 3 years ago
Thank you for a useful module. Just wanted to provide some insights for anyone who may have questions later. Some of this could be useful in the readme. Closing this as a non-issue.
Hi @johnziebro,
As this a useful content, I decided to put it on the Wiki of the project : https://github.com/montag451/pypi-mirror/wiki/Useful-Insights-and-Workflow-with-Virtual-Environment. I think that it's a better place than a bug report :). Thx for your contribution!
Hi @montag451,
In the end I found a much simpler solution. I used your docs recommendation to launch the server from the command line, and added a function to ./~bashrc which launches the mirror in a disconnected screen, and executes pip install with any modules passed as parameters against the local mirror. After the install the screen is exited, shutting down the local mirror. This works on Ubuntu 20.
mirrorinstall() {
screen -S pypimirror -dm bash -c 'python3 -m http.server -d /home/USERNAME/Projects/pypi_mirror/simple 8080' pip install -i http://0.0.0.0:8080 "$@" screen -S pypimirror -X quit }
The benefit of this is that the server only runs and quits just long enough for 'pip install' and no longer, mirror available on-demand. You don't have to mess with CRON or systemd in order to have the server constantly running in the background and saves resources. This solution assumes Pip is configured to trust the local mirror.
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, October 7th, 2021 at 6:07 PM, montag451 @.***> wrote:
Hi @.***(https://github.com/johnziebro),
As this a useful content, I decided to put it on the Wiki of the project : https://github.com/montag451/pypi-mirror/wiki/Useful-Insights-and-Workflow-with-Virtual-Environment. I think that it's a better place than an bug report :). Thx for your contribution!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Even simpler :smile: :
mirrorinstall() {
# Change server path to where the 'simple' directory is located
# Add to ~/.bashrc
# source ~/.bashrc
# run the function on the command line like you would pip
# Ex: mirrorinstall requests numpy pandas
# Since pip is used for the install the modules can be managed with pip commands normally. IE: pip uninstall requests
pip install -i file:///home/USERNAME/Projects/pypi_mirror/simple "$@"
}
Less simple, more useful: https://www.elytixs.com/partially-mirroring-pypi-org/#bonus-bash-pypi-mirror-script
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Saturday, October 9th, 2021 at 1:34 AM, montag451 @.***> wrote:
Even simpler 😄 :
mirrorinstall
() {
#
Change server path to where the 'simple' directory is located
#
Add to ~/.bashrc
#
source ~/.bashrc
#
run the function on the command line like you would pip
#
Ex: mirrorinstall requests numpy pandas
#
Since pip is used for the install the modules can be managed with pip commands normally. IE: pip uninstall requests
pip install -i file:///home/USERNAME/Projects/pypi_mirror/simple
"
$@
"
}
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Virtual Environment New Project Workflow w/ Pyenv*:
Assumes Pyenv installed.
*note global.trusted only affects the venv not base os
Download one or any number of modules as binaries:
pypi-mirror download -d downloads -b pip requests flask
Generate a pypi repository from downloads:
pypi-mirror create -d downloads -m simple
Use python's webserver to serve locally:
python3 -m http.server 8000
Pip install from the repository untrustingly:
pip install -i http://0.0.0.0:8000/simple requests --trusted-host 0.0.0.0
Upgrade pip from local trusted mirror (if pip is mirrored)
pip install -i http://localhost:8000/simple --upgrade pip
Install multiple modules from requirements.txt from local mirror trustingly
Install specific modules from local mirror trustingly
pip install -i http://localhost:8000/simple requests flask
Install multiple files from requirements.txt from local mirror untrustingly
Update all installed modules
pypi-mirror list -d /path/to/my/download/dir --name-only | xargs pypi-mirror download -d /path/to/my/download/dir
Additional notes on pip's config inside venv:
Simple Python server script. Place in directory above 'simple' directory.