A collection of PowerShell scripts to streamline common tasks during the development of projects written in Python or using tools written in Python (pre-commit, Bump My Version, Material for MkDocs, …), inspired by Scripts to Rule Them All. Requires uv
0.8.18+.
- Download and unzip a release, or clone this project.
- Copy the
scripts
subfolder into your project. - Customize the scripts as you like, add your own, and delete what you do not need.
- Create or edit the
pyproject.toml
of your project:- Use the
requires-python
entry to specify the Python version you want to use. - List the dependencies of the tools you use in the
dev
dependency group. - If your project does not include a Python package, do not define the
[build-system]
table.
- Use the
- Profit.
Bootstrap.ps1
Bootstrap a development environment.New-PythonVenv.ps1
Create or refresh a Python virtual environment.Install-PreCommitHooks.ps1
Install pre-commit hooks.Update-PreCommitHooks.ps1
Update pre-commit hooks.Set-VenvOutsideProject.ps1
Telluv
to store the Python virtual environment outside the project folder. Useful to avoid problems with Microsoft OneDrive.Update-Scripts.ps1
Upgrade (or downgrade) the scripts to the specified released version. Requires robocopy.
Build-Package.ps1
Build source distribution and wheel, then expand them for inspection.Release-Project.ps1
Bump the project version, tag a release, and push toorigin
.
Build-Docs.ps1
Build the documentation.Serve-Docs.ps1
Start a live preview server to view the documentation while editing it.
Use Get-Help
to show the documentation of each script:
PS> Get-Help .\scripts\Release-Project.ps1 -Detailed
Instead of copying, you can include the scripts
repository as a submodule of your project. On Windows, this can be achieved as follows:
-
Enable Windows Developer Mode to be able to create symbolic links without administrative rights.
-
Enable symbolic links in
git
:PS> git config --global core.symlinks true
-
From within your project, add
scripts
as a submodule, and create a symbolic link in the project folder.PS> git submodule add https://github.com/angelo-peronio/scripts.git submodules/scripts PS> New-Item -ItemType SymbolicLink -Path scripts -Target .\submodules\scripts\scripts\
-
Remember to clone your project with
git clone --recurse
-
After cloning on Windows, the
scripts
symbolic link will not work. Recreate it:PS> Remove-Item scripts PS> git restore scripts
uv sync --upgrade
is used to create the Python virtual environment with the latest version of the dependencies,uv run
is used to activate it.- Environment variables are automatically loaded from a
.env
file in the project root folder, if present. This mechanism is used to optionally store the virtual environment outside the project folder, untiluv
will support this natively.
Other common ways to reach the same goal: