Skip to content

Commit

Permalink
Add equivalent origen version support from OM. Bump origen version to…
Browse files Browse the repository at this point in the history
… dev7.
  • Loading branch information
corey committed Feb 6, 2024
1 parent 44f1db9 commit be52e43
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 17 deletions.
17 changes: 15 additions & 2 deletions python/origen/origen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
import re
import os, pathlib
import importlib_metadata

init_verbosity = 0
cli_path = None
cli_ver = None
Expand Down Expand Up @@ -96,6 +98,7 @@ def __getattr__(name: str):

from origen.tester import Tester, DummyTester
from origen.producer import Producer
from origen_metal.utils.version import Version

import origen.target
targets = origen.target
Expand Down Expand Up @@ -149,12 +152,22 @@ def __getattr__(name: str):
bool
'''

version = _origen.version()
''' Returns the version of the Origen executable.
__version__ = importlib_metadata.version(__name__)
''' Returns the version of Origen.
Returns:
str: Origen executable version
>>> __origen__.version
'{{ origen_version }}'
'''

version = Version(__version__)
''' Returns the version of Origen.
Returns:
origen_metal.utils.version.Version: Origen version
>>> origen.version
'{{ origen_version }}'
'''
Expand Down
2 changes: 1 addition & 1 deletion python/origen/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "origen"
version = "2.0.0.dev6"
version = "2.0.0.dev7"
description = "Semiconductor Developer's Kit"
homepage = "https://origen-sdk.org/o2"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions rust/origen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/origen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "origen"
version = "2.0.0-dev.5"
version = "2.0.0-dev7"
authors = ["Origen-SDK"]
license = "MIT"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion rust/origen/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cli"
version = "2.0.0-dev.5"
version = "2.0.0-dev.7"
authors = ["Origen-SDK"]
edition = "2021"
workspace = ".."
Expand Down
4 changes: 2 additions & 2 deletions rust/pyapi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/pyapi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "origen_pyapi"
version = "2.0.0-dev.5"
version = "2.0.0-dev7"
authors = ["Origen-SDK"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion test_apps/python_app/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test_apps/python_app/templates/dut_info.txt.mako
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Hello from Origen version ${origen.version}!
Hello from Origen version ${origen.__version__}!
Hello from template compiler "${test_renderer_name}"!
The application name is "${origen.app.name}"
6 changes: 3 additions & 3 deletions test_apps/python_app/tests/compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def expected_str_render(self):
@property
def expected_str_render_with_standard_context(self):
# Make sure origen.version isn't woefully broken
assert isinstance(origen.version, str)
assert len(origen.version) > 0
return f"Hello from Origen version {origen.version}!"
assert isinstance(origen.__version__, str)
assert len(origen.__version__) > 0
return f"Hello from Origen version {origen.__version__}!"

@property
def expected_str_render_with_additional_context(self):
Expand Down
18 changes: 18 additions & 0 deletions test_apps/python_app/tests/version_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import origen
from origen_metal.utils.version import Version
from origen_metal._helpers import pip_show

class TestOrigenVersion:
_current_version = None

def current_version(self):
if self._current_version is None:
self._current_version = pip_show('origen', wrap_poetry=True).version
return self._current_version

def test_origen_version(self):
assert isinstance(origen.version, Version)
assert str(origen.version) == self.current_version()

def test_origen_version_str(self):
assert origen.__version__ == self.current_version()
8 changes: 6 additions & 2 deletions test_apps/python_no_app/tests/test_global_invocation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import origen, origen_metal, _origen, getpass, pytest, pathlib, sys
from .shared import working_dir
from python_app_tests.version_test import TestOrigenVersion as T_OrigenVersion

sys.path.insert(-1, str(pathlib.Path(__file__).parent.parent.parent.joinpath("no_workspace")))
from t_invocation_env import T_InvocationBaseTests

def test_import():
assert "2." in origen.version
assert "2." in str(origen.version)

def test_app_is_none():
assert origen.app is None
Expand All @@ -31,4 +32,7 @@ def test_current_user_is_available(self):
@pytest.mark.skip
def test_datastores_are_available(self):
# TEST_NEEDED Datastores in global invocation
assert origen.datastores.keys() == ['ldaps']
assert origen.datastores.keys() == ['ldaps']

class TestVersion(T_OrigenVersion):
pass

0 comments on commit be52e43

Please sign in to comment.