Skip to content

Conversation

@zemkogabor
Copy link

Simple Dockerfile for this package.

@ernstki
Copy link

ernstki commented Dec 11, 2025

This will be useful if you have Docker but no Python, or had trouble getting the dependencies installed. If you think about it, though, you're pulling a small Debian operating system image across the InterWebs and spinning up a server just to run one Python program.

If you already have a Python interpreter on the host system, or another similar system, you might be happier deploying a zipapp. Because rotate-backups has a lot of dependencies, Python's built-in zipapp module won't cut it here. In spite of its terrible name, the shiv utility works as advertised:

git clone https://github.com/xolox/python-rotate-backups.git
cd python-rotate-backups
shiv -c rotate-backups -o rotate-backups .
./rotate-backups --help

That rotate-backups file is basically a ZIP archive with #!/usr/bin/env python3 at the top. It can then be copied anywhere with a compatible Python interpreter; all dependencies are included inside. After running it once, the archive is extracted to ~/.shiv for faster subsequent startups.

If you don't already have shiv installed somewhere else (e.g. with pip install --user or pipx), it would be fine to create a virtualenv within the rotate-backups source and then throw it away later:

python -m venv venv
. venv/bin/activate  # or venv/Scripts/Activate.ps1 on Windows
pip install shiv
shiv --help

One caveat: Windows doesn't understand Unix "shebang" lines without hacks and workarounds, so you may need to add a .py extension to the zipapp in order to use it on that platform.

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