From c04b6be26a1dabd762c2880d736c1d846a30711f Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 19:49:55 +0200 Subject: [PATCH 01/19] add pyproject.toml, set minimum python version to 3.6 --- bitstruct/__init__.py | 4 +--- bitstruct/version.py | 1 - pyproject.toml | 51 +++++++++++++++++++++++++++++++++++++++++++ setup.py | 46 ++++++++++---------------------------- 4 files changed, 64 insertions(+), 38 deletions(-) delete mode 100644 bitstruct/version.py create mode 100644 pyproject.toml diff --git a/bitstruct/__init__.py b/bitstruct/__init__.py index 00464b3..17d60bf 100644 --- a/bitstruct/__init__.py +++ b/bitstruct/__init__.py @@ -1,12 +1,10 @@ -from __future__ import print_function +__version__ = '8.17.0' import re import struct from io import BytesIO import binascii -from .version import __version__ - class Error(Exception): pass diff --git a/bitstruct/version.py b/bitstruct/version.py deleted file mode 100644 index d191032..0000000 --- a/bitstruct/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '8.17.0' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d56b439 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[build-system] +build-backend = 'setuptools.build_meta' +requires = ["setuptools >= 68.0"] + +[project] +name = "bitstruct" +description = """This module performs conversions between Python values +and C bit field structs represented as Python +byte strings.""" +readme = "README.rst" +requires-python = ">=3.6" +license = { text = "MIT" } +keywords = [ + "bit field", + "bit parsing", + "bit unpack", + "bit pack", +] +authors = [ + { name = "Erik Moqvist", email = "erik.moqvist@gmail.com" }, + { name = "Ilya Petukhov" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: Implementation :: CPython", +] +dependencies = [] +dynamic = ["version"] + +[project.urls] +Documentation = "https://bitstruct.readthedocs.io/en/latest/" +Issues = "https://github.com/eerimoq/bitstruct/issues" +Source = "https://github.com/eerimoq/bitstruct" +Homepage = "https://github.com/eerimoq/bitstruct" + +[tool.setuptools.dynamic] +version = {attr = "bitstruct.__version__"} + +[tool.setuptools.package-data] +"*" = [ + "**/py.typed", + "**.pyi", +] + +[tool.cibuildwheel] +test-requires = "pytest" +test-command = "pytest {project}/test" +build-frontend = "build" diff --git a/setup.py b/setup.py index 3b65ae4..4b709c8 100755 --- a/setup.py +++ b/setup.py @@ -1,20 +1,12 @@ #!/usr/bin/env python import sys -import re import setuptools import platform -from setuptools import find_packages - - -def find_version(): - return re.search(r"^__version__ = '(.*)'$", - open('bitstruct/version.py', 'r').read(), - re.MULTILINE).group(1) def is_cpython_3(): - if platform.python_implementation() != 'CPython': + if platform.python_implementation() != "CPython": return False if sys.version_info[0] < 3: @@ -25,37 +17,23 @@ def is_cpython_3(): def setup(ext_modules): setuptools.setup( - name='bitstruct', - version=find_version(), - description=('This module performs conversions between Python values ' - 'and C bit field structs represented as Python ' - 'byte strings.'), - long_description=open('README.rst', 'r').read(), - author='Erik Moqvist, Ilya Petukhov', - author_email='erik.moqvist@gmail.com', - license='MIT', - classifiers=[ - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', - ], - keywords=['bit field', 'bit parsing', 'bit unpack', 'bit pack'], - url='https://github.com/eerimoq/bitstruct', - packages=find_packages(exclude=['tests']), ext_modules=ext_modules, - test_suite="tests") + ) if is_cpython_3(): try: - setup([setuptools.Extension('bitstruct.c', - sources=[ - 'bitstruct/c.c', - 'bitstruct/bitstream.c' - ])]) + setup( + [ + setuptools.Extension( + "bitstruct.c", + sources=["bitstruct/c.c", "bitstruct/bitstream.c"], + ) + ] + ) except: - print('WARNING: Failed to build the C extension.') + print("WARNING: Failed to build the C extension.") setup([]) else: - print('INFO: C extension only implemented in CPython 3.') + print("INFO: C extension only implemented in CPython 3.") setup([]) From b60f64c05c73808ec0fd14c1b3d86dc2e5605daf Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 19:53:42 +0200 Subject: [PATCH 02/19] test 3.12 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index aa0d1dc..f9d707d 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.7', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v1 - name: Set up Python ${{ matrix.python-version }} From 3d159fabe6351dfba261d963d0c69dfc2737ec23 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 19:56:07 +0200 Subject: [PATCH 03/19] do not run setup.py --- .github/workflows/pythonpackage.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index f9d707d..d806e26 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -18,10 +18,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - name: Test run: | - python setup.py build_ext -b . + python -m pip install -e . python -m unittest release: From f0ec7b65f31e8dc2bc641988185eefd041eecd4b Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 19:58:04 +0200 Subject: [PATCH 04/19] update actions --- .github/workflows/pythonpackage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index d806e26..6e80804 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -10,9 +10,9 @@ jobs: matrix: python-version: ['3.7', '3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -30,9 +30,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: 3.9 - name: Install pypa/build From 65a69f3d0c61d699070f6bda206b0e3853aee90b Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 20:03:44 +0200 Subject: [PATCH 05/19] use cibuildwheel --- .github/workflows/pythonpackage.yml | 76 +++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 6e80804..cab9712 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -23,27 +23,61 @@ jobs: python -m pip install -e . python -m unittest + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + # Used to host cibuildwheel + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + release: - needs: [test] - runs-on: ubuntu-20.04 + name: Publish distribution 📦 to PyPI + needs: [test, build_wheels, build_sdist] + runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags') - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Install pypa/build - run: | - python -m pip install build --user - - name: Build a binary wheel and a source tarball - run: | - git clean -dfx - python -m build --sdist --outdir dist/ . - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - skip_existing: true - password: ${{ secrets.pypi_password }} + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@master + with: + skip_existing: true + password: ${{ secrets.pypi_password }} From 57894220f6255f3488ee771b5e266f4ffe7529f2 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 20:08:44 +0200 Subject: [PATCH 06/19] raise minimum python version to 3.7 because of setuptools compatibility --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d56b439..b2f0a82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ description = """This module performs conversions between Python values and C bit field structs represented as Python byte strings.""" readme = "README.rst" -requires-python = ">=3.6" +requires-python = ">=3.7" license = { text = "MIT" } keywords = [ "bit field", From f2373a24d4e5c738b086bbd1ca54b6263d661acf Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 20:15:33 +0200 Subject: [PATCH 07/19] explicitly set packages, fix setuptools complaints about newlines in summary --- pyproject.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b2f0a82..b834e04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ requires = ["setuptools >= 68.0"] [project] name = "bitstruct" -description = """This module performs conversions between Python values -and C bit field structs represented as Python +description = """This module performs conversions between Python values \ +and C bit field structs represented as Python \ byte strings.""" readme = "README.rst" requires-python = ">=3.7" @@ -36,6 +36,9 @@ Issues = "https://github.com/eerimoq/bitstruct/issues" Source = "https://github.com/eerimoq/bitstruct" Homepage = "https://github.com/eerimoq/bitstruct" +[tool.setuptools] +packages = ["bitstruct"] + [tool.setuptools.dynamic] version = {attr = "bitstruct.__version__"} From 192113e1b9e0caf1b850291bb49fe440ed39d3cf Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 20:19:19 +0200 Subject: [PATCH 08/19] try to fix pytest command --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b834e04..fcc1185 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,5 +50,5 @@ version = {attr = "bitstruct.__version__"} [tool.cibuildwheel] test-requires = "pytest" -test-command = "pytest {project}/test" +test-command = "pytest -v --assert=plain {project}/tests" build-frontend = "build" From 1dfd0de2c4263475bb0c7f01b812dbb68b52e7cd Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 20:42:45 +0200 Subject: [PATCH 09/19] use src package structure --- pyproject.toml | 4 ++-- setup.py | 2 +- {bitstruct => src/bitstruct}/__init__.py | 0 {bitstruct => src/bitstruct}/bitstream.c | 0 {bitstruct => src/bitstruct}/bitstream.h | 0 {bitstruct => src/bitstruct}/c.c | 0 6 files changed, 3 insertions(+), 3 deletions(-) rename {bitstruct => src/bitstruct}/__init__.py (100%) rename {bitstruct => src/bitstruct}/bitstream.c (100%) rename {bitstruct => src/bitstruct}/bitstream.h (100%) rename {bitstruct => src/bitstruct}/c.c (100%) diff --git a/pyproject.toml b/pyproject.toml index fcc1185..e41b712 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,8 +36,8 @@ Issues = "https://github.com/eerimoq/bitstruct/issues" Source = "https://github.com/eerimoq/bitstruct" Homepage = "https://github.com/eerimoq/bitstruct" -[tool.setuptools] -packages = ["bitstruct"] +[tool.setuptools.packages.find] +where = ["src"] [tool.setuptools.dynamic] version = {attr = "bitstruct.__version__"} diff --git a/setup.py b/setup.py index 4b709c8..8bacb0c 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def setup(ext_modules): [ setuptools.Extension( "bitstruct.c", - sources=["bitstruct/c.c", "bitstruct/bitstream.c"], + sources=["src/bitstruct/c.c", "src/bitstruct/bitstream.c"], ) ] ) diff --git a/bitstruct/__init__.py b/src/bitstruct/__init__.py similarity index 100% rename from bitstruct/__init__.py rename to src/bitstruct/__init__.py diff --git a/bitstruct/bitstream.c b/src/bitstruct/bitstream.c similarity index 100% rename from bitstruct/bitstream.c rename to src/bitstruct/bitstream.c diff --git a/bitstruct/bitstream.h b/src/bitstruct/bitstream.h similarity index 100% rename from bitstruct/bitstream.h rename to src/bitstruct/bitstream.h diff --git a/bitstruct/c.c b/src/bitstruct/c.c similarity index 100% rename from bitstruct/c.c rename to src/bitstruct/c.c From c66303b6a75fc1a6b82aa1fbcd50ae9ce916d162 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 20:52:54 +0200 Subject: [PATCH 10/19] try to build pypy wheels --- setup.py | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/setup.py b/setup.py index 8bacb0c..61d5364 100755 --- a/setup.py +++ b/setup.py @@ -1,39 +1,17 @@ #!/usr/bin/env python - -import sys -import setuptools import platform +import setuptools -def is_cpython_3(): - if platform.python_implementation() != "CPython": - return False - - if sys.version_info[0] < 3: - return False - - return True +if platform.python_implementation() in ("CPython", "PyPy"): + ext_modules = [ + setuptools.Extension( + "bitstruct.c", + sources=["src/bitstruct/c.c", "src/bitstruct/bitstream.c"], + ) + ] -def setup(ext_modules): setuptools.setup( ext_modules=ext_modules, ) - - -if is_cpython_3(): - try: - setup( - [ - setuptools.Extension( - "bitstruct.c", - sources=["src/bitstruct/c.c", "src/bitstruct/bitstream.c"], - ) - ] - ) - except: - print("WARNING: Failed to build the C extension.") - setup([]) -else: - print("INFO: C extension only implemented in CPython 3.") - setup([]) From fbbf30b629f52a882f5af03e7c638b935ff5ce7a Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 21:02:47 +0200 Subject: [PATCH 11/19] skip pypy --- pyproject.toml | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e41b712..964835c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,3 +52,4 @@ version = {attr = "bitstruct.__version__"} test-requires = "pytest" test-command = "pytest -v --assert=plain {project}/tests" build-frontend = "build" +skip = "pp*" diff --git a/setup.py b/setup.py index 61d5364..a951be6 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import setuptools -if platform.python_implementation() in ("CPython", "PyPy"): +if platform.python_implementation() == "CPython": ext_modules = [ setuptools.Extension( "bitstruct.c", From bf640672a4e54de2e4e4b7bdf0d3c521b76e350a Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 21:10:06 +0200 Subject: [PATCH 12/19] run `ruff --select UP --select I --fix src` --- setup.py | 6 ++++-- src/bitstruct/__init__.py | 42 +++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/setup.py b/setup.py index a951be6..3375e35 100755 --- a/setup.py +++ b/setup.py @@ -3,12 +3,14 @@ import setuptools - if platform.python_implementation() == "CPython": ext_modules = [ setuptools.Extension( "bitstruct.c", - sources=["src/bitstruct/c.c", "src/bitstruct/bitstream.c"], + sources=[ + "src/bitstruct/c.c", + "src/bitstruct/bitstream.c", + ], ) ] diff --git a/src/bitstruct/__init__.py b/src/bitstruct/__init__.py index 17d60bf..f87c25c 100644 --- a/src/bitstruct/__init__.py +++ b/src/bitstruct/__init__.py @@ -1,16 +1,16 @@ __version__ = '8.17.0' +import binascii import re import struct from io import BytesIO -import binascii class Error(Exception): pass -class _Info(object): +class _Info: def __init__(self, size, name=None): self.size = size @@ -21,7 +21,7 @@ def __init__(self, size, name=None): class _SignedInteger(_Info): def __init__(self, size, name): - super(_SignedInteger, self).__init__(size, name) + super().__init__(size, name) self.minimum = -2 ** (size - 1) self.maximum = -self.minimum - 1 @@ -55,7 +55,7 @@ def unpack(self, bits): class _UnsignedInteger(_Info): def __init__(self, size, name): - super(_UnsignedInteger, self).__init__(size, name) + super().__init__(size, name) self.maximum = 2 ** size - 1 def pack(self, arg): @@ -63,10 +63,7 @@ def pack(self, arg): if value < 0 or value > self.maximum: raise Error( - '"u{}" requires 0 <= integer <= {} (got {})'.format( - self.size, - self.maximum, - arg)) + f'"u{self.size}" requires 0 <= integer <= {self.maximum} (got {arg})') return bin(value + (1 << self.size))[3:] @@ -77,10 +74,10 @@ def unpack(self, bits): class _Boolean(_UnsignedInteger): def pack(self, arg): - return super(_Boolean, self).pack(int(bool(arg))) + return super().pack(int(bool(arg))) def unpack(self, bits): - return bool(super(_Boolean, self).unpack(bits)) + return bool(super().unpack(bits)) class _Float(_Info): @@ -95,8 +92,7 @@ def pack(self, arg): elif self.size == 64: value = struct.pack('>d', value) else: - raise Error('expected float size of 16, 32, or 64 bits (got {})'.format( - self.size)) + raise Error(f'expected float size of 16, 32, or 64 bits (got {self.size})') return bin(int(b'01' + binascii.hexlify(value), 16))[3:] @@ -110,8 +106,7 @@ def unpack(self, bits): elif self.size == 64: value = struct.unpack('>d', packed)[0] else: - raise Error('expected float size of 16, 32, or 64 bits (got {})'.format( - self.size)) + raise Error(f'expected float size of 16, 32, or 64 bits (got {self.size})') return value @@ -153,7 +148,7 @@ def pack(self): class _Text(_Info): def __init__(self, size, name, encoding, errors): - super(_Text, self).__init__(size, name) + super().__init__(size, name) self.encoding = encoding self.errors = errors @@ -178,7 +173,7 @@ def _parse_format(fmt, names, text_encoding, text_errors): parsed_infos = re.findall(r'([<>]?)([a-zA-Z])(\d+)(\s*)', fmt) if ''.join([''.join(info) for info in parsed_infos]) != fmt: - raise Error("bad format '{}'".format(fmt + byte_order)) + raise Error(f"bad format '{fmt + byte_order}'") # Use big endian as default and use the endianness of the previous # value if none is given for the current value. @@ -194,7 +189,7 @@ def _parse_format(fmt, names, text_encoding, text_errors): size = int(parsed_info[2]) if size == 0: - raise Error("bad format '{}'".format(fmt + byte_order)) + raise Error(f"bad format '{fmt + byte_order}'") if names is None: name = i @@ -224,7 +219,7 @@ def _parse_format(fmt, names, text_encoding, text_errors): elif type_ == 'P': info = _OnePadding(size) else: - raise Error("bad char '{}' in format".format(type_)) + raise Error(f"bad char '{type_}' in format") info.endianness = endianness @@ -246,7 +241,7 @@ def _unpack_bytearray(size, bits): return binascii.unhexlify(hex(int('10000000' + bits, 2))[4:].rstrip('L')) -class _CompiledFormat(object): +class _CompiledFormat: def __init__(self, fmt, @@ -362,8 +357,7 @@ def pack_into_any(self, buf, offset, data, **kwargs): if len(bits) > len(buf_bits): raise Error( - 'pack_into requires a buffer of at least {} bits'.format( - len(bits))) + f'pack_into requires a buffer of at least {len(bits)} bits') buf[:] = _unpack_bytearray(len(bits), bits) @@ -385,7 +379,7 @@ class CompiledFormat(_CompiledFormat): """ def __init__(self, fmt, text_encoding='utf-8', text_errors='strict'): - super(CompiledFormat, self).__init__(fmt, None, text_encoding, text_errors) + super().__init__(fmt, None, text_encoding, text_errors) self._number_of_arguments = 0 for info in self._infos: @@ -448,7 +442,7 @@ def pack(self, data): try: return self.pack_any(data) except KeyError as e: - raise Error('{} not found in data dictionary'.format(str(e))) + raise Error(f'{str(e)} not found in data dictionary') def unpack(self, data, allow_truncated=False): """See :func:`~bitstruct.unpack_dict()`. @@ -465,7 +459,7 @@ def pack_into(self, buf, offset, data, **kwargs): try: self.pack_into_any(buf, offset, data, **kwargs) except KeyError as e: - raise Error('{} not found in data dictionary'.format(str(e))) + raise Error(f'{str(e)} not found in data dictionary') def unpack_from(self, data, offset=0, allow_truncated=False): """See :func:`~bitstruct.unpack_from_dict()`. From 7284780c684025e73c82f08391bc7e320ace9b28 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 21:18:17 +0200 Subject: [PATCH 13/19] update MANIFEST.in --- MANIFEST.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index b4cf522..33f7815 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,7 @@ include LICENSE include Makefile -include bitstruct/c.c -include bitstruct/bitstream.[hc] +include src/bitstruct/c.c +include src/bitstruct/bitstream.[hc] recursive-include docs *.bat recursive-include docs *.py recursive-include docs *.rst From 8a05fe7ea9bd869490ee7fd3d069475a29352483 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 8 Oct 2023 21:22:04 +0200 Subject: [PATCH 14/19] do not run setup.py --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 69effa0..d310ed1 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,3 @@ test: - python3 setup.py build_ext -b . + python3 -m pip install -e . python3 -m unittest From 060034715645279abf5437a3cadb8dac0705bd50 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 15 Oct 2023 00:25:09 +0200 Subject: [PATCH 15/19] build and release wheels whenever a release is published on GitHub --- .github/workflows/pythonpackage.yml | 61 +-------------------------- .github/workflows/release.yml | 64 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index cab9712..b2495b0 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.7', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -22,62 +22,3 @@ jobs: run: | python -m pip install -e . python -m unittest - - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - fail-fast: false - - steps: - - uses: actions/checkout@v4 - - # Used to host cibuildwheel - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel - - - name: Build wheels - run: python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl - - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Build sdist - run: pipx run build --sdist - - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz - - release: - name: Publish distribution 📦 to PyPI - needs: [test, build_wheels, build_sdist] - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags') - steps: - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@master - with: - skip_existing: true - password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9d1a99d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,64 @@ +name: Build & Release + +on: + release: + types: [ published ] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + # Used to host cibuildwheel + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + release: + name: Publish distribution 📦 to PyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@master + with: + skip_existing: true + password: ${{ secrets.pypi_password }} From 01390dba1f7f4f85386c7be13c4ab8adfb7da3cf Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 15 Oct 2023 00:26:51 +0200 Subject: [PATCH 16/19] do not limit max. parallel CI jobs --- .github/workflows/pythonpackage.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index b2495b0..989d5c6 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -6,7 +6,6 @@ jobs: test: runs-on: ubuntu-latest strategy: - max-parallel: 4 matrix: python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: From d155afc8f0be7bb88babf56605269585e50b6295 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 15 Oct 2023 00:32:05 +0200 Subject: [PATCH 17/19] use pytest --- .github/workflows/pythonpackage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 989d5c6..fac5a9a 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -17,7 +17,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install pytest + python -m pip install . - name: Test run: | - python -m pip install -e . - python -m unittest + python -m pytest -v --assert=plain .\tests\ From de878f9bbe415d0ee9d8a025d400556c600862a2 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 15 Oct 2023 00:34:00 +0200 Subject: [PATCH 18/19] fix path, set fail-fast: false --- .github/workflows/pythonpackage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index fac5a9a..583c4fd 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -6,6 +6,7 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: @@ -21,4 +22,4 @@ jobs: python -m pip install . - name: Test run: | - python -m pytest -v --assert=plain .\tests\ + python -m pytest -v --assert=plain ./tests From 4156afb973ff360c95654ba99596c49438a924b0 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Sun, 15 Oct 2023 16:30:54 +0200 Subject: [PATCH 19/19] publish on tag and workflow_dispatch --- .github/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d1a99d..1c4a5bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,11 @@ name: Build & Release on: - release: - types: [ published ] + push: + tags: + - '*' + workflow_dispatch: + jobs: build_wheels: