From d2cc64cda1396d6c070c92480342e72fc35dc1c2 Mon Sep 17 00:00:00 2001 From: Alex Mykyta Date: Mon, 16 Oct 2023 21:03:23 -0700 Subject: [PATCH] Rework packaging to use pyproject.toml. Add c-header --- .github/workflows/build.yml | 43 +++++++++++++++++----- docs/for-devs/exporter-plugin.rst | 20 +++-------- docs/for-devs/importer-plugin.rst | 20 +++-------- docs/index.rst | 10 +++--- pyproject.toml | 59 ++++++++++++++++++++++++++++++ setup.py | 60 ------------------------------- src/peakrdl/__about__.py | 2 +- src/peakrdl/py.typed | 0 8 files changed, 108 insertions(+), 106 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py create mode 100644 src/peakrdl/py.typed diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02bd4c4..fb5b015 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,9 @@ on: types: - published + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + jobs: test: strategy: @@ -22,6 +25,7 @@ jobs: - 3.9 - "3.10" - "3.11" + - "3.12" include: - os: ubuntu-latest @@ -34,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: @@ -43,7 +53,18 @@ jobs: run: | python -m pip install -U -r test/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 . @@ -85,7 +106,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install dependencies run: | @@ -118,12 +139,12 @@ jobs: mypy --config-file test/mypy.ini src/peakrdl #------------------------------------------------------------------------------- - build_sdist: + build: needs: - test - lint - mypy - name: Build source distribution + name: Build distributions runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -131,19 +152,25 @@ jobs: - uses: actions/setup-python@v4 name: Install Python with: - python-version: 3.8 + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install -U build - - name: Build sdist - run: python setup.py sdist + - name: Build + 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 diff --git a/docs/for-devs/exporter-plugin.rst b/docs/for-devs/exporter-plugin.rst index 586f78c..8a55a3a 100644 --- a/docs/for-devs/exporter-plugin.rst +++ b/docs/for-devs/exporter-plugin.rst @@ -74,23 +74,13 @@ For consistency, it is recommended to define your plugin descriptor class in a file named ``__peakrdl__.py`` at the root of your package. The example below shows how you would provide an entry point linkage to your -exporter's descriptor class inside your package's ``setup.py``: +exporter's descriptor class inside your package's ``pyproject.toml``: -.. code-block:: python - :emphasize-lines: 7-11 +.. code-block:: toml - import setuptools + [project.entry-points."peakrdl.exporters"] + my-exporter = "my_package.__peakrdl__:MyExporterDescriptor" - setuptools.setup( - name="my_package", - packages=["my_package"], - # ... - entry_points = { - "peakrdl.exporters": [ - 'my-exporter = my_package.__peakrdl__:MyExporterDescriptor' - ] - } - ) * ``my_package``: The name of your installable Python module * ``peakrdl.exporters``: This is the namespace that PeakRDL will search. Any @@ -101,7 +91,7 @@ exporter's descriptor class inside your package's ``setup.py``: * ``my-exporter``: The lefthand side of the assignment is your exporter's subcommand name. This text is what is used in the command line interface. -For a complete example, see `PeakRDL-ipxact's setup.py file `_. +For a complete example, see `PeakRDL-cheader's pyproject.toml file `_. Via the PeakRDL configuration file diff --git a/docs/for-devs/importer-plugin.rst b/docs/for-devs/importer-plugin.rst index e15fbeb..d4701c8 100644 --- a/docs/for-devs/importer-plugin.rst +++ b/docs/for-devs/importer-plugin.rst @@ -74,23 +74,13 @@ For consistency, it is recommended to define your plugin descriptor class in a file named ``__peakrdl__.py`` at the root of your package. The example below shows how you would provide an entry point linkage to your -importer's descriptor class inside your package's ``setup.py``: +importer's descriptor class inside your package's ``pyproject.toml``: -.. code-block:: python - :emphasize-lines: 7-11 +.. code-block:: toml - import setuptools + [project.entry-points."peakrdl.importers"] + my-importer = "my_package.__peakrdl__:MyImporterDescriptor" - setuptools.setup( - name="my_package", - packages=["my_package"], - # ... - entry_points = { - "peakrdl.importers": [ - 'my-importer = my_package.__peakrdl__:MyImporterDescriptor' - ] - } - ) * ``my_package``: The name of your installable Python module * ``peakrdl.importers``: This is the namespace that PeakRDL will search. Any @@ -99,8 +89,6 @@ importer's descriptor class inside your package's ``setup.py``: * ``my_package.__peakrdl__:MyImporterDescriptor``: This is the import path that points to your descriptor class definition -For a complete example, see `PeakRDL-ipxact's setup.py file `_. - Via the PeakRDL configuration file diff --git a/docs/index.rst b/docs/index.rst index 1d13fc6..f0a5ac4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,7 +2,7 @@ Introduction ============ PeakRDL is a free and open-source control & status register (CSR) toolchain. -This projects provides a command-line tool that unifies many aspects of register +This project provides a command-line tool that unifies many aspects of register automation centered around the SystemRDL register description language. This tool can: @@ -12,12 +12,9 @@ This tool can: * Generate synthesizable SystemVerilog RTL register blocks. * Create rich and dynamic HTML documentation. * Build a UVM register model abstraction layer. +* Generate a C register abstraction header for software. * ... or extended this tool with your own plugins -.. warning:: - - The PeakRDL command line tool is still in pre-production (v0.x version numbers). - During this time, I may decide to refactor things which could break compatibility. Installing @@ -57,7 +54,8 @@ Links :hidden: :caption: Additional Exporter Docs - regblock + regblock + c-header ip-xact .. toctree:: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ab03b2d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,59 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "peakrdl" +dynamic = ["version"] +requires-python = ">=3.6" +dependencies = [ + "systemrdl-compiler >= 1.27.1, < 2", + "peakrdl-html >= 2.10.1, < 3", + "peakrdl-ipxact >= 3.4.1, < 4", + "peakrdl-regblock >= 0.19.0, < 2", + "peakrdl-systemrdl >= 0.3.0, < 2", + "peakrdl-uvm >= 2.3.0, < 3", + "peakrdl-cheader >= 1.0.0, < 2", + "tomli;python_version<'3.11'", +] + +authors = [ + {name="Alex Mykyta"}, +] +description = "Command-line tool for control/status register automation and code generation." +readme = "README.md" +license = {file = "LICENSE"} +keywords = [ + "SystmRDL", "PeakRDL", "CSR", "compiler", "tool", "registers", "generator", + "C", "header", "software", "Verilog", "SystemVerilog", "register abstraction layer", + "FPGA", "ASIC", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "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)", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)", +] + +[project.urls] +Source = "https://github.com/SystemRDL/PeakRDL" +Tracker = "https://github.com/SystemRDL/PeakRDL/issues" +Changelog = "https://github.com/SystemRDL/PeakRDL/releases" +Documentation = "https://peakrdl.readthedocs.io/" + +[tool.setuptools.dynamic] +version = {attr = "peakrdl.__about__.__version__"} + +[project.scripts] +peakrdl = "peakrdl.main:main" diff --git a/setup.py b/setup.py deleted file mode 100644 index b46494c..0000000 --- a/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -import os -import setuptools - -with open("README.md", "r", encoding='utf-8') as f: - long_description = f.read() - - -with open(os.path.join("src/peakrdl", "__about__.py"), "r", encoding='utf-8') as f: - v_dict = {} - exec(f.read(), v_dict) - version = v_dict['__version__'] - -setuptools.setup( - name="peakrdl", - version=version, - author="Alex Mykyta", - author_email="amykyta3@github.com", - description="Command-line tool for control/status register automation", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/SystemRDL/PeakRDL", - packages=setuptools.find_packages("src"), - package_dir={"": "src"}, - include_package_data=True, - entry_points = { - "console_scripts": ['peakrdl = peakrdl.main:main'] - }, - python_requires='>=3.6', - install_requires=[ - "systemrdl-compiler >= 1.26.0, < 2", - "peakrdl-html >= 2.10.1, < 3", - "peakrdl-ipxact >= 3.4.1, < 4", - "peakrdl-regblock >= 0.18.0", - "peakrdl-systemrdl >= 0.3.0", - "peakrdl-uvm >= 2.3.0, < 3", - "tomli;python_version<'3.11'" - ], - 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 :: Only", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Operating System :: OS Independent", - "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)", - ), - project_urls={ - "Documentation": "https://peakrdl.readthedocs.io", - "Source": "https://github.com/SystemRDL/PeakRDL", - "Tracker": "https://github.com/SystemRDL/PeakRDL/issues", - "Changelog": "https://github.com/SystemRDL/PeakRDL/releases", - }, -) diff --git a/src/peakrdl/__about__.py b/src/peakrdl/__about__.py index 3e2f46a..5becc17 100644 --- a/src/peakrdl/__about__.py +++ b/src/peakrdl/__about__.py @@ -1 +1 @@ -__version__ = "0.9.0" +__version__ = "1.0.0" diff --git a/src/peakrdl/py.typed b/src/peakrdl/py.typed new file mode 100644 index 0000000..e69de29