diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27b528e..83a56a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,10 @@ on: pull_request: workflow_dispatch: +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + env: BUILD_TYPE: Release HAMMING_WITH_AVX2: OFF @@ -20,16 +24,22 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + open-mp: "ON" + - os: macos-latest + open-mp: "OFF" + - os: windows-latest + open-mp: "OFF" steps: - uses: actions/checkout@v3 with: submodules: "recursive" - - name: enable openmp on linux - run: echo "HAMMING_WITH_OPENMP=ON" >> $GITHUB_ENV - if: runner.os == 'Linux' + - uses: actions/setup-python@v4 + with: + python-version: "3.11" - name: make build directory run: cmake -E make_directory ${{runner.workspace}}/build @@ -37,7 +47,7 @@ jobs: - name: configure cmake shell: bash working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=ON -DHAMMING_BUILD_BENCHMARKS=ON -DHAMMING_WITH_SSE2=ON -DHAMMING_WITH_AVX2=$HAMMING_WITH_AVX2 -DHAMMING_WITH_AVX512=$HAMMING_WITH_AVX512 -DHAMMING_BUILD_PYTHON=ON -DHAMMING_WITH_OPENMP=$HAMMING_WITH_OPENMP + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=ON -DHAMMING_BUILD_BENCHMARKS=ON -DHAMMING_WITH_SSE2=ON -DHAMMING_WITH_AVX2=$HAMMING_WITH_AVX2 -DHAMMING_WITH_AVX512=$HAMMING_WITH_AVX512 -DHAMMING_BUILD_PYTHON=ON -DHAMMING_WITH_OPENMP=${{ matrix.open-mp }} - name: build shell: bash diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 14958e7..bf3c34f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -9,17 +9,14 @@ on: release: types: [published] +concurrency: + group: wheels-${{ github.ref }} + cancel-in-progress: true + jobs: build-wheels: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} - env: - CIBW_TEST_REQUIRES: "pytest numpy" - CIBW_TEST_COMMAND: "pytest {project}/python/tests -v" - CIBW_TEST_SKIP: "pp* *-musllinux*" - CIBW_ENVIRONMENT: "BLAS=None LAPACK=None ATLAS=None" - CIBW_SKIP: "*-manylinux_i686" - CIBW_BUILD_VERBOSITY: 3 strategy: matrix: @@ -30,11 +27,7 @@ jobs: with: submodules: "recursive" - - name: enable openmp on linux - run: echo 'CIBW_ENVIRONMENT=HAMMING_WITH_OPENMP=ON' >> $GITHUB_ENV - if: runner.os == 'Linux' - - - uses: pypa/cibuildwheel@v2.14 + - uses: pypa/cibuildwheel@v2.15 - uses: actions/upload-artifact@v3 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6ae4b1..00e077a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,21 +12,11 @@ repos: hooks: - id: black - - repo: https://github.com/dfm/black_nbconvert - rev: v0.4.0 - hooks: - - id: black_nbconvert - - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.13 hooks: - id: cmake-format - additional_dependencies: [pyyaml==5.4.1] - - - repo: https://github.com/kynan/nbstripout - rev: 0.6.1 - hooks: - - id: nbstripout + additional_dependencies: [pyyaml] - repo: https://github.com/pre-commit/mirrors-clang-format rev: v16.0.6 @@ -34,6 +24,12 @@ repos: - id: clang-format - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0 + rev: v3.0.1 hooks: - id: prettier + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.22.0 + hooks: + - id: check-github-workflows + - id: check-readthedocs diff --git a/CMakeLists.txt b/CMakeLists.txt index c9d9f27..ca282d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.11..3.26) project( hammingdist - VERSION 0.19.0 + VERSION 0.20.0 LANGUAGES CXX) include(CTest) diff --git a/ext/Catch2 b/ext/Catch2 index 62fd660..182c910 160000 --- a/ext/Catch2 +++ b/ext/Catch2 @@ -1 +1 @@ -Subproject commit 62fd660583d3ae7a7886930b413c3c570e89786c +Subproject commit 182c910b4b63ff587a3440e08f84f70497e49a81 diff --git a/ext/benchmark b/ext/benchmark index 0d98dba..015d1a0 160000 --- a/ext/benchmark +++ b/ext/benchmark @@ -1 +1 @@ -Subproject commit 0d98dba29d66e93259db7daa53a9327df767a415 +Subproject commit 015d1a091af6937488242b70121858bce8fd40e9 diff --git a/ext/cpu_features b/ext/cpu_features index 8a494eb..936b9ab 160000 --- a/ext/cpu_features +++ b/ext/cpu_features @@ -1 +1 @@ -Subproject commit 8a494eb1e158ec2050e5f699a504fbc9b896a43b +Subproject commit 936b9ab5515dead115606559502e3864958f7f6e diff --git a/ext/pybind11 b/ext/pybind11 index 0bd8896..8a099e4 160000 --- a/ext/pybind11 +++ b/ext/pybind11 @@ -1 +1 @@ -Subproject commit 0bd8896a4010f2d91b2340570c24fa08606ec406 +Subproject commit 8a099e44b3d5f85b20f05828d919d2332a8de841 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e6eecfd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "hammingdist" +version = "0.20.0" +description = "A fast tool to calculate Hamming distances" +readme = "README.md" +license = {text = "MIT"} +authors=[{name="Liam Keegan", email="ssc@iwr.uni-heidelberg.de"}, {name="Dominic Kempf", email="ssc@iwr.uni-heidelberg.de"}] +requires-python = ">=3.7" +classifiers=[ + "Topic :: Scientific/Engineering :: Bio-Informatics", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Science/Research", + "Intended Audience :: Education", + "Programming Language :: C++", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", +] + +[project.urls] +Github = "https://github.com/ssciwr/hammingdist" +Issues = "https://github.com/ssciwr/hammingdist/issues" + +[project.optional-dependencies] +test = ["pytest", "numpy"] + +[tool.scikit-build.cmake.define] +BUILD_TESTING = "OFF" +HAMMING_BUILD_BENCHMARKS = "OFF" +HAMMING_BUILD_PYTHON = "ON" + +[tool.cibuildwheel] +skip = "*-manylinux_i686" +# skip tests for python 3.12 until numpy 1.26 is available +test-skip = "pp* *-musllinux* cp312-*" +test-extras = "test" +test-command = "pytest {project}/python/tests -v" +environment = { BLAS="None", LAPACK="None", ATLAS="None" } +build-verbosity = 3 + +[tool.cibuildwheel.linux] +environment = { CMAKE_ARGS="-DHAMMING_WITH_OPENMP=ON" } diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 478ba79..24725e5 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,2 +1,3 @@ pybind11_add_module(hammingdist hammingdist.cc) target_link_libraries(hammingdist PUBLIC hamming) +install(TARGETS hammingdist DESTINATION .) diff --git a/setup.py b/setup.py deleted file mode 100644 index 8178a6c..0000000 --- a/setup.py +++ /dev/null @@ -1,122 +0,0 @@ -import os -import re -import sys -import platform -import subprocess - -from setuptools import setup, Extension -from setuptools.command.build_ext import build_ext -from distutils.version import LooseVersion - -# Convert distutils Windows platform specifiers to CMake -A arguments -PLAT_TO_CMAKE = { - "win32": "Win32", - "win-amd64": "x64", - "win-arm32": "ARM", - "win-arm64": "ARM64", -} - - -class CMakeExtension(Extension): - def __init__(self, name, sourcedir=""): - Extension.__init__(self, name, sources=[]) - self.sourcedir = os.path.abspath(sourcedir) - - -class CMakeBuild(build_ext): - def run(self): - try: - out = subprocess.check_output(["cmake", "--version"]) - except OSError: - raise RuntimeError( - "CMake must be installed to build the following extensions: " - + ", ".join(e.name for e in self.extensions) - ) - - if platform.system() == "Windows": - cmake_version = LooseVersion( - re.search(r"version\s*([\d.]+)", out.decode()).group(1) - ) - if cmake_version < "3.1.0": - raise RuntimeError("CMake >= 3.1.0 is required on Windows") - - for ext in self.extensions: - self.build_extension(ext) - - def build_extension(self, ext): - extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) - # required for auto-detection of auxiliary "native" libs - if not extdir.endswith(os.path.sep): - extdir += os.path.sep - - cmake_args = [ - "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir, - "-DPYTHON_EXECUTABLE=" + sys.executable, - "-DHAMMING_BUILD_PYTHON=ON", - "-DBUILD_TESTING=OFF", - "-DHAMMING_BUILD_BENCHMARKS=OFF", - "-DHAMMING_WITH_OPENMP=" + os.environ.get("HAMMING_WITH_OPENMP", "OFF"), - ] - - cfg = "Debug" if self.debug else "Release" - build_args = ["--config", cfg] - - if platform.system() == "Windows": - cmake_args += [ - "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir) - ] - cmake_args += ["-A", PLAT_TO_CMAKE[self.plat_name]] - build_args += ["--", "/m"] - else: - cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg] - build_args += ["--", "-j2"] - - env = os.environ.copy() - env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format( - env.get("CXXFLAGS", ""), self.distribution.get_version() - ) - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - subprocess.check_call( - ["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env - ) - subprocess.check_call( - ["cmake", "--build", ".", "--target", "hammingdist"] + build_args, - cwd=self.build_temp, - ) - - -from os import path - -with open(path.join(path.abspath(path.dirname(__file__)), "README.md")) as f: - long_description = f.read() - -setup( - name="hammingdist", - version="0.19.0", - author="Dominic Kempf, Liam Keegan", - author_email="ssc@iwr.uni-heidelberg.de", - description="A fast tool to calculate Hamming distances", - url="https://github.com/ssciwr/hammingdist", - long_description=long_description, - long_description_content_type="text/markdown", - ext_modules=[CMakeExtension("hammingdist")], - cmdclass=dict(build_ext=CMakeBuild), - zip_safe=False, - classifiers=[ - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX :: Linux", - "Programming Language :: C++", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "License :: OSI Approved :: MIT License", - ], -)