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
9 changes: 4 additions & 5 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
workflow_dispatch:

env:
MAIN_PYTHON_VERSION: '3.12'
DOCUMENTATION_CNAME: 'python-wrapper.scade.docs.pyansys.com'
LIBRARY_NAME: 'ansys-scade-python-wrapper'

Expand All @@ -38,10 +37,10 @@ jobs:
library-name: "ansys-scade-python-wrapper"
repository-name: "ansys/scade-python-wrapper"
is-public: true
main-python-version: '3.12'
# strategies
build-wheelhouse-versions: "['3.10']"
python-tests-versions: "['3.10']"
main-python-version: '3.14'
# 3.7 can't be built anymore
build-wheelhouse-versions: "['3.10', '3.12']"
scade-tests-versions: "['23.1', '25.2', '26.1']"
secrets:
PYANSYS_CI_BOT_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
PYANSYS_CI_BOT_USERNAME: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ celerybeat.pid

# Environments
.env
.venv
.venv37
.venv*
env/
venv/
ENV/
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ The ``ansys-scade-python-wrapper`` package supports only the versions of Python
Ansys SCADE, starting from 2021 R2:

* 2021 R2 through 2023 R1: Python 3.7
* 2023 R2 and later: Python 3.10
* 2023 R2 through 2025 R2: Python 3.10
* 2026 R1 and later: Python 3.12

Ansys SCADE Python Wrapper has two installation modes: user and developer. To install for use,
see `Getting started <https://python-wrapper.scade.docs.pyansys.com/version/stable/getting_started/index.html>`_.
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/58.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump Python and SCADE versions
10 changes: 6 additions & 4 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ to guarantee the project's integrity.

The following ``tox`` commands are provided:

- ``tox -e style``: Checks for coding style quality.
- ``tox -e py``: Checks for unit tests.
- ``tox -e py-coverage``: Checks for unit testing and code coverage.
- ``tox -e doc``: Checks for the documentation-building process.
* ``tox -e code-style``: Checks for coding style quality.
* ``tox -e py-tests``: Checks for unit testing without code coverage.
* ``tox -e py-tests-coverage``: Checks for unit testing with code coverage.
* ``tox -e doc``: Checks for the documentation-building process.
* ``tox -e doc-html``: Builds the HTML documentation.
* ``tox -e doc-links``: Checks for broken links in the documentation.

Use raw testing
^^^^^^^^^^^^^^^
Expand Down
5 changes: 3 additions & 2 deletions doc/source/getting_started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ Requirements
The ``ansys-scade-python-wrapper`` package supports only the versions of Python delivered with
Ansys SCADE, starting from 2021 R2:

* 2021 R2 to 2023 R1: Python 3.7
* 2023 R2 and later: Python 3.10
* 2021 R2 through 2023 R1: Python 3.7
* 2023 R2 through 2025 R2: Python 3.10
* 2026 R1 and later: Python 3.12

Install in user mode
--------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/source/usage/wrapper.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Wrapper
=======
========

Settings
--------
Expand Down
25 changes: 14 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["flit_core >=3.2,<3.13"]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
Expand All @@ -8,9 +8,10 @@ version="2.0.dev0"
description="SCADE code generation target to produce a Python proxy to a SCADE application."
readme="README.rst"

