Skip to content

Commit 53e9655

Browse files
authored
Bump version to 0.2.2 (#77)
- [x] This contribution adheres to [CONTRIBUTING.md](https://github.com/ni/nisync-python/blob/main/CONTRIBUTING.md). ### What does this Pull Request accomplish? - Update nisync API version from 0.2.1 to 0.2.2 - Update minimum supported python version to 3.11 - Added a prepublish.py convenient script ### Why should this Pull Request be merged? The pyproject.toml version needs to be incremented to publish to PyPI ### What testing has been done? Ran 'poetry run pytest -v'
1 parent ee1df71 commit 53e9655

11 files changed

Lines changed: 679 additions & 412 deletions

File tree

‎.github/ISSUE_TEMPLATE/bug_report.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ Search open/closed issues before submitting. Someone may have reported the same
4646
* Operating system and version: [e.g. Windows 11 24H2, Ubuntu Linux 24.04]
4747
* NI-Sync version: [e.g. 2024 Q4]
4848
* `nisync-python` version: [e.g. 1.0.1]
49-
* Python version [e.g. 3.9]
49+
* Python version [e.g. 3.11]

‎.github/workflows/build.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ on:
66
jobs:
77
build:
88
name: Build
9-
runs-on:
9+
runs-on:
1010
- ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.11", "3.12"]
1114
steps:
1215
- name: Check out repo
1316
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1417
- name: Set up Python
1518
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
19+
with:
20+
python-version: ${{ matrix.python-version }}
1621
- name: Set up Poetry
1722
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
1823
- name: Check Poetry version

‎.github/workflows/run_acceptance_tests.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,26 @@ jobs:
1515
strategy:
1616
matrix:
1717
configuration: ["win-10-py32", "win-10-py64"]
18+
python-version: ["3.11", "3.12"]
1819
# Fail-fast skews the pass/fail ratio and seems to make pytest produce
1920
# incomplete JUnit XML results.
2021
fail-fast: false
2122
timeout-minutes: 90
2223
steps:
2324
- name: Check out repo
2425
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
26+
- name: Set up Python
27+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
architecture: ${{ matrix.configuration == 'win-10-py32' && 'x86' || 'x64' }}
2531
- name: Install dependencies
2632
run: poetry install
2733
- name: Run acceptance tests for PXIe-6674T
28-
run: poetry run pytest --resource_name="6674T" --junitxml=test_results/acceptance-${{ matrix.configuration }}.xml
34+
run: poetry run pytest --resource_name="6674T" --junitxml=test_results/acceptance-${{ matrix.configuration }}-py${{ matrix.python-version }}.xml
2935
- name: Upload test results
3036
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
3137
with:
32-
name: test_results_acceptance_${{ matrix.configuration }}
38+
name: test_results_acceptance_${{ matrix.configuration }}_py${{ matrix.python-version }}
3339
path: test_results/*.xml
3440
if: always()

‎.github/workflows/run_unit_tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, windows-latest]
14-
python-version: ["3.9", "3.10", "3.11", "3.12"]
14+
python-version: ["3.11", "3.12"]
1515
# Fail-fast skews the pass/fail ratio and seems to make pytest produce
1616
# incomplete JUnit XML results.
1717
fail-fast: false

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
* [0.1.0](#010)
33
* [0.2.0](#020)
44
* [0.2.1](#021)
5+
* [0.2.2](#022)
56

67
All notable changes to this project will be documented in this file.
8+
## 0.2.2
9+
* ### Merged Pull Requests
10+
[Update to Hardware Manager references and device screenshots](https://github.com/ni/nisync-python/pull/76)
11+
[Update minimum supported python version to 3.11](https://github.com/ni/nisync-python/pull/77)
712
## 0.2.1
813
* ### Resolved issue
914
[68: DriverNotInstalledError mentions the wrong driver](https://github.com/ni/nisync-python/issues/68)

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ system.
5050

5151
## Python Version Support
5252

53-
**nisync** supports CPython 3.9+ and PyPy3.
53+
**nisync** supports CPython 3.11+ and PyPy 3.11+.
5454

5555
# Installation
5656

‎_metadata/__init__.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file was generated
22

3-
from .attributes import attributes
4-
from .constants import constants
5-
from .functions import functions
3+
from _metadata.attributes import attributes
4+
from _metadata.constants import constants
5+
from _metadata.functions import functions

‎poetry.lock‎

Lines changed: 535 additions & 396 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎prepublish.py‎

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/usr/bin/env python3
2+
"""Check the latest published version before publishing."""
3+
4+
import json
5+
import os
6+
import subprocess
7+
import sys
8+
import tomllib
9+
from pathlib import Path
10+
from urllib.request import urlopen
11+
12+
13+
ROOT_DIR = Path(__file__).resolve().parent
14+
VENV_DIR = ROOT_DIR / ".venv"
15+
16+
17+
def get_project_metadata(key: str) -> str:
18+
"""Read a value from the Poetry project section in pyproject.toml."""
19+
try:
20+
with (ROOT_DIR / "pyproject.toml").open("rb") as pyproject_file:
21+
metadata = tomllib.load(pyproject_file)
22+
value = metadata["tool"]["poetry"][key]
23+
except (KeyError, TypeError) as error:
24+
raise ValueError(f"Could not find the project {key} in [tool.poetry]") from error
25+
return value
26+
27+
28+
def get_project_name() -> str:
29+
"""Read the Poetry project name from pyproject.toml."""
30+
return get_project_metadata("name")
31+
32+
33+
def get_project_version() -> str:
34+
"""Read the Poetry project version from pyproject.toml."""
35+
return get_project_metadata("version")
36+
37+
38+
def get_latest_published_version(project_name: str) -> str:
39+
"""Query PyPI for the latest published project version."""
40+
url = f"https://pypi.org/pypi/{project_name}/json"
41+
with urlopen(url, timeout=10) as response:
42+
payload = json.load(response)
43+
44+
try:
45+
version = payload["info"]["version"]
46+
except (KeyError, TypeError) as error:
47+
raise ValueError("PyPI returned a response without a project version") from error
48+
49+
return version
50+
51+
52+
def prepare_virtual_environment() -> None:
53+
"""Create .venv if needed, upgrade publishing tools, and build the package."""
54+
venv_python = VENV_DIR / ("Scripts/python.exe" if os.name == "nt" else "bin/python")
55+
if not venv_python.is_file():
56+
print("Creating .venv...")
57+
subprocess.run([sys.executable, "-m", "venv", str(VENV_DIR)], check=True)
58+
else:
59+
print("Using existing .venv...")
60+
61+
for package in ("pip", "build", "twine"):
62+
print(f"Upgrading {package} in .venv...")
63+
subprocess.run(
64+
[str(venv_python), "-m", "pip", "install", "--upgrade", package],
65+
check=True,
66+
)
67+
68+
print("Building package in .venv...")
69+
subprocess.run([str(venv_python), "-m", "build"], cwd=ROOT_DIR, check=True)
70+
71+
72+
def print_publish_instructions() -> None:
73+
"""Show how to activate .venv if needed and upload the built distributions."""
74+
if Path(sys.prefix).resolve() != VENV_DIR.resolve():
75+
print()
76+
print("Activate the project .venv before publishing:")
77+
if os.name == "nt":
78+
print(r" PowerShell: .\.venv\Scripts\Activate.ps1")
79+
print(r" Command Prompt: .venv\Scripts\activate.bat")
80+
else:
81+
print(" source .venv/bin/activate")
82+
83+
print("Publish with:")
84+
print(" python -m twine upload dist/*")
85+
86+
87+
def main() -> int:
88+
"""Check the published version and prepare the publishing environment."""
89+
try:
90+
project_name = get_project_name()
91+
project_version = get_project_version()
92+
version = get_latest_published_version(project_name)
93+
except (OSError, ValueError) as error:
94+
print(f"Unable to check the latest published version: {error}", file=sys.stderr)
95+
return 1
96+
97+
if project_version == version:
98+
print(f"The current version {project_version} has already been published.", file=sys.stderr)
99+
return 1
100+
101+
print(f"Latest published version of {project_name}: {version}")
102+
print(f"Preparing to publish version {project_version}...")
103+
try:
104+
prepare_virtual_environment()
105+
except (OSError, subprocess.CalledProcessError) as error:
106+
print(f"Unable to prepare the publishing environment: {error}", file=sys.stderr)
107+
return 1
108+
109+
print_publish_instructions()
110+
return 0
111+
112+
113+
if __name__ == "__main__":
114+
raise SystemExit(main())

‎pyproject.toml‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nisync"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
description = "NI-Sync Python API"
55
authors = ["NI <opensource@ni.com>"]
66
maintainers = ["NI <opensource@ni.com>"]
@@ -15,8 +15,6 @@ classifiers = [
1515
"Operating System :: Microsoft :: Windows",
1616
"Operating System :: POSIX :: Linux",
1717
"Programming Language :: Python :: 3",
18-
"Programming Language :: Python :: 3.9",
19-
"Programming Language :: Python :: 3.10",
2018
"Programming Language :: Python :: 3.11",
2119
"Programming Language :: Python :: 3.12",
2220
"Programming Language :: Python :: Implementation :: CPython",
@@ -27,7 +25,7 @@ classifiers = [
2725
include = ["nisync/*"]
2826

2927
[tool.poetry.dependencies]
30-
python = "^3.9"
28+
python = "^3.11"
3129
hightime = "*"
3230

3331
[tool.poetry.group.dev.dependencies]

0 commit comments

Comments
 (0)