Skip to content

Commit

Permalink
Use UV
Browse files Browse the repository at this point in the history
  • Loading branch information
fchorney committed Feb 15, 2025
0 parents commit dc1305b
Show file tree
Hide file tree
Showing 18 changed files with 1,693 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build
on: [push]

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout

- name: Set up uv
uses: astral-sh/setup-uv

- name: Set up Python
uses: actions/setup-python
with:
python-version: 3.13

- name: Run Tests
run: |
uv sync
tox -e py313
# TODO: Add fix, check, types, coverage, docs, etc
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
on:
workflow_dispatch:
push:
branches: ['main']
jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout

- name: Set up uv
uses: astral-sh/setup-uv

- name: Set up Python
uses: actions/setup-python
with:
python-version: 3.13

- name: Release
run: |
uv build
uv publish --publish-url https://test.pypi.org/legacy/ --trusted-publishing always
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# Virtual environments
.venv

# Coverage
.coverage.*
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13.2
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Fernando Chorney

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PyStructTypes

Leverage Python Types to Define C-Struct Interfaces
28 changes: 28 additions & 0 deletions docs/autoapi_templates/python/module.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{obj.name}}
{{obj.name|length * "="}}

.. automodule:: {{obj.name}}{%- block subpackages %}
{%- if obj.subpackages %}

Subpackages
-----------

.. toctree::
:titlesonly:
:maxdepth: 1
{% for subpackage in obj.subpackages %}
{% if subpackage.display %}{{ subpackage.short_name }}/index.rst{% endif -%}
{%- endfor %}
{%- endif %}{%- endblock -%}{%- block submodules %}
{%- if obj.submodules %}

Submodules
----------

.. toctree::
:titlesonly:
:maxdepth: 1
{% for submodule in obj.submodules %}
{% if submodule.display %}{{ submodule.short_name }}/index.rst{% endif -%}
{%- endfor %}
{%- endif %}{%- endblock -%}
1 change: 1 addition & 0 deletions docs/autoapi_templates/python/package.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/module.rst" %}
99 changes: 99 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from datetime import datetime

from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify

# from pystructtype import __version__


# This exists to fix a bug in recommonmark due to a missing function definition
# https://github.com/readthedocs/recommonmark/issues/177
class CustomCommonMarkParser(CommonMarkParser):
def visit_document(self, node):
pass


# Sphinx Base --------------------------------------------------------------------------
# Extensions
extensions = [
# http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html
"sphinx.ext.autodoc",
# http://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html
"sphinx.ext.napoleon",
# http://www.sphinx-doc.org/en/master/usage/extensions/todo.html
"sphinx.ext.todo",
# http://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html
"sphinx.ext.viewcode",
# https://sphinx-autoapi.readthedocs.io/en/latest/
"autoapi.extension",
# https://github.com/invenia/sphinxcontrib-runcmd
"sphinxcontrib.runcmd",
]

# Set initial page name
master_doc = "index"

# Project settings
project = "PyStructType"
year = datetime.now().year
author = "Fernando Chorney"
copyright = f"{year}, {author}"

# Short version name
version = "0.1.0"

# Long version name
release = version

# HTML Settings
html_theme = "sphinx_rtd_theme"
html_last_updated_fmt = "%b %d, %Y"
html_short_title = f"{project}-{version}"

# Pygments Style Settings
pygments_style = "monokai"

# Sphinx Extension Autodoc -------------------------------------------------------------

# Order members by source order
autodoc_member_order = "bysource"

# Always show members, and member-inheritance by default
autodoc_default_options = {"members": True, "show-inheritance": True}

# Sphinx Extension Napoleon ------------------------------------------------------------

# We want to force google style docstrings, so disable numpy style
napoleon_numpy_docstring = False

# Set output style
napoleon_use_ivar = True
napoleon_use_rtype = False
napoleon_use_param = False

# Sphinx Extension AutoAPI -------------------------------------------------------------
autoapi_type = "python"
autoapi_dirs = ["../src/pystructtype/"]
autoapi_template_dir = "./autoapi_templates"
autoapi_root = "autoapi"
autoapi_add_toctree_entry = False
autoapi_keep_files = False

# Exclude the autoapi templates in the doc building
exclude_patterns = ["autoapi_templates"]


# Add any Sphinx plugin settings here that don't have global variables exposed.
def setup(app):
# App Settings ---------------------------------------------------------------------
# Set source filetype(s)
# Allow .rst files along with .md
app.add_source_suffix(".rst", "restructuredtext")
app.add_source_suffix(".md", "markdown")
app.add_source_parser(CustomCommonMarkParser)

# RecommonMark Settings ------------------------------------------------------------
# Enable the evaluation of rst directive in .md files
# https://recommonmark.readthedocs.io/en/latest/auto_structify.html
app.add_config_value("recommonmark_config", {"enable_eval_rst": True}, True)
app.add_transform(AutoStructify)
11 changes: 11 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PyStructType
============

Add Stuff Here

.. toctree::
:maxdepth: 1
:caption: Code Reference
:name: sec-code-ref

autoapi/pystructtype/index
91 changes: 91 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[project]
name = "pystructtype"
version = "0.1.0"
description = "Leverage Python Types to Define C-Struct Interfaces"
readme = "README.md"
authors = [{name = "fchorney", email = "[email protected]"}]
license = "MIT"
license-files = ["LICEN[CS]E*"]
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Topic :: Utilities",
"Programming Language :: Python :: 3.13",

]
keywords = ["struct", "cstruct", "type"]
requires-python = ">=3.13"
dependencies = [
"loguru>=0.7.3",
]

[project.urls]
Homepage = "https://github.com/fchorney/pystructtype"
Documentation = ""
Repository = "https://github.com/fchorney/pystructtype"
Issues = "https://github.com/fchorney/pystructtype/issues"


[dependency-groups]
dev = [
"coverage[toml]",
"mypy",
"pytest",
"pytest-cov",
"recommonmark",
"ruff",
"sphinx",
"sphinx-autoapi",
"sphinx-rtd-theme",
"sphinxcontrib-runcmd",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.coverage.run]
relative_files = true

[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = true
exclude_lines = ["if __name__ == .__main__.:", "def __str__", "def __repr__", "pragma: no cover"]

[tool.uv]
package = true

[tool.ruff]
line-length = 120
indent-width = 4

target-version = "py313"

[tool.ruff.lint]
select = [
"F", # PyFlakes
"E", # Error
"I", # iSort
"N", # Pep8-Naming
"B", # Flake8-BugBear
"UP", # PyUpgrade
"RUF", # Ruff Specific Rules
]
ignore = []
fixable = ["ALL"]
unfixable = []

[tool.ruff.format]
# Like Black
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
docstring-code-format = true
docstring-code-line-length = "dynamic"

[tool.ruff.lint.isort]
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[bdist_wheel]
universal = 1

[mypy]
# ignore_missing_imports = true
check_untyped_defs = true
Loading

0 comments on commit dc1305b

Please sign in to comment.