Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
Expand All @@ -39,10 +39,10 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- run: python3 -m pip install --upgrade setuptools build
Expand All @@ -51,10 +51,10 @@ jobs:
find dist
- name: Upload wheels as job artifacts
if: github.event_name == 'push' && github.ref_type == 'tag'
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
name: python-package-distributions
path: dist/
- name: Sanity-check the resulting wheel
run: |
python3 -m venv venv
Expand All @@ -67,14 +67,15 @@ jobs:
needs: build_wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Download wheels from artifacts
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: dist
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ __pycache__
.idea
.pytest_cache
.coverage
astyle_py/version.py
4 changes: 2 additions & 2 deletions astyle_py/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2022 Ivan Grokhotkov <[email protected]>
# SPDX-License-Identifier: MIT
from .astyle_wrapper import Astyle, AstyleError
from .version import __version__

__all__ = ['Astyle', 'AstyleError']
__version__ = '1.0.5'
__all__ = ['Astyle', 'AstyleError', '__version__']
14 changes: 14 additions & 0 deletions astyle_py/astyle_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2022 Ivan Grokhotkov <[email protected]>
# SPDX-License-Identifier: MIT
import os
import platform
import typing

from wasmtime import (
Expand All @@ -16,11 +17,24 @@
WasiConfig,
)

# Workaround for https://github.com/bytecodealliance/wasmtime/issues/10099
MACOS_MACH_PORTS_WORKAROUND = False

if platform.system() == 'Darwin':
try:
from wasmtime._bindings import wasmtime_config_macos_use_mach_ports_set

MACOS_MACH_PORTS_WORKAROUND = True
except ImportError:
pass


class WasmContext:
def __init__(self):
wasm_cfg = Config()
wasm_cfg.cache = True
if MACOS_MACH_PORTS_WORKAROUND:
wasmtime_config_macos_use_mach_ports_set(wasm_cfg.ptr(), False)
self.linker = Linker(Engine(wasm_cfg))
self.linker.define_wasi()
self.store = Store(self.linker.engine)
Expand Down
123 changes: 122 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,124 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools", "setuptools-scm", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "astyle_py"
description = "Astyle, wrapped in a python package."
readme = "README.md"
requires-python = ">=3.9"
license = {file = "LICENSE"}
authors = [
{name = "Ivan Grokhotkov", email = "[email protected]"}
]
urls = { "Homepage" = "https://github.com/igrr/astyle_py" }
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only"
]
dynamic = ["version"]

dependencies = [
"wasmtime~=30.0.0",
"PyYAML~=6.0.1"
]

[project.optional-dependencies]
dev = [
"pytest",
"types-PyYAML",
"pre-commit",
"coverage",
"commitizen"
]

[project.scripts]
astyle_py = "astyle_py.__main__:main"

[tool.setuptools.packages.find]
include = ["astyle_py"]

[tool.setuptools.package-data]
"astyle_py" = ["lib/*/libastyle.wasm"]

[tool.setuptools_scm]
write_to = "astyle_py/version.py"

[tool.flake8]
max-line-length = 120

[tool.pytest.ini_options]
addopts = "-s --tb short"

[tool.commitizen]
annotated_tag = true
bump_message = "change: release v$new_version"
name = "cz_customize"
tag_format = "v$version"
update_changelog_on_bump = true
version_provider = "scm"
version_files = ["README.md"]

[tool.commitizen.customize]
bump_map = { "change" = "MINOR", "feat" = "MINOR", "fix" = "PATCH", "refactor" = "PATCH", "remove" = "PATCH", "revert" = "PATCH" }
bump_pattern = "^(change|feat|fix|refactor|remove|revert)"
change_type_order = [
"change",
"ci",
"test",
"docs",
"feat",
"fix",
"refactor",
"remove",
"revert",
]
example = "change: this is a custom change type"
message_template = "{% if scope %}{{change_type}}({{scope}}): {{message}}{% else %}{{change_type}}: {{message}}{% endif %}{% if body %}\n\n{{body}}{% endif %}{% if is_breaking_change %}\n\nBREAKING CHANGE{% endif %}{% if footer %}\n\n{{footer}}{% endif %}"
schema = "<type>(<scope>): <summary>"
schema_pattern = "^([a-z]+)(\\([\\w\\-\\.]+\\))?:\\s.*"

[[tool.commitizen.customize.questions]]
choices = [
{ value = "change", name = "change: A change made to the codebase." },
{ value = "ci", name = "ci: Changes to our CI configuration files and scripts." },
{ value = "test", name = "test: Adding missing tests, correcting or improving existing tests." },
{ value = "docs", name = "docs: Documentation only changes." },
{ value = "feat", name = "feat: A new feature." },
{ value = "fix", name = "fix: A bug fix." },
{ value = "refactor", name = "refactor: A code change that neither fixes a bug nor adds a feature." },
{ value = "remove", name = "remove: Removing code or files." },
{ value = "revert", name = "revert: Revert to a commit." },
]
message = "Select the TYPE of change you are committing"
name = "change_type"
type = "list"

[[tool.commitizen.customize.questions]]
message = "What is the SCOPE of this change (press enter to skip)?"
name = "scope"
type = "input"

[[tool.commitizen.customize.questions]]
message = "Describe the changes made (SUMMARY of commit message):"
name = "message"
type = "input"

[[tool.commitizen.customize.questions]]
message = "Provide additional contextual information - commit message BODY: (press [enter] to skip)"
name = "body"
type = "input"

[[tool.commitizen.customize.questions]]
default = false
message = "Is this a BREAKING CHANGE? Correlates with MAJOR in SemVer"
name = "is_breaking_change"
type = "confirm"

[[tool.commitizen.customize.questions]]
message = "Footer. Information about Breaking Changes and reference issues that this commit closes: (press [enter] to skip)"
name = "footer"
type = "input"
45 changes: 0 additions & 45 deletions setup.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions setup.py

This file was deleted.

4 changes: 0 additions & 4 deletions test/pytest.ini

This file was deleted.

Loading