Effortless Python Project Setup with py-setup-tool
A quick guide to py-setup-tool, a simple shell script that automates Python project initialization, including virtual environment creation and dependency installation.
Every Python developer knows the ritual. You start a new project, and the first few minutes are always the same:
- Create a virtual environment:
python -m venv .venv
- Activate it:
source .venv/bin/activate
- Upgrade pip:
pip install --upgrade pip
- Install dependencies:
pip install -r requirements.txt
These steps, while essential, are pure boilerplate. They're a tax you pay every time you start something new. What if you could automate this entire process with a single command?
That's why I created py-setup-tool
, a simple, self-contained shell script designed to do just that.
What is py-setup-tool?
py-setup-tool
is a shell script (pysetup.sh
) that you drop into the root of your Python project. It automates the creation of a virtual environment and the installation of your project's dependencies, ensuring a consistent and reproducible setup every time.
It's designed to be simple, with no external dependencies of its own.
How It Works
Using the tool is as easy as running the script. First, make it executable:
chmod +x ./pysetup.sh
Then, run it to initialize your project:
./pysetup.sh
The script will:
- Create a Python virtual environment (typically in a
.venv
directory). - Activate the environment.
- Install or update the dependencies listed in your
requirements.txt
or other specified dependency files.
Keeping It Updated
The script can even update itself. By default, it will ask if you want to pull the latest version. You can control this behavior with flags:
./pysetup.sh -u
or./pysetup.sh --update
: Always fetches the latest version without prompting../pysetup.sh -n
or./pysetup.sh --no-update
: Skips the update check entirely.
This ensures you can easily keep your project setup tooling consistent across all your repositories.
Getting Started
Ready to eliminate those repetitive setup steps?
- Grab the
pysetup.sh
script from the py-setup-tool GitHub repository. - Place it in the root of your Python project.
- Make it executable and run it.
That's it. Your environment is ready to go.
Conclusion
Sometimes the best developer tools are the simplest ones. py-setup-tool
isn't a complex framework; it's a productivity script that shaves off a few minutes of repetitive work from the start of every new project. By automating your setup process, you create a more consistent and efficient workflow for yourself and your team.
Give it a try in your next project and enjoy a slightly faster start.