Skip to content

Commit

Permalink
Prep for release
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed Oct 17, 2023
1 parent 3d1025c commit feea255
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 28 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.7 to bootstrap py3.6
if: ${{ matrix.python-version == '3.6' }}
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -47,7 +53,18 @@ jobs:
run: |
python -m pip install -U -r tests/requirements.txt
# Python 3.6 cannot install directly from a pyproject.toml
# Instead, build a wheel from py3.7 and then install it
- name: Install via wheel
if: ${{ matrix.python-version == '3.6' }}
run: |
python3.7 -m pip install build
python3.7 -m build
python --version
python -m pip install ./dist/*.whl
- name: Install
if: ${{ matrix.python-version != '3.6' }}
run: |
python -m pip install .
Expand Down Expand Up @@ -115,14 +132,14 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U mypy
python -m pip install -U mypy peakrdl
- name: Type Check
run: |
mypy --config-file tests/mypy.ini src/peakrdl_cheader
#-------------------------------------------------------------------------------
build_sdist:
build:
needs:
- test
- lint
Expand All @@ -137,17 +154,23 @@ jobs:
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install -U build
- name: Build sdist
run: python setup.py sdist
run: python -m build

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
path: |
dist/*.tar.gz
dist/*.whl
#-------------------------------------------------------------------------------
deploy:
needs:
- build_sdist
- build

runs-on: ubuntu-latest

Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "peakrdl-cheader"
dynamic = ["version"]
requires-python = ">=3.7"
requires-python = ">=3.6"
dependencies = [
"systemrdl-compiler >= 1.21.0, < 2",
"jinja2",
Expand All @@ -23,11 +23,13 @@ classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
Expand Down
30 changes: 21 additions & 9 deletions src/peakrdl_cheader/c_standards.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
from typing import Dict
from typing import Dict, Tuple
import enum

class CStandard(enum.Enum):

def __init__(self, version: int, d: Dict[str, bool]) -> None:
def __init__(self, name: str, d: Dict[str, bool]) -> None:
self.anon_unions = d.get("anon_unions", False)
self.static_assert = d.get("static_assert", False)
self.static_assert_needs_assert_h = d.get("static_assert_needs_assert_h", False)

# Prevent Enum from flattening members into aliases
self._value_ = version
self._value_ = name

gnu23 = 23, {
gnu23 = "gnu23", {
"anon_unions": True,
"static_assert": True,
}

gnu17 = 17, {
gnu17 = "gnu17", {
"anon_unions": True,
"static_assert": True,
"static_assert_needs_assert_h": True,
}

gnu11 = 11, {
gnu11 = "gnu11", {
"anon_unions": True,
"static_assert": True,
"static_assert_needs_assert_h": True,
}

gnu99 = 99, {}
gnu99 = "gnu99", {
"anon_unions": False,
"static_assert": False,
"static_assert_needs_assert_h": False,
}

gnu90 = 90, {}
gnu90 = "gnu90", {
"anon_unions": False,
"static_assert": False,
"static_assert_needs_assert_h": False,
}

gnu89 = 89, {}
gnu89 = "gnu89", {
"anon_unions": False,
"static_assert": False,
"static_assert_needs_assert_h": False,
}

latest = gnu17 # gnu23 is still unreleased
2 changes: 1 addition & 1 deletion src/peakrdl_cheader/header_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, ds: DesignState) -> None:
self.root_node = None

self.f: TextIO
self.f = None
self.f = None # type: ignore

def run(self, path: str, top_nodes: List[AddrmapNode]) -> None:
with open(path, "w", encoding='utf-8') as f:
Expand Down
Empty file added src/peakrdl_cheader/py.typed
Empty file.
6 changes: 3 additions & 3 deletions src/peakrdl_cheader/testcase_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def __init__(self, ds: DesignState) -> None:
self.root_node = None

self.root_struct_name: str
self.root_struct_name = None
self.root_struct_name = ""

self.f: TextIO
self.f = None
self.f = None # type: ignore

self.overlap_pair_stack: List[List[str]]
self.overlap_pair_stack = []
Expand Down Expand Up @@ -150,7 +150,7 @@ def __init__(self, ds: DesignState) -> None:
self.root_node = None

self.f: TextIO
self.f = None
self.f = None # type: ignore

def run(self, f: TextIO, top_nodes: List[AddrmapNode]) -> None:
self.f = f
Expand Down
3 changes: 0 additions & 3 deletions tests/.mypy.ini

This file was deleted.

8 changes: 3 additions & 5 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,20 @@ def do_export(self):
def do_compile(self):
args = [
"gcc",
"--std", self.std.name,
"--std", self.std.value,
os.path.join(self.output_dir, "out.h.test.c"),
"-o", os.path.join(self.output_dir, "test.exe"),
]
ret = subprocess.run(args, capture_output=True)
ret = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print(" ".join(args))
print(ret.stdout.decode('utf-8'))
print(ret.stderr.decode('utf-8'))
self.assertEqual(ret.returncode, 0)

def do_run(self):
args = [os.path.join(self.output_dir, "test.exe")]
ret = subprocess.run(args, capture_output=True)
ret = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print(" ".join(args))
print(ret.stdout.decode('utf-8'))
print(ret.stderr.decode('utf-8'))
self.assertEqual(ret.returncode, 0)

def do_test(self):
Expand Down
11 changes: 11 additions & 0 deletions tests/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[mypy]
namespace_packages = True
explicit_package_bases = True

[mypy-systemrdl.*]
# Ignore missing py.typed in release
ignore_missing_imports = True

[mypy-peakrdl.*]
# Ignore missing py.typed in release
ignore_missing_imports = True
3 changes: 2 additions & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ source .venv/bin/activate

# Install test dependencies
pip install -U pip setuptools wheel
pip install peakrdl
pip install -r requirements.txt

# Install dut
Expand All @@ -28,4 +29,4 @@ coverage html -i -d htmlcov
pylint --rcfile pylint.rc ../src/peakrdl_cheader

# Run static type checking
#mypy ../src/peakrdl_cheader
mypy ../src/peakrdl_cheader

0 comments on commit feea255

Please sign in to comment.