diff options
author | Andrew Waterman <andrew@sifive.com> | 2025-10-13 16:24:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-10-13 16:24:22 -0700 |
commit | 26e2c04c913a67ac51bf0a354f21f2d7d5c07c40 (patch) | |
tree | 7db4f4637f71f1777f86702a2228ccf3b9217a03 /src/riscv_opcodes/__main__.py | |
parent | 433081c02368eb72e6dea5413e404a8ef231658e (diff) | |
download | riscv-opcodes-master.zip riscv-opcodes-master.tar.gz riscv-opcodes-master.tar.bz2 |
Add pyproject.toml (the modern alternative to requirements.txt), making this a proper Python package that can be installed via pip and potentially uploaded to PyPI.
This also loads the files using `importlib.resources` and installs them into the wheel. This means that when you create a wheel using `uv build` it will still be able to load all the opcodes and CSV files.
To avoid moving those resource files in the source repo, the Python build backend (hatchling) is instructed to move them to the right place when building a wheel, and the `resource_root()` function checks in both places so it always works. This is a little hacky but it works.
CI builds source and binary wheels (not actually binary) that can be uploaded to PyPI. If we do upload them then using this project is as simple as
```
uvx riscv_opcodes -c 'rv*'
```
Co-authored-by: Tim Hutt <timothy.hutt@codasip.com>
Diffstat (limited to 'src/riscv_opcodes/__main__.py')
-rw-r--r-- | src/riscv_opcodes/__main__.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/riscv_opcodes/__main__.py b/src/riscv_opcodes/__main__.py new file mode 100644 index 0000000..456cddd --- /dev/null +++ b/src/riscv_opcodes/__main__.py @@ -0,0 +1,10 @@ +""" +This allows running as a module, i.e. `python3 -m riscv_opcodes` which +we wouldn't normally need, but the `coverage` tool doesn't work on +installed scripts - you can't do `coverage run riscv_opcodes` because it +looks for a Python file called `riscv_opcodes` in the current directory. +""" + +from .parse import main + +main() |