Skip to content

Commit f212bd7

Browse files
committed
feat: add executable version
1 parent 0a2a395 commit f212bd7

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

.github/workflows/release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
run: uv sync --locked --all-extras --dev
3636

3737
- name: Run PowerShell build script
38+
env:
39+
PVM_VERSION: ${{ github.ref_name }}
3840
shell: pwsh
3941
run: |
4042
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,5 @@ __marimo__/
215215
# Streamlit
216216
.streamlit/secrets.toml
217217

218-
dump/
218+
dump/
219+
_version.py

main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
# Use DEBUG in development, INFO in production builds
1414
log_level = logging.DEBUG if os.getenv('PVM_DEV') == '1' else logging.INFO
1515

16+
try:
17+
from src._version import VERSION
18+
except ImportError:
19+
VERSION = "dev"
20+
1621
logging.basicConfig(
1722
level=log_level,
1823
format='[%(asctime)s] [%(levelname)s] [%(name)s] - %(message)s',
@@ -33,6 +38,13 @@ def cli():
3338
description="A lightweight Python version manager for Windows. Install, manage, and switch between multiple Python versions with ease. Downloads official embeddable Python distributions, maintains isolated installations, and uses shims for seamless version switching without modifying system settings or registry."
3439
)
3540

41+
parser.add_argument(
42+
'--version',
43+
action='version',
44+
version=f'pvm {VERSION}',
45+
help='Shows the version of pvm installed'
46+
)
47+
3648
subparsers = parser.add_subparsers(
3749
title="commands",
3850
dest="command",

powershell/build.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@ Write-Host "Building python-version-manager executable..."
33
# Set production mode (INFO level logging), 1 for development (DEBUG level logging)
44
$env:PVM_DEV = "0"
55

6+
# Version from CI (fallback for local builds)
7+
# during CI, version is exposed by github as github.ref_name instead
8+
9+
if (-not $env:PVM_VERSION) {
10+
$env:PVM_VERSION = "dev"
11+
}
12+
13+
"VERSION = `"$env:PVM_VERSION`"" | Set-Content src/_version.py
14+
15+
Write-Host "Building version $($env:PVM_VERSION)"
616
uv run -m PyInstaller --onefile --clean --exclude-module tests --name pvm main.py

0 commit comments

Comments
 (0)