# only 3.7. and 3.10
requires-python = ">=3.7,!=3.8.*,!=3.9.*,<3.11"
license = {file = "LICENSE"}
# only 3.7, 3.10, or >= 3.12
requires-python = ">=3.7,!=3.8.*,!=3.9.*,!=3.11.*"
license = "MIT"
license-files = ["LICENSE"]
authors = [
{name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"},
]
Expand All @@ -20,13 +21,14 @@ maintainers = [
dependencies=[
"importlib-metadata >= 1.0; python_version < '3.8'",
"importlib-metadata >= 4.0; python_version >= '3.8'",
"ansys-scade-apitools",
"ansys-scade-wux",
"ansys-scade-apitools >= 0.5",
"ansys-scade-wux >= 2.3.0",
]
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.12",
"Operating System :: Microsoft :: Windows",
]
keywords=["Scade", "Wrapper", "Integration"]
Expand All @@ -37,9 +39,10 @@ build = [
"twine==6.2.0"
]
tests = [
# 8.0.2 at most: https://github.com/microsoft/PTVS/issues/7853
"pytest==8.4.2",
"pytest-cov==7.0.0"
"pytest >= 8.3.4; python_version >= '3.8'",
"pytest <= 7.4.4; python_version < '3.8'",
"pytest-cov >= 6.0.0; python_version >= '3.8'",
"pytest-cov <= 4.1.0; python_version < '3.8'",
]
doc = [
"ansys-sphinx-theme[autoapi]==1.7.0; python_version >= '3.12'",
Expand Down
26 changes: 19 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@

"""Unit tests utils."""

import os
from pathlib import Path
from subprocess import run
import sys
from typing import Optional

# note: importing apitools modifies sys.path to access SCADE APIs
from ansys.scade.apitools.info import get_scade_home
from ansys.scade.apitools.info import get_scade_home, get_scade_version

# must be imported after apitools
# isort: split
Expand Down Expand Up @@ -79,14 +82,15 @@ def find_configuration(project: std.Project, name: str) -> std.Configuration:
assert False


def build_kcg_proxy(path: Path, configuration: str) -> Path | None:
def build_kcg_proxy(path: Path, configuration: str) -> Optional[Path]:
"""
Build the Python proxy if obsolete or not present.

This requires the package to be registered to the version of SCADE used
to run the tests, which is possible only on host systems, with a manual
installation step.
Requires SCADE 2026 R1/Python 3.12
"""
if get_scade_version() < 261:
return None

project = load_project(path)
# retrieve the configuration
conf = find_configuration(project, configuration)
Expand Down Expand Up @@ -114,10 +118,18 @@ def build_kcg_proxy(path: Path, configuration: str) -> Path | None:
else:
obsolete = False
if obsolete:
env = os.environ
if not env.get('VIRTUAL_ENV'):
# variable not set when tests are run from VS Code or VS 2022
venv = Path(sys.executable).parent.parent.as_posix()
print('setting VIRTUAL_ENV to', venv)
env = env.copy()
env['VIRTUAL_ENV'] = venv
# run scade -code to rebuild the python proxy
exe = get_scade_home() / 'SCADE' / 'bin' / 'scade.exe'
cmd = [exe, '-code', str(path), '-conf', configuration, '-sim']
cp = run(cmd, capture_output=True, encoding='utf-8')
cmd = [str(exe), '-code', str(path), '-conf', configuration, '-sim']
print('cmd:', cmd)
cp = run(cmd, capture_output=True, encoding='utf-8', env=env)
if cp.stdout:
print(cp.stdout)
if cp.stderr:
Expand Down
12 changes: 8 additions & 4 deletions tests/test_int_cvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
import ctypes
from pathlib import Path
import sys
from typing import Optional

import pytest

from ansys.scade.apitools.info import get_scade_version
from conftest import build_kcg_proxy


Expand All @@ -64,18 +66,20 @@ def append(self, text: bytes) -> int:


@pytest.fixture(scope='session')
def proxy_types() -> Path | None:
def proxy_types() -> Optional[Path]:
"""Ensure the proxy is built and up-to-date."""
path = test_dir / 'Types' / 'Model' / 'Model.etp'
return build_kcg_proxy(path, 'Python')


def test_int_cvt(proxy_types):
if proxy_types is None:
# DLL can't be built on GH runners
print('test skipped')
version = get_scade_version()
if version < 261:
print(f'test skipped: requires at least SCADE 2026 R1 (current: v{version})')
return

assert proxy_types is not None

# update sys.path to access the generated files
old_path = sys.path.copy()
sys.path.append(str(proxy_types.parent))
Expand Down
25 changes: 14 additions & 11 deletions tests/test_int_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,30 @@

Verify the output values are identical to the input values for a
significant set of types.

Reminder: The tests using build_kcg_proxy require specific installation
steps, that can't be executed for automated tests on ci-cd runners.
"""

from pathlib import Path
import sys
from typing import Optional

import pytest

from ansys.scade.apitools.info import get_scade_version
from conftest import build_kcg_proxy

# fixtures
test_dir = Path(__file__).parent


@pytest.fixture(scope='session')
def proxy_kcg_types() -> Path | None:
def proxy_kcg_types() -> Optional[Path]:
"""Ensure the proxy is built and up-to-date."""
path = test_dir / 'Types' / 'Model' / 'Model.etp'
return build_kcg_proxy(path, 'Python')


@pytest.fixture(scope='session')
def proxy_kcg_types_io() -> Path | None:
def proxy_kcg_types_io() -> Optional[Path]:
"""Ensure the proxy is built and up-to-date."""
path = test_dir / 'Types' / 'Model' / 'Model.etp'
return build_kcg_proxy(path, 'Python IO')
Expand Down Expand Up @@ -113,11 +112,13 @@ def check_outputs(root, t):

# unit tests
def test_int_kcg_types(proxy_kcg_types):
if proxy_kcg_types is None:
# DLL can't be built on GH runners
print('test skipped')
version = get_scade_version()
if version < 261:
print(f'test skipped: requires at least SCADE 2026 R1 (current: v{version})')
return

assert proxy_kcg_types is not None

# update sys.path to access the generated files
old_path = sys.path.copy()
sys.path.append(str(proxy_kcg_types.parent))
Expand All @@ -140,11 +141,13 @@ def test_int_kcg_types(proxy_kcg_types):


def test_int_kcg_types_io(proxy_kcg_types_io):
if proxy_kcg_types_io is None:
# DLL can't be built on GH runners
print('test skipped')
version = get_scade_version()
if version < 261:
print(f'test skipped: requires at least Python 3.12 (current: v{version})')
return

assert proxy_kcg_types_io is not None

# update sys.path to access the generated files
old_path = sys.path.copy()
sys.path.append(str(proxy_kcg_types_io.parent))
Expand Down
48 changes: 29 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,42 +1,52 @@
[tox]
description = Default tox environments list
envlist = style, tests-coverage, doc-html
# coverage is optional but includes tests: by default run only coverage
# env_list = code-style, py{37,310,312}-tests{-coverage,}, doc-{links,html}
env_list = code-style, py{37,310,312}-tests-coverage, doc-{links,html}
skip_missing_interpreters = true
isolated_build = true
isolated_build_env = build

[testenv]
description = Checks for project unit tests and coverage (if desired)
basepython =
tests310: python3.10
{style,tests,doc}: python3
extras =
tests
[testenv:py{37, 310, 312}-tests{-coverage,}]
description =
Checks for project unit tests
coverage: and coverage
py37: with python version 3.7
py310: with python version 3.10
py312: with python version 3.12
base_python =
py37: python3.7
py310: python3.10
py312: python3.12
extras = tests
setenv =
TEMP = {env_tmp_dir}
TMP = {env_tmp_dir}
PYTHONUNBUFFERED = yes
coverage: PYTEST_EXTRA_ARGS = --cov=ansys.scade.python_wrapper --cov-report=term --cov-report=xml:.cov/xml --cov-report=html:.cov/html --cov-branch
coverage: PYTEST_EXTRA_ARGS = --cov=ansys.scade.python_wrapper --cov-report=term --cov-report=xml:.cov/.{env_name}/xml --cov-report=html:.cov/.{env_name}/html --cov-branch
passenv =
ANSYSLMD_LICENSE_FILE
commands =
pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} {posargs:-vv}
python -m pytest -o addopts= {env:PYTEST_EXTRA_ARGS:} {posargs:-vv}

[testenv:style]
[testenv:code-style]
description = Checks project code style
skip_install = true
deps = pre-commit
commands =
pre-commit install
pre-commit run --all-files --show-diff-on-failure

[testenv:doc-{links,html}]
description = Check if documentation links generate properly
description =
Checks
links: the integrity of all external links
html: if html documentation generates properly
base_python = python3
setenv =
links: SPHINXBUILDER = linkcheck
html: SPHINXBUILDER = html
links: BUILDER = linkcheck
html: BUILDER = html
passenv =
BUILD_API
BUILD_EXAMPLES
extras =
doc
extras = doc
commands =
sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxinidir}/doc/_build/{env:SPHINXBUILDER}" --color -vW -b{env:SPHINXBUILDER}
sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxinidir}/doc/_build/{env:BUILDER}" --color -vW -b{env:BUILDER}
Loading