Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@ Possible sections in each release:
* Security: in case of vulnerabilities.


### [v0.24.0] - 15-09-2025

Changed:

* Backwards incomatible changes to the imgui version and adapter:
* Update imgui to v1.92 by @panxinmiao in https://github.com/pygfx/wgpu-py/pull/725.
* Fix ImguiRenderer and simplify gui callback function by @panxinmiao in https://github.com/pygfx/wgpu-py/pull/730

Deprecated:

* Remove wgpu.gui canvases by @almarklein in https://github.com/pygfx/wgpu-py/pull/735
* For now, the ``from wgpu.gui.auto import WgpuCavas`` is still supported, but returns a ``rendercanvas.RenderCanvas``.

Other:

* Bump wgpu native to 25.0.2.2 by @Vipitis in https://github.com/pygfx/wgpu-py/pull/740
* Remove additional call to `._release` by @Vipitis in https://github.com/pygfx/wgpu-py/pull/732
* Update _version.py by @almarklein in https://github.com/pygfx/wgpu-py/pull/733
* Switch to trusted publishing for PyPI publish in CI by @EpicWink in https://github.com/pygfx/wgpu-py/pull/738


### [v0.23.0] - 11-07-2025

Added:
Expand Down
73 changes: 39 additions & 34 deletions wgpu/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
_version.py v1.2
_version.py v1.4

Simple version string management, using a hard-coded version string
for simplicity and compatibility, while adding git info at runtime.
Expand All @@ -14,14 +14,15 @@
* On a new release, you just update the __version__.
"""

# ruff: noqa: RUF100, S310, PLR2004, D212, D400, D415, S603, BLE001, COM812

import logging
import subprocess
from pathlib import Path


# This is the base version number, to be bumped before each release.
# The build system detects this definition when building a distribution.
__version__ = "0.23.0"
__version__ = "0.24.0"

# Set this to your library name
project_name = "wgpu"
Expand All @@ -30,21 +31,20 @@
logger = logging.getLogger(project_name)

# Get whether this is a repo. If so, repo_dir is the path, otherwise None.
# .git is a dir in a normal repo and a file when in a submodule.
repo_dir = Path(__file__).parents[1]
repo_dir = repo_dir if repo_dir.joinpath(".git").is_dir() else None
repo_dir = repo_dir if repo_dir.joinpath(".git").exists() else None


def get_version():
def get_version() -> str:
"""Get the version string."""
if repo_dir:
return get_extended_version()
else:
return __version__
return __version__


def get_extended_version():
def get_extended_version() -> str:
"""Get an extended version string with information from git."""

release, post, labels = get_version_info_from_git()

# Sample first 3 parts of __version__
Expand All @@ -54,9 +54,9 @@ def get_extended_version():
if not release:
release = base_release
elif release != base_release:
logger.warning(
warning(
f"{project_name} version from git ({release})"
+ f" and __version__ ({base_release}) don't match."
f" and __version__ ({base_release}) don't match."
)

# Build the total version
Expand All @@ -71,14 +71,14 @@ def get_extended_version():
return version


def get_version_info_from_git():
"""Get (release, post, labels) from Git.
def get_version_info_from_git() -> str:
"""
Get (release, post, labels) from Git.

With `release` the version number from the latest tag, `post` the
number of commits since that tag, and `labels` a tuple with the
git-hash and optionally a dirty flag.
"""

# Call out to Git
command = [
"git",
Expand All @@ -90,9 +90,9 @@ def get_version_info_from_git():
"--first-parent",
]
try:
p = subprocess.run(command, cwd=repo_dir, capture_output=True)
p = subprocess.run(command, check=False, cwd=repo_dir, capture_output=True)
except Exception as e:
logger.warning(f"Could not get {project_name} version: {e}")
warning(f"Could not get {project_name} version: {e}")
p = None

# Parse the result into parts
Expand All @@ -102,7 +102,7 @@ def get_version_info_from_git():
output = p.stdout.decode(errors="ignore")
if p.returncode:
stderr = p.stderr.decode(errors="ignore")
logger.warning(
warning(
f"Could not get {project_name} version.\n\nstdout: "
+ output
+ "\n\nstderr: "
Expand All @@ -120,16 +120,23 @@ def get_version_info_from_git():
return release, post, labels


def _to_tuple(v):
"""Convert __version__ to version_info tuple."""
def version_to_tuple(v: str) -> tuple:
v = __version__.split("+")[0] # remove hash
return tuple(int(i) if i.isnumeric() else i for i in v.split("."))


def prnt(m: str) -> None:
sys.stdout.write(m + "\n")


def warning(m: str) -> None:
logger.warning(m)


# Apply the versioning
base_version = __version__
__version__ = get_version()
version_info = _to_tuple(__version__)
version_info = version_to_tuple(__version__)


# The CLI part
Expand All @@ -149,41 +156,39 @@ def _to_tuple(v):
import urllib.request

_, *args = sys.argv
this_file = Path(__file__)

if not args:
print(f"{project_name} v{__version__}")

elif args[0] == "version":
print(f"{project_name} v{__version__}")
if not args or args[0] == "version":
prnt(f"{project_name} v{__version__}")

elif args[0] == "bump":
if len(args) != 2:
sys.exit("Expected a version number to bump to.")
new_version = args[1].lstrip("v") # allow '1.2.3' and 'v1.2.3'
if not new_version.count(".") == 2:
if new_version.count(".") != 2:
sys.exit("Expected two dots in new version string.")
if not all(s.isnumeric() for s in new_version.split(".")):
sys.exit("Expected only numbers in new version string.")
with open(__file__, "rb") as f:
with this_file.open("rb") as f:
text = ref_text = f.read().decode()
text = text.replace(base_version, new_version, 1)
with open(__file__, "wb") as f:
with this_file.open("wb") as f:
f.write(text.encode())
print(f"Bumped version from '{base_version}' to '{new_version}'.")
prnt(f"Bumped version from '{base_version}' to '{new_version}'.")

elif args[0] == "update":
u = "https://raw.githubusercontent.com/pygfx/_version/main/_version.py"
with urllib.request.urlopen(u) as f:
text = ref_text = f.read().decode()
text = text.replace("0.0.0", base_version, 1)
text = text.replace("PROJECT_NAME", project_name, 1)
with open(__file__, "wb") as f:
with this_file.open("wb") as f:
f.write(text.encode())
print("Updated to the latest _version.py.")
prnt("Updated to the latest _version.py.")

elif args[0].lstrip("-") in ["h", "help"]:
print(CLI_USAGE)
prnt(CLI_USAGE)

else:
print(f"Unknown command for _version.py: {args[0]!r}")
print("Use ``python _version.py help`` to see a list of options.")
prnt(f"Unknown command for _version.py: {args[0]!r}")
prnt("Use ``python _version.py help`` to see a list of options.")
Loading