diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 31d9085..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[bumpversion] -current_version = 3.1.0 -commit = True -tag = True - -[bumpversion:file:setup.py] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e0e137d..3dddc6d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,36 +1,73 @@ -on: - push: - # Sequence of patterns matched against refs/tags - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - -name: Create release - -jobs: - build: - name: Creating Release - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install python dependencies - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade setuptools - pip install wheel twine - - - name: Publishing - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py bdist_wheel - python setup.py sdist - twine upload dist/* +name: CI + +on: + push: + branches: [master] + pull_request: + release: + types: [published] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + test: + name: Test on Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: + ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "pypy3.11"] + + steps: + - uses: actions/checkout@v7 + + - name: Install uv + uses: astral-sh/setup-uv@v8.3.2 + with: + enable-cache: true + python-version: ${{ matrix.python-version }} + + - name: Run tests + run: uv run --extra test pytest + + build: + name: Build distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - name: Install uv + uses: astral-sh/setup-uv@v8.3.2 + with: + enable-cache: true + + - name: Build sdist and wheel + run: uv build + + - uses: actions/upload-artifact@v7 + with: + name: dist + path: ./dist/* + + publish: + name: Publish to PyPI + needs: [test, build] + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.repository == 'TkTech/PyNBT' + environment: + name: pypi + url: https://pypi.org/p/PyNBT + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v8 + with: + name: dist + path: dist + + - name: Publish + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 14678a2..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Run tests - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: [3.5, 3.6, 3.7, 3.8, '3.9.0-alpha - 3.9.0', pypy3] - - steps: - # Python needs to be setup before checkout to prevent files from being - # left in the source tree. See setup-python/issues/106. - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - uses: actions/checkout@v2 - - - name: Installing python dependencies - run: | - pip install -e '.[test]' - - - name: Running tests - run: | - pytest diff --git a/.gitignore b/.gitignore index 692d92c..aeb121b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,21 @@ *.swp *.swo *.pyc -build/* +*.pyd +*.so +__pycache__/ +.pytest_cache/ +build/ +_build/ +dist/ +wheelhouse/ +*.egg-info +.eggs +.venv/ +venv ENV/ +uv.lock __test__.nbt -*.egg-info .ropeproject +.idea .DS_Store -venv diff --git a/README.md b/README.md index faa015d..722f913 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -![Run tests](https://github.com/TkTech/PyNBT/workflows/Run%20tests/badge.svg?event=push) +![CI](https://github.com/TkTech/PyNBT/actions/workflows/release.yml/badge.svg) # PyNBT PyNBT is a tiny, liberally licenced (MIT) NBT library. It supports reading and writing big endian or little endian NBT files. -Tested and supported on Py3.5-Py3.9, pypy3. +Tested and supported on CPython 3.9-3.14 and PyPy. ## Using the Library Using the library in your own programs is simple and is capable of reading, modifying, and saving NBT files. diff --git a/pynbt.py b/pynbt.py index 5b4c0b3..8932223 100644 --- a/pynbt.py +++ b/pynbt.py @@ -2,6 +2,7 @@ Implements reading & writing for the Named Binary Tag (NBT) format used in Minecraft. """ +__version__ = "3.1.0" __all__ = ( 'NBTFile', 'TAG_Byte', diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b6c1fe3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,57 @@ +[build-system] +requires = ["setuptools>=77"] +build-backend = "setuptools.build_meta" + +[project] +name = "PyNBT" +dynamic = ["version"] +description = "Tiny, liberally-licensed NBT library (Minecraft)." +readme = "README.md" +requires-python = ">=3.9" +license = "MIT" +license-files = ["LICENCE"] +authors = [{ name = "Tyler Kennedy", email = "tk@tkte.ch" }] +keywords = ["minecraft", "nbt"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = ["mutf8>=1.1.0"] + +[project.optional-dependencies] +test = ["pytest"] + +[project.urls] +Homepage = "https://github.com/TkTech/PyNBT" +Source = "https://github.com/TkTech/PyNBT" +Issues = "https://github.com/TkTech/PyNBT/issues" + +[tool.setuptools] +py-modules = ["pynbt"] + +[tool.setuptools.dynamic] +version = { attr = "pynbt.__version__" } + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.bumpversion] +current_version = "3.1.0" +commit = true +tag = true +tag_name = "v{new_version}" +allow_dirty = false + +[[tool.bumpversion.files]] +filename = "pynbt.py" diff --git a/setup.py b/setup.py deleted file mode 100644 index 653572c..0000000 --- a/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -import os.path -from setuptools import setup - -root = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(root, 'README.md'), 'rb') as readme: - long_description = readme.read().decode('utf-8') - -setup( - name='PyNBT', - version='3.1.0', - description='Tiny, liberally-licensed NBT library (Minecraft).', - long_description=long_description, - long_description_content_type='text/markdown', - author='Tyler Kennedy', - author_email='tk@tkte.ch', - url='https://github.com/TkTech/PyNBT', - keywords=['minecraft', 'nbt'], - py_modules=['pynbt'], - install_requires=[ - 'mutf8>=1.0.2' - ], - extras_require={ - 'test': ['pytest'] - }, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'License :: OSI Approved :: MIT License' - ] -)