diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fc3d99a..c30714a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 @@ -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 @@ -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: diff --git a/.gitignore b/.gitignore index 5127a42..1abf657 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__ .idea .pytest_cache .coverage +astyle_py/version.py diff --git a/astyle_py/__init__.py b/astyle_py/__init__.py index 26750cd..b335580 100644 --- a/astyle_py/__init__.py +++ b/astyle_py/__init__.py @@ -1,6 +1,6 @@ # SPDX-FileCopyrightText: 2022 Ivan Grokhotkov # 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__'] diff --git a/astyle_py/astyle_wrapper.py b/astyle_py/astyle_wrapper.py index 365cff9..ac4bad2 100644 --- a/astyle_py/astyle_wrapper.py +++ b/astyle_py/astyle_wrapper.py @@ -1,6 +1,7 @@ # SPDX-FileCopyrightText: 2022 Ivan Grokhotkov # SPDX-License-Identifier: MIT import os +import platform import typing from wasmtime import ( @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 9787c3b..9ebda76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "ivan@espressif.com"} +] +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 = "(): " + 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" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a29b575..0000000 --- a/setup.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[metadata] -name = astyle_py -version = attr: astyle_py.__version__ -description = Astyle, wrapped in a python package. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/igrr/astyle_py -author = Ivan Grokhotkov -author_email = ivan@espressif.com -license = MIT -license_files = LICENSE -classifier = - Development Status :: 4 - Beta - Environment :: Console - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Programming Language :: Python :: 3 :: Only - -[options] -packages = find: -install_requires = - wasmtime~=12.0.0 - PyYAML~=6.0.1 -include_package_data = True -python_requires = >=3.8 - -[options.extras_require] -dev = - pytest - types-PyYAML - pre-commit - coverage - -[options.package_data] -astyle_py = lib/*/libastyle.wasm - -[options.entry_points] -console_scripts = - astyle_py = astyle_py.__main__:main - -[bdist_wheel] -universal = True - -[flake8] -max-line-length = 120 diff --git a/setup.py b/setup.py deleted file mode 100644 index 8bf1ba9..0000000 --- a/setup.py +++ /dev/null @@ -1,2 +0,0 @@ -from setuptools import setup -setup() diff --git a/test/pytest.ini b/test/pytest.ini deleted file mode 100644 index b620fd7..0000000 --- a/test/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -[pytest] -addopts = - -s - --tb short