diff --git a/.github/workflows/ctypeslib-linux.yml b/.github/workflows/ctypeslib-linux.yml index 5c7fcc8..532a9ab 100644 --- a/.github/workflows/ctypeslib-linux.yml +++ b/.github/workflows/ctypeslib-linux.yml @@ -6,8 +6,31 @@ on: [push, pull_request] jobs: - test: + check-package-build: + name: Build & inspect our package. + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + # get all history and tags for setuptools_scm to find the right version + fetch-depth: 0 + - name: Install build dependencies + run: | + pip install setuptools setuptools_scm wheel build + - name: Build package wheel + run: python -m build -w + - name: Upload built artifacts. + uses: actions/upload-artifact@v3 + # By default, the artifacts and log files generated by workflows are retained for 90 days before they are automatically deleted. + with: + name: Packages + path: ./dist/* +# - uses: hynek/build-and-inspect-python-package@v1 +# id: build-package + # packages are uploaded to Packages + test: + needs: check-package-build runs-on: ubuntu-latest strategy: matrix: @@ -15,7 +38,7 @@ jobs: # python-version: [ 3.5, 3.6, 3.7, 3.8, 3.9 ] os: [ubuntu-latest, macos-latest, windows-latest] python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] - clang-version: ['11', '14'] + clang-version: ['11', '12', '13', '14'] # clang 15+ is C2X standard and requires cleaning up C code in test libs # https://github.com/madler/zlib/issues/633 @@ -32,8 +55,8 @@ jobs: platform: x64 - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install clang==${{ matrix.clang-version }}.* coveralls + python -m pip install --upgrade pip + pip install setuptools setuptools_scm clang==${{ matrix.clang-version }}.* coveralls coverage[toml] - name: build test libs run: | CFLAGS="-Wall -Wextra -Werror -std=c99 -pedantic -fpic" @@ -57,30 +80,28 @@ jobs: if: ${{runner.os == 'macOS' }} run: | echo "DYLD_LIBRARY_PATH=$(pwd)/test/data/:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV - - name: Install clang2py + - uses: actions/download-artifact@v3 + with: + name: Packages + path: ~/packages/ + - name: Install the package that was built run: | - python setup.py develop - - name: Test with Unittest and coverage + pip install ~/packages/ctypeslib2*.whl + - name: Run tests with Unittest and coverage run: | - coverage run --source=ctypeslib setup.py test + coverage run --source=ctypeslib -m unittest test.alltests - name: Coveralls - uses: AndreMiras/coveralls-python-action@develop + uses: coverallsapp/github-action@v2 with: parallel: true - flag-name: Unit Test + flag-name: run-${{ join(matrix.*, ' - ') }} coveralls_finish: needs: test runs-on: ubuntu-latest steps: - name: Coveralls Finished - uses: AndreMiras/coveralls-python-action@develop + uses: coverallsapp/github-action@v2 with: parallel-finished: true -# - name: Coveralls -# run: | -# coveralls -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} \ No newline at end of file diff --git a/BUILD.md b/BUILD.md index f30fe96..34ce400 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,5 +1,8 @@ +build package requirement +`pip install build` + build dist -`python setup.py bdist_wheel` +`python -m build` upload `twine upload dist/....latest_version` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d7d1858..41e6747 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,44 @@ +[build-system] +requires = ["setuptools>=56.2", "setuptools_scm[toml]>=7"] +build-backend = "setuptools.build_meta" +[project] +name = "ctypeslib2" +authors = [{name = "Loic Jaquemet", email = "loic.jaquemet+python@gmail.com"}] +license = {text = "License :: OSI Approved :: MIT License"} +description = "ctypeslib2 - FFI toolkit, relies on clang" +readme = "README.md" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.8", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = ["clang>=11"] +dynamic = ["version"] + +[project.urls] +Homepage = "https://github.com/trolldbois/ctypeslib" +Download = "https://github.com/trolldbois/ctypeslib/releases" + +[project.scripts] +clang2py = "ctypeslib.clang2py:main" + +[tool.setuptools] +packages = ["ctypeslib", "ctypeslib.codegen"] +include-package-data = false + +[tool.setuptools.package-data] +ctypeslib = [ + "data/fundamental_type_name.tpl", + "data/headers.tpl", + "data/pointer_type.tpl", + "data/string_cast.tpl", + "data/structure_type.tpl", +] + +[tool.setuptools_scm] [tool.black] line-length = 120 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 926e22a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[coverage:run] -relative_files = True diff --git a/setup.py b/setup.py index 17be7b6..a6dce86 100755 --- a/setup.py +++ b/setup.py @@ -3,39 +3,5 @@ from setuptools import setup -setup( - name="ctypeslib2", - version="2.3.4", - description="ctypeslib2 - FFI toolkit, relies on clang", - long_description=open("README.md").read(), - long_description_content_type="text/markdown", - author="Loic Jaquemet", - author_email="loic.jaquemet+python@gmail.com", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.8", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - url="https://github.com/trolldbois/ctypeslib", - download_url="https://github.com/trolldbois/ctypeslib/releases", - license="License :: OSI Approved :: MIT License", - packages=['ctypeslib', - 'ctypeslib.codegen', - ], - package_data={'ctypeslib': ['data/fundamental_type_name.tpl', - 'data/headers.tpl', - 'data/pointer_type.tpl', - 'data/string_cast.tpl', - 'data/structure_type.tpl', - ]}, - entry_points={ - 'console_scripts': [ - 'clang2py = ctypeslib.clang2py:main', - ]}, - test_suite="test.alltests", - install_requires=[ - 'clang>=11', - ] -) +if __name__ == "__main__": + setup()