How to update a pip module with tarball or commit
The aim of this page📝 is to explain how to upgrade a pip module from Github-located tarball (.tar.gz
file package) or a git commit. As an illustration, I am using the backage of ytdl.
2 min readSep 4, 2023
from a tarball
<!-- SYNTAX -->
python -m pip install https://github.com/<URL>.tag.gz
<!-- EXAMPLE -->
python -m pip install https://github.com/ytdl-org/ytdl-nightly/releases/download/2023.08.07/youtube-dl-2023.08.07.tar.gz
- Go to a GitHub Repo ⟹ Releases ⟹ Get the package URL of the
tar.gz
from a commit
<!-- SYNTAX -->
python -m pip install '<pip_module> @ git+https://<repo_url>@<commit_id>'
<!-- EXAMPLE -->
python -m pip install 'youtube-dl @ git+https://github.com/ytdl-org/ytdl-nightly@d88609d20f60ea9114a33c7ecacebdd6d135de74'
- Go to a GitHub Repo ⟹ Find a commit to the
main/master
branch you want to install from - You need to know the name of the pip modul, it does not need to be identical with the URLs you’re going to be using
- Find the name of
<pip_module>
withpip list
command - The
repo_url
and thecommit_id
should be straightforwad, just mind the const values in the syntax (two@
s,git+...
, etc.) - For the mechanics of what pip’s doing, see https://adamj.eu/tech/2019/03/11/pip-install-from-a-git-repository/
- This can be automated with say Powershell — the prereq is that you have already cloned the repository locally.
- Once in
$profile
I just runupdate-ytdl
to get the very latest version of the module in question.
# SYNTAX
function update-<module> {
cd "<repo_folder>"
git pull
$latest_SHA = git rev-parse HEAD
write-host "latest SHA: $latest_SHA"
python -m pip install "<module> @ git+https://<repo_URL>@$latest_SHA"
}
# EXAMPLE
function update-ytdl {
cd "C:\Users\Admin\tools\ytdl-nightly"
git pull
$latest_SHA = git rev-parse HEAD
write-host "latest SHA: $latest_SHA"
python -m pip install "youtube-dl @ git+https://github.com/ytdl-org/ytdl-nightly@$latest_SHA"
}
--force reinstall
not very much working for me
- This was noted in https://github.com/ytdl-org/youtube-dl/issues/31530#issuecomment-1435477247, but although the command is working, the version does not get upgraded as expected, so just listing here for completeness
<!-- SYNTAX -->
pip install --upgrade --force-reinstall "git+https://github.com/ytdl-org/youtube-dl.git"
<!-- EXAMPLE -->
pip install --upgrade --force-reinstall "git+https://github.com/ytdl-org/youtube-dl.git"