Skip to content

Python First Commit

info-rchitect edited this page Jan 6, 2020 · 4 revisions
  1. Create your Python source code at o2/python/origen. Your Python file must import the origen module as so:
import origen
  1. If you need to use new Python dependencies, you must add them to the o2/pyproject.toml file under [tool.poetry.dependencies]. After you add the new dependencies you must run poetry update from the o2/example directory. For more info, see this guide.
[tool.poetry.dependencies]
python = "^3.6"
termcolor = ">= 1.1.0"
pyreadline = { "version" = "^2.1",  "platform" = "win32" }
colorama = "^0.4"
bs4 = "0.0.1"
beautifulsoup4 = "4.8.2"
lxml = "4.4.2"
# Your new dependencies go here
  1. Create a unit test Python file at o2/example/tests. The file name must end with _test.py. It also must import the origen module, the unit test methods must start with test, and one of example DUTs must be isntantiated as so:
import origen

def test_translator_ip_xact():
    origen.app.instantiate_dut("dut.falcon")
    # Your unit tests go here
    # https://docs.pytest.org/en/latest/
  1. Once you have written unit tests you must run pytest from the o2/example directory as so:
info-rchitect@D10-brian:/mnt/c/o2/example$ poetry run pytest tests/translator_test.py
========================================== test session starts ==========================================
platform linux -- Python 3.8.1, pytest-3.10.1, py-1.8.1, pluggy-0.13.1
rootdir: /mnt/c/o2/example, inifile: setup.cfg
collected 1 item

tests/translator_test.py .                                                                        [100%]

======================================= 1 passed in 0.21 seconds ========================================
  1. Once the unit tests are passing, create your branch and make a PR via Git
Clone this wiki locally