Skip to content

Commit

Permalink
feat: replace setup.py with poetry (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
esynr3z committed Oct 9, 2024
1 parent 14dc5d4 commit 206f228
Show file tree
Hide file tree
Showing 8 changed files with 978 additions and 92 deletions.
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
fail_fast: true
repos:
- repo: local
hooks:
- id: ruff_format
name: Python format check
entry: poetry run ruff format --check --diff
language: system
types: [file, python]
stages: [pre-commit]
- id: ruff_lint
name: Python lint check
entry: poetry run ruff check
language: system
types: [file, python]
stages: [pre-commit]
- id: pyright
name: Python type check
entry: poetry run pyright
language: system
types: [file, python]
stages: [pre-commit]
- id: check-yaml
name: YAML check
entry: poetry run check-yaml
language: python
types: [yaml]
stages: [pre-commit]
- id: check-toml
name: TOML check
entry: poetry run check-toml
language: python
types: [toml]
stages: [pre-commit]
- id: check-json
name: JSON check
entry: poetry run check-json
language: python
types: [json]
stages: [pre-commit]
- id: commitizen
name: Commit style check
stages: [commit-msg]
entry: cz check --commit-msg-file .git/COMMIT_EDITMSG
pass_filenames: false
language: system
25 changes: 16 additions & 9 deletions corsair/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Corsair is a control and status register (CSR) map generator for HDL projects.
It generates HDL code, documentation and other artifacts from CSR map description file.
"""

from __future__ import annotations

__title__ = "corsair"
__description__ = "Control and status register (CSR) map generator for HDL projects."

try:
from ._version import version as __version__
except (ImportError, ModuleNotFoundError) as e:
__version__ = 'git-latest'

from . import config
from .enum import EnumValue
from . import config, generators
from .bitfield import BitField
from .enum import EnumValue
from .reg import Register
from .regmap import RegisterMap
from . import generators
from .version import __version__

__all__ = [
"__version__",
"RegisterMap",
"Register",
"EnumValue",
"BitField",
"config",
"generators",
]
5 changes: 5 additions & 0 deletions corsair/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Separate module to contain version and avoid circular dependencies."""

from __future__ import annotations

__version__ = "0.0.0" # 0.0.0 is standard placeholder for poetry-dynamic-versioning
810 changes: 810 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
in-project = true
97 changes: 97 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[tool.poetry]
name = "corsair"
version = "0.0.0"
description = "Control and Status Register map generator for FPGA/ASIC projects"
authors = ["esynr3z <[email protected]>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/esynr3z/corsair"
documentation = "https://corsair.readthedocs.io/"
keywords = [
"CSR",
"registers",
"generator",
"Verilog",
"SystemVerilog",
"Verilog",
"RAL",
"FPGA",
"ASIC",
]
classifiers = [
"Environment :: Console",
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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 :: MIT License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
]

[tool.poetry.scripts]
corsair = "corsair.__main__:main"

[tool.poetry.dependencies]
python = "^3.8"
pyyaml = "^6.0.2"
jinja2 = "^3.1.4"
wavedrom = "^2.0.3.post3"

[tool.poetry.group.dev.dependencies]
ruff = "^0.6.9"
pre-commit = "^3.5.0"
commitizen = "^3.29.1"
pyright = "^1.1.383"
pre-commit-hooks = "^5.0.0"
pytest = "^8.3.3"

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"

[tool.ruff]
line-length = 120
extend-exclude = ["*"] # need to relax this as codebase is improved

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"D203", # incompatible with D211
"D213", # incompatible with D212
# Offical guide recommends disable these to avoid conflicts with formatter
"W191", # tab-indentation
"E111", # indentation-with-invalid-multiple
"E114", # indentation-with-invalid-multiple-comment
"E117", # over-indented
"D206", # indent-with-spaces
"D300", # triple-single-quotes
"Q000", # bad-quotes-inline-string
"Q001", # bad-quotes-multiline-string
"Q002", # bad-quotes-docstring
"Q003", # avoidable-escaped-quote
"COM812", # missing-trailing-comma
"COM819", # prohibited-trailing-comma
"ISC001", # single-line-implicit-string-concatenation
"ISC002", # multi-line-implicit-string-concatenation
]

[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]

[tool.ruff.format]
docstring-code-format = true

[tool.pyright]
exclude = ["*"] # need to relax this as codebase is improved
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
poetry==1.8.3
poetry-dynamic-versioning[plugin]==1.4.1
83 changes: 0 additions & 83 deletions setup.py

This file was deleted.

0 comments on commit 206f228

Please sign in to comment.