Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ Search open/closed issues before submitting. Someone may have reported the same
* Operating system and version: [e.g. Windows 11 24H2, Ubuntu Linux 24.04]
* NI-Sync version: [e.g. 2024 Q4]
* `nisync-python` version: [e.g. 1.0.1]
* Python version [e.g. 3.9]
* Python version [e.g. 3.11]
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ on:
jobs:
build:
name: Build
runs-on:
runs-on:
- ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- name: Check out repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
- name: Check Poetry version
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/run_acceptance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@ jobs:
strategy:
matrix:
configuration: ["win-10-py32", "win-10-py64"]
python-version: ["3.11", "3.12"]
# Fail-fast skews the pass/fail ratio and seems to make pytest produce
# incomplete JUnit XML results.
fail-fast: false
timeout-minutes: 90
steps:
- name: Check out repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.configuration == 'win-10-py32' && 'x86' || 'x64' }}
- name: Install dependencies
run: poetry install
- name: Run acceptance tests for PXIe-6674T
run: poetry run pytest --resource_name="6674T" --junitxml=test_results/acceptance-${{ matrix.configuration }}.xml
run: poetry run pytest --resource_name="6674T" --junitxml=test_results/acceptance-${{ matrix.configuration }}-py${{ matrix.python-version }}.xml
- name: Upload test results
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test_results_acceptance_${{ matrix.configuration }}
name: test_results_acceptance_${{ matrix.configuration }}_py${{ matrix.python-version }}
path: test_results/*.xml
if: always()
2 changes: 1 addition & 1 deletion .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12"]
# Fail-fast skews the pass/fail ratio and seems to make pytest produce
# incomplete JUnit XML results.
fail-fast: false
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
* [0.1.0](#010)
* [0.2.0](#020)
* [0.2.1](#021)
* [0.2.2](#022)

All notable changes to this project will be documented in this file.
## 0.2.2
* ### Merged Pull Requests
[Update to Hardware Manager references and device screenshots](https://github.com/ni/nisync-python/pull/76)
[Update minimum supported python version to 3.11](https://github.com/ni/nisync-python/pull/77)
## 0.2.1
* ### Resolved issue
[68: DriverNotInstalledError mentions the wrong driver](https://github.com/ni/nisync-python/issues/68)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ system.

## Python Version Support

**nisync** supports CPython 3.9+ and PyPy3.
**nisync** supports CPython 3.11+ and PyPy 3.11+.

# Installation

Expand Down
6 changes: 3 additions & 3 deletions _metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was generated

from .attributes import attributes
from .constants import constants
from .functions import functions
from _metadata.attributes import attributes
from _metadata.constants import constants
from _metadata.functions import functions
931 changes: 535 additions & 396 deletions poetry.lock

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions prepublish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env python3
"""Check the latest published version before publishing."""

import json
import os
import subprocess
import sys
import tomllib
from pathlib import Path
from urllib.request import urlopen


ROOT_DIR = Path(__file__).resolve().parent
VENV_DIR = ROOT_DIR / ".venv"


def get_project_metadata(key: str) -> str:
"""Read a value from the Poetry project section in pyproject.toml."""
try:
with (ROOT_DIR / "pyproject.toml").open("rb") as pyproject_file:
metadata = tomllib.load(pyproject_file)
value = metadata["tool"]["poetry"][key]
except (KeyError, TypeError) as error:
raise ValueError(f"Could not find the project {key} in [tool.poetry]") from error
return value


def get_project_name() -> str:
"""Read the Poetry project name from pyproject.toml."""
return get_project_metadata("name")


def get_project_version() -> str:
"""Read the Poetry project version from pyproject.toml."""
return get_project_metadata("version")


def get_latest_published_version(project_name: str) -> str:
"""Query PyPI for the latest published project version."""
url = f"https://pypi.org/pypi/{project_name}/json"
with urlopen(url, timeout=10) as response:
payload = json.load(response)

try:
version = payload["info"]["version"]
except (KeyError, TypeError) as error:
raise ValueError("PyPI returned a response without a project version") from error

return version


def prepare_virtual_environment() -> None:
"""Create .venv if needed, upgrade publishing tools, and build the package."""
venv_python = VENV_DIR / ("Scripts/python.exe" if os.name == "nt" else "bin/python")
if not venv_python.is_file():
print("Creating .venv...")
subprocess.run([sys.executable, "-m", "venv", str(VENV_DIR)], check=True)
else:
print("Using existing .venv...")

for package in ("pip", "build", "twine"):
print(f"Upgrading {package} in .venv...")
subprocess.run(
[str(venv_python), "-m", "pip", "install", "--upgrade", package],
check=True,
)

print("Building package in .venv...")
subprocess.run([str(venv_python), "-m", "build"], cwd=ROOT_DIR, check=True)


def print_publish_instructions() -> None:
"""Show how to activate .venv if needed and upload the built distributions."""
if Path(sys.prefix).resolve() != VENV_DIR.resolve():
print()
print("Activate the project .venv before publishing:")
if os.name == "nt":
print(r" PowerShell: .\.venv\Scripts\Activate.ps1")
print(r" Command Prompt: .venv\Scripts\activate.bat")
else:
print(" source .venv/bin/activate")

print("Publish with:")
print(" python -m twine upload dist/*")


def main() -> int:
"""Check the published version and prepare the publishing environment."""
try:
project_name = get_project_name()
project_version = get_project_version()
version = get_latest_published_version(project_name)
except (OSError, ValueError) as error:
print(f"Unable to check the latest published version: {error}", file=sys.stderr)
return 1

if project_version == version:
print(f"The current version {project_version} has already been published.", file=sys.stderr)
return 1

print(f"Latest published version of {project_name}: {version}")
print(f"Preparing to publish version {project_version}...")
try:
prepare_virtual_environment()
except (OSError, subprocess.CalledProcessError) as error:
print(f"Unable to prepare the publishing environment: {error}", file=sys.stderr)
return 1

print_publish_instructions()
return 0


if __name__ == "__main__":
raise SystemExit(main())
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nisync"
version = "0.2.1"
version = "0.2.2"
description = "NI-Sync Python API"
authors = ["NI <opensource@ni.com>"]
maintainers = ["NI <opensource@ni.com>"]
Expand All @@ -15,8 +15,6 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
Expand All @@ -27,7 +25,7 @@ classifiers = [
include = ["nisync/*"]

[tool.poetry.dependencies]
python = "^3.9"
python = "^3.11"
hightime = "*"

[tool.poetry.group.dev.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions templates/_metadata/__init__.py.mako
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was generated

from .attributes import attributes
from .constants import constants
from .functions import functions
from _metadata.attributes import attributes
from _metadata.constants import constants
from _metadata.functions import functions
Loading