From e11ff3e3fae9b784ba24c648ea691ae5a991ad19 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 16 Jun 2024 22:09:56 +0800 Subject: [PATCH 01/62] Publish cppbinder as a Python package (#1) --- .github/workflows/wheels.yml | 81 ++++++++++++++++++ .gitignore | 146 +++++++++++++++++++++++++++++++- .gitmodules | 3 + CMakeLists.txt | 156 +---------------------------------- binder/__init__.py | 43 ++++++++++ binder/bin/.gitkeep | 0 llvm-project | 1 + pyproject.toml | 45 ++++++++++ setup.py | 13 +++ source/CMakeLists.txt | 13 ++- source/function.hpp | 1 + 11 files changed, 345 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/wheels.yml create mode 100644 .gitmodules create mode 100644 binder/__init__.py create mode 100644 binder/bin/.gitkeep create mode 160000 llvm-project create mode 100644 pyproject.toml create mode 100644 setup.py diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 00000000..0fb233eb --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,81 @@ +name: Wheels + +on: + release: + types: [published] + +concurrency: + group: wheels-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + pull-requests: write + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: + - windows-2022 + - ubuntu-22.04 + - macos-14 + fail-fast: false + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Build the binder executable + shell: bash + run: | + cmake ${{ env.CMAKE_OPTIONS }} -S . -B build + cmake --build build --config Release --target binder + env: + CMAKE_OPTIONS: >- + -DCMAKE_BUILD_TYPE=Release + -DLLVM_ENABLE_EH=ON + -DLLVM_ENABLE_RTTI=ON + -DLLVM_ENABLE_PROJECTS=clang + - name: Move the installer to the binder/bin directory + if: matrix.os == 'windows-2019' + shell: bash + run: | + mv build/llvm-project/llvm/Release/bin/binder.exe binder/bin + - name: Build the wheel + run: | + pip wheel --wheel-dir dist . + + - uses: actions/upload-artifact@v4 + with: + name: cppbinder-${{ github.ref_name }}-${{ matrix.os }} + path: ./dist/*.whl + + - name: Upload wheels to release + shell: bash + run: | + gh release upload ${{ github.ref_name }} ./dist/*.whl --clobber + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish: + needs: build + runs-on: ubuntu-22.04 + steps: + - name: Download wheels + run: | + gh release download ${{ github.ref_name }} --pattern *.whl --dir dist + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.14 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + packages-dir: dist diff --git a/.gitignore b/.gitignore index bfa70639..9a0dfc3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,143 @@ -*.pyc +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class -build -documentation/.build/ -source/.gitignore +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# IDE config files +.vs/ +.vscode/ +.VSCodeCounter/ +.idea/ + +# CMake build/debug directory +cmake-build-*/ + +# Binder build files +binder/_version.py +binder/bin diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..856de7de --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "llvm-project"] + path = llvm-project + url = https://github.com/haiiliin/llvm-project.git diff --git a/CMakeLists.txt b/CMakeLists.txt index ed5546cf..aa997190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,152 +1,4 @@ -#This file can be used to build binder using preinstalled LLVM/Clang -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) -PROJECT(binder CXX C) -SET(VERSION 1.4.1) -option(STATIC "Statically compile Binder. See `documentation/install.rst` for more information." OFF) -set(CMAKE_VERBOSE_MAKEFILE ON) -#So far there are exceptions in config.cpp -set(LLVM_REQUIRES_EH ON) -set(USE_EXTERNAL_LLVM ON) -include("GNUInstallDirs") -set(LLVM_DIR_ORIG ${LLVM_DIR}) -set(Clang_DIR_ORIG ${Clang_DIR}) -# cmake version >= 3.19 includes all our modules -if(${CMAKE_VERSION} VERSION_LESS "3.19") - set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) -else() - # set CMP0054 to NEW - # https://cmake.org/cmake/help/latest/policy/CMP0054.html - cmake_policy(SET CMP0054 NEW) -endif() -SET(CMAKE_MODULE_PATH_ORIG "${CMAKE_MODULE_PATH}") -set (CMAKE_MODULE_PATH "${LLVM_DIR};${Clang_DIR};${CMAKE_MODULE_PATH}") -option(BINDER_ENABLE_TEST "Enables building of tests" ON) -option(BINDER_MOCK_TEST "Mock running of binder on tests" OFF) -option(BINDER_USE_PYTHON_IN_TEST "Try to import python modules during tests" ON) -if (NOT DEFINED BINDER_TEST_PYTHON_VERSIONS) - set(BINDER_TEST_PYTHON_VERSIONS "0,2.7,3") -endif() -MESSAGE(STATUS "binder: BINDER_ENABLE_TEST=${BINDER_ENABLE_TEST} with BINDER_TEST_PYTHON_VERSIONS=${BINDER_TEST_PYTHON_VERSIONS}. Note that version 0 can be used to check the generated sources agains the references.") -MESSAGE(STATUS "binder: BINDER_USE_PYTHON_IN_TEST=${BINDER_USE_PYTHON_IN_TEST}") -MESSAGE(STATUS "binder: Using LLVM_DIR=${LLVM_DIR} to search for cmake configurations.") -MESSAGE(STATUS "binder: Using Clang_DIR=${Clang_DIR} to search for cmake configurations.") -MESSAGE(STATUS "binder: Using CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH} to search for cmake configurations.") -find_package(Clang CONFIG QUIET PATHS /usr/lib64/cmake/clang /usr/lib/cmake/clang /usr/share/clang/cmake ) -find_package(LLVM CONFIG QUIET PATHS /usr/lib64/cmake/clang /usr/lib/cmake/llvm /usr/share/llvm/cmake ) -if (Clang_FOUND AND LLVM_FOUND AND NOT LLVMCONFIG ) - set(CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR};${CMAKE_MODULE_PATH}") - MESSAGE(STATUS "binder: cmake configurations llvm and clang were found. LLVM_CMAKE_DIR=${LLVM_CMAKE_DIR}") - include(AddLLVM) - include(LLVMConfig) - MESSAGE(STATUS "binder: LLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}") - MESSAGE(STATUS "binder: LLVM_VERSION=${LLVM_VERSION}") - find_path(LibClang_INCLUDE_DIR stddef.h HINTS - ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION}/include - ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION}/include - ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION}/include - ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION}/include - ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION}/include - ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}/include - ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}/include - ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}/include - ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION_MAJOR}/include - ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION_MAJOR}/include - ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include - ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include - ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include - ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include - ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include - ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include - ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include - ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include - ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include - ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include - ${CLANG_INCLUDE_DIRS} - ) - include_directories( ${CLANG_INCLUDE_DIRS} ) - MESSAGE(STATUS "binder: CLANG_INCLUDE_DIRS=${CLANG_INCLUDE_DIRS}") -else() - MESSAGE(STATUS "binder: llvm or clang cmake configurations were not found.") - MESSAGE(STATUS "binder: CLang_FOUND=${Clang_FOUND}") - MESSAGE(STATUS "binder: LLVM_FOUND=${LLVM_FOUND}") - MESSAGE(STATUS "binder: Trying to look for llvm-config.") - set(LLVM_DIR ${LLVM_DIR_ORIG}) - set(Clang_DIR ${Clang_DIR_ORIG}) - SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH_ORIG}") - MESSAGE(STATUS "binder: Restored original LLVM_DIR=${LLVM_DIR}") - MESSAGE(STATUS "binder: Restored original Clang_DIR=${Clang_DIR}") - if (LLVMCONFIG) - MESSAGE(STATUS "binder: The explicit location of llvm-config is set to LLVMCONFIG=${LLVMCONFIG}") - if (EXISTS ${LLVMCONFIG}) - set (LLVMCONFIGEXE ${LLVMCONFIG}) - else() - MESSAGE(FATAL_ERROR "binder: File ${LLVMCONFIG} does not exist") - endif() - else() - MESSAGE(STATUS "binder: Searching for llvm-config in ${LLVM_DIR}/bin $ENV{PATH} /usr/bin/ /usr/local/bin") - find_program(LLVMCONFIGEXE NAMES llvm-config HINTS ${LLVM_DIR}/bin $ENV{PATH} /usr/bin/ /usr/local/bin) - endif() - if (LLVMCONFIGEXE) - MESSAGE(STATUS "binder: llvm-config found in ${LLVMCONFIGEXE}") - execute_process (COMMAND ${LLVMCONFIGEXE} --version OUTPUT_VARIABLE LLVMVERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND ${LLVMCONFIGEXE} --libdir OUTPUT_VARIABLE LLVMLIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND ${LLVMCONFIGEXE} --includedir OUTPUT_VARIABLE LLVMINCLUDEDIR OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND ${LLVMCONFIGEXE} --cxxflags OUTPUT_VARIABLE LLVMCXXFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) - set(LLVM_COMPILE_FLAGS ${LLVMCXXFLAGS}) - include_directories( ${LLVMINCLUDEDIR}) - include_directories( ${CLANG_INCLUDE_DIRS} ) - link_directories(${LLVMLIBDIR} ) - string(REPLACE "." ";" VERSION_LIST ${LLVMVERSION}) - list(GET VERSION_LIST 0 LLVM_VERSION_MAJOR) - list(GET VERSION_LIST 1 LLVM_VERSION_MINOR) - list(GET VERSION_LIST 2 LLVM_VERSION_PATCH) - find_path(LibClang_INCLUDE_DIR stddef.h HINTS - ${LLVMINCLUDEDIR}/clang/${LLVMVERSION}/include - ${LLVMINCLUDEDIR}/../clang/${LLVMVERSION}/include - ${LLVMINCLUDEDIR}/../../lib/clang/${LLVMVERSION}/include - ${LLVMINCLUDEDIR}/../../lib64/clang/${LLVMVERSION}/include - ${CLANG_INCLUDE_DIRS}/clang/${LLVMVERSION}/include - ${CLANG_INCLUDE_DIRS} - ) - MESSAGE(STATUS "binder: llvm version from ${LLVMCONFIGEXE} is ${LLVMVERSION}") - MESSAGE(STATUS "binder: llvm library dir from ${LLVMCONFIGEXE} is ${LLVMLIBDIR}") - MESSAGE(STATUS "binder: llvm includedir dir from ${LLVMCONFIGEXE} is ${LLVMINCLUDEDIR}") - else() - MESSAGE(FATAL_ERROR "binder: llvm-config not found") - endif() -endif() -IF( NOT LibClang_INCLUDE_DIR ) -#This will assure non-empty argument for binder in tests. - set(LibClang_INCLUDE_DIR "/") -endif() -MESSAGE(STATUS "binder: LibClang_INCLUDE_DIR, the location of headers is ${LibClang_INCLUDE_DIR}") -MESSAGE(STATUS "binder: LLVM_VERSION_MAJOR=${LLVM_VERSION_MAJOR}") -MESSAGE(STATUS "binder: LLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}") -MESSAGE(STATUS "binder: LLVM_VERSION_PATCH=${LLVM_VERSION_PATCH}") -if( ${LLVM_VERSION_MAJOR} GREATER_EQUAL 16 ) -# LLVM 16 introduces the use of C++ features from C++17 -set(CMAKE_CXX_STANDARD 17) -else() -set(CMAKE_CXX_STANDARD 14) -endif() -macro(add_clang_executable name) - add_executable( ${name} ${ARGN} ) -# set_target_properties(${name} PROPERTIES FOLDER "Clang executables") - message(STATUS "binder: We have cmake functions to update LLVM_COMPILE_FLAGS") - if (LLVM_COMPILER_IS_GCC_COMPATIBLE) - list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti") - elseif (MSVC) - list(APPEND LLVM_COMPILE_FLAGS "/GR-") - endif () -endmacro(add_clang_executable) -include_directories(source) -add_subdirectory(source) -if (BINDER_ENABLE_TEST) - if(${CMAKE_VERSION} VERSION_LESS "3.0.0") - message("You are running cmake version ${CMAKE_VERSION}.") - message("The testing suite will be disabled as it requires cmake 3.0.0 or higher.") - else() - ENABLE_TESTING() - add_subdirectory(test) - endif() -endif() +cmake_minimum_required(VERSION 3.4.3) +project(binder LANGUAGES CXX C) + +add_subdirectory(llvm-project/llvm) diff --git a/binder/__init__.py b/binder/__init__.py new file mode 100644 index 00000000..f3ed0c1f --- /dev/null +++ b/binder/__init__.py @@ -0,0 +1,43 @@ +import os +import sys +import subprocess +from pathlib import Path + +try: + from ._version import __version__ as _default_version +except ImportError: + _default_version = "0.0.1" + + +__all__ = ["binder", "__version__"] + + +BINDER_BIN_DIR = os.path.join(os.path.dirname(__file__), "bin") + + +def binder(): + raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder"), *sys.argv[1:]], close_fds=False)) + + +def _get_version(): + """Return the version string used for __version__.""" + # Only shell out to a git subprocess if really needed, and not on a + # shallow clone, such as those used by CI, as the latter would trigger + # a warning from setuptools_scm. + root = Path(__file__).resolve().parent + if (root / ".git").exists() and not (root / ".git/shallow").exists(): + try: + import setuptools_scm + + return setuptools_scm.get_version( + root=str(root), + version_scheme="post-release", + fallback_version=_default_version, + ) + except (ImportError, LookupError): + return _default_version + else: # Get the version from the _version.py setuptools_scm file. + return _default_version + + +__version__: str = _get_version() diff --git a/binder/bin/.gitkeep b/binder/bin/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/llvm-project b/llvm-project new file mode 160000 index 00000000..c6aee8f1 --- /dev/null +++ b/llvm-project @@ -0,0 +1 @@ +Subproject commit c6aee8f17b27ae0328fa7fd50acbfcea477c3c79 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..dd05993d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,45 @@ +[build-system] +requires = ["setuptools", "setuptools-scm", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "cppbinder" +description = "Binder, tool for automatic generation of Python bindings" +readme = "README.md" +dynamic = ["version"] +authors = [ + {name = "Rosetta Commons"}, +] +classifiers = [ + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "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", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +requires-python = ">=3.8" + +[project.urls] +Homepage = "https://github.com/RosettaCommons/binder/" +Documentation = "https://cppbinder.readthedocs.io/" +"Bug Tracker" = "https://github.com/RosettaCommons/binder/issues/" + +[project.scripts] +binder = "binder:binder" + +[tool.setuptools] +include-package-data = true +packages = ["binder"] + +[tool.setuptools.package-data] +binder = ["bin/**"] + +[tool.setuptools_scm] +root = "." +version_scheme = "post-release" +write_to = "binder/_version.py" +fallback_version = "0.0.1" diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..4a534767 --- /dev/null +++ b/setup.py @@ -0,0 +1,13 @@ +from setuptools import setup +from wheel.bdist_wheel import bdist_wheel as _bdist_wheel + + +class bdist_wheel(_bdist_wheel): + def finalize_options(self): + super().finalize_options() + self.root_is_pure = False + self.python_tag = "py3" + self.py_limited_api = "cp38" + + +setup(cmdclass={"bdist_wheel": bdist_wheel}) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 06a0353a..ccb1bc6f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -40,6 +40,11 @@ add_clang_executable(binder fmt/os.cc fmt/os.h ) +get_filename_component(PARENT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) +get_filename_component(PPARENT_DIRECTORY ${PARENT_DIRECTORY} DIRECTORY) +get_filename_component(PPPARENT_DIRECTORY ${PPARENT_DIRECTORY} DIRECTORY) +message(STATUS "binder: Build binder to ${PPPARENT_DIRECTORY}/binder/bin") +set_target_properties(binder PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PPPARENT_DIRECTORY}/binder/bin) if (NOT VERSION) set(VERSION 1.4.1) endif() @@ -123,6 +128,12 @@ else() clangFrontend ) endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_COMPILE_FLAGS}") +list(REMOVE_ITEM CMAKE_CXX_FLAGS "-fno-exceptions") +string (REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) +message(STATUS "binder: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/binder PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_WRITE OWNER_READ OWNER_EXECUTE -DESTINATION ${CMAKE_INSTALL_BINDIR}) +DESTINATION binder/bin) diff --git a/source/function.hpp b/source/function.hpp index 4e3a320f..15bae4af 100644 --- a/source/function.hpp +++ b/source/function.hpp @@ -14,6 +14,7 @@ #define _INCLUDED_function_hpp_ #include +#include #include #include From 02efc6a6ac5f38aa7f6e786e4116a335788d9b00 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 16 Jun 2024 22:13:42 +0800 Subject: [PATCH 02/62] Fix release workflow: move built executable Post #1 --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0fb233eb..23a0cb20 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -46,7 +46,7 @@ jobs: -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_PROJECTS=clang - name: Move the installer to the binder/bin directory - if: matrix.os == 'windows-2019' + if: matrix.os == 'windows-2022' shell: bash run: | mv build/llvm-project/llvm/Release/bin/binder.exe binder/bin From 63f8c742117fe266cd25ad2445c236173b017292 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 16 Jun 2024 22:46:35 +0800 Subject: [PATCH 03/62] Set github token when downloading wheels --- .github/workflows/wheels.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 23a0cb20..9563f13a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,6 +73,8 @@ jobs: - name: Download wheels run: | gh release download ${{ github.ref_name }} --pattern *.whl --dir dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@v1.8.14 with: From f440855a992e4556379703109ef14c8797121b69 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 16 Jun 2024 23:19:44 +0800 Subject: [PATCH 04/62] Checkout the repository before download wheels --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 9563f13a..9cb0ade1 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -70,6 +70,7 @@ jobs: needs: build runs-on: ubuntu-22.04 steps: + - uses: actions/checkout@v4 - name: Download wheels run: | gh release download ${{ github.ref_name }} --pattern *.whl --dir dist From bd749150be02d86032ba8f3eac55e09b889d93d9 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 17 Jun 2024 00:33:39 +0800 Subject: [PATCH 05/62] Manylinux wheels should be built with cibuildwheel --- .github/workflows/wheels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 9cb0ade1..258732e3 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,7 +73,8 @@ jobs: - uses: actions/checkout@v4 - name: Download wheels run: | - gh release download ${{ github.ref_name }} --pattern *.whl --dir dist + gh release download ${{ github.ref_name }} --pattern *macosx*.whl --dir dist + gh release download ${{ github.ref_name }} --pattern *win*.whl --dir dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish package to PyPI From a8620dbdbccb188db390ae65c2ad86379b92f972 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 17 Jun 2024 18:34:23 +0800 Subject: [PATCH 06/62] Use scikit-build-core and cibuildwheel to build the package (#2) --- .github/workflows/wheels.yml | 71 +++++++++++++++++++++++------------- pyproject.toml | 42 +++++++++++++++++---- setup.py | 13 ------- source/CMakeLists.txt | 19 +++------- 4 files changed, 86 insertions(+), 59 deletions(-) delete mode 100644 setup.py diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 258732e3..fff2998f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,6 +1,11 @@ name: Wheels on: + pull_request: + branches: + - master + paths: + - ".github/workflows/wheels.yml" release: types: [published] @@ -13,11 +18,10 @@ permissions: pull-requests: write jobs: - build: + build-wheels: runs-on: ${{ matrix.os }} strategy: matrix: - # macos-13 is an intel runner, macos-14 is apple silicon os: - windows-2022 - ubuntu-22.04 @@ -29,52 +33,67 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Set up Python - uses: actions/setup-python@v5 + - name: Build wheels + uses: pypa/cibuildwheel@v2.19.1 + + - uses: actions/upload-artifact@v4 + if: always() with: - python-version: 3.12 + name: cppbinder-wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl - - name: Build the binder executable + - name: Upload wheels to release + if: github.event_name == 'release' shell: bash run: | - cmake ${{ env.CMAKE_OPTIONS }} -S . -B build - cmake --build build --config Release --target binder + gh release upload ${{ github.ref_name }} ./wheelhouse/*.whl --clobber env: - CMAKE_OPTIONS: >- - -DCMAKE_BUILD_TYPE=Release - -DLLVM_ENABLE_EH=ON - -DLLVM_ENABLE_RTTI=ON - -DLLVM_ENABLE_PROJECTS=clang - - name: Move the installer to the binder/bin directory - if: matrix.os == 'windows-2022' - shell: bash + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-sdist: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install dependencies run: | - mv build/llvm-project/llvm/Release/bin/binder.exe binder/bin - - name: Build the wheel + python -m pip install --upgrade pip + pip install build + + - name: Build source distribution run: | - pip wheel --wheel-dir dist . + rm build.py # to avoid conflict with the build package + python -m build --sdist --outdir dist - uses: actions/upload-artifact@v4 + if: always() with: - name: cppbinder-${{ github.ref_name }}-${{ matrix.os }} - path: ./dist/*.whl + name: cppbinder-sdist + path: ./dist/*.tar.gz - name: Upload wheels to release - shell: bash + if: github.event_name == 'release' run: | - gh release upload ${{ github.ref_name }} ./dist/*.whl --clobber + gh release upload ${{ github.ref_name }} ./dist/*.tar.gz --clobber env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish: - needs: build + needs: [build-wheels, build-sdist] + if: github.event_name == 'release' runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Download wheels run: | - gh release download ${{ github.ref_name }} --pattern *macosx*.whl --dir dist - gh release download ${{ github.ref_name }} --pattern *win*.whl --dir dist + gh release download ${{ github.ref_name }} --pattern *.whl --pattern *.tar.gz --dir dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish package to PyPI diff --git a/pyproject.toml b/pyproject.toml index dd05993d..3d8df0a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["setuptools", "setuptools-scm", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["scikit-build-core", "setuptools", "setuptools-scm", "pybind11"] +build-backend = "scikit_build_core.build" [project] name = "cppbinder" @@ -31,12 +31,40 @@ Documentation = "https://cppbinder.readthedocs.io/" [project.scripts] binder = "binder:binder" -[tool.setuptools] -include-package-data = true -packages = ["binder"] +[tool.scikit-build] +minimum-version = "0.8" +build-dir = "build/{wheel_tag}" -[tool.setuptools.package-data] -binder = ["bin/**"] +# Dynamic versioning +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" + +# Source distribution +sdist.include = ["binder/_version.py"] + +# Components to install and targets to build +install.components = ["binder"] +cmake.targets = ["binder"] + +# Cmake defines +cmake.define.LLVM_ENABLE_EH = "ON" +cmake.define.LLVM_ENABLE_RTTI = "ON" +cmake.define.LLVM_ENABLE_PROJECTS = "clang" + +# Wheel configuration +wheel.packages = ["binder"] +wheel.py-api = "py3" +wheel.expand-macos-universal-tags = true + +[tool.cibuildwheel] +build = "cp312-*" +musllinux-x86_64-image = "musllinux_1_1" +musllinux-i686-image = "musllinux_1_1" +musllinux-aarch64-image = "musllinux_1_1" +musllinux-ppc64le-image = "musllinux_1_1" +musllinux-s390x-image = "musllinux_1_1" + +[tool.cibuildwheel.macos] +archs = ["universal2"] [tool.setuptools_scm] root = "." diff --git a/setup.py b/setup.py deleted file mode 100644 index 4a534767..00000000 --- a/setup.py +++ /dev/null @@ -1,13 +0,0 @@ -from setuptools import setup -from wheel.bdist_wheel import bdist_wheel as _bdist_wheel - - -class bdist_wheel(_bdist_wheel): - def finalize_options(self): - super().finalize_options() - self.root_is_pure = False - self.python_tag = "py3" - self.py_limited_api = "cp38" - - -setup(cmdclass={"bdist_wheel": bdist_wheel}) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index ccb1bc6f..985335f8 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -40,11 +40,6 @@ add_clang_executable(binder fmt/os.cc fmt/os.h ) -get_filename_component(PARENT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) -get_filename_component(PPARENT_DIRECTORY ${PARENT_DIRECTORY} DIRECTORY) -get_filename_component(PPPARENT_DIRECTORY ${PPARENT_DIRECTORY} DIRECTORY) -message(STATUS "binder: Build binder to ${PPPARENT_DIRECTORY}/binder/bin") -set_target_properties(binder PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PPPARENT_DIRECTORY}/binder/bin) if (NOT VERSION) set(VERSION 1.4.1) endif() @@ -127,13 +122,11 @@ else() clangAST clangFrontend ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_COMPILE_FLAGS}") + list(REMOVE_ITEM CMAKE_CXX_FLAGS "-fno-exceptions") + string (REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + message(STATUS "binder: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") endif() - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_COMPILE_FLAGS}") -list(REMOVE_ITEM CMAKE_CXX_FLAGS "-fno-exceptions") -string (REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) -message(STATUS "binder: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/binder +install(TARGETS binder PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_WRITE OWNER_READ OWNER_EXECUTE -DESTINATION binder/bin) +DESTINATION binder/bin COMPONENT binder) From 90b75dae7524257f7ca4bc56c6af34c2ba988c57 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 17 Jun 2024 18:54:59 +0800 Subject: [PATCH 07/62] Rename build.py to build-binder.py to avoid conflicts --- .github/workflows/wheels.yml | 1 - build.py => build-binder.py | 0 documentation/install.rst | 2 +- 3 files changed, 1 insertion(+), 2 deletions(-) rename build.py => build-binder.py (100%) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index fff2998f..93e6b0a5 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -69,7 +69,6 @@ jobs: - name: Build source distribution run: | - rm build.py # to avoid conflict with the build package python -m build --sdist --outdir dist - uses: actions/upload-artifact@v4 diff --git a/build.py b/build-binder.py similarity index 100% rename from build.py rename to build-binder.py diff --git a/documentation/install.rst b/documentation/install.rst index c81fd856..a699977d 100644 --- a/documentation/install.rst +++ b/documentation/install.rst @@ -28,7 +28,7 @@ may not be compatible with the header files on the system Binder where is run. Building ******** -The steps below are encoded in `binder/build.py` and `binder/build-and-run-tests.py` +The steps below are encoded in `binder/build-binder.py` and `binder/build-and-run-tests.py` files so for default install you can just run `build-and-run-tests.py` script directly. This section describes how to build a dynamically-linked ``binder`` executable. To *statically* compile binder, see :ref:`building-static`. From b1e4f0dd33180897cbdef86b13ae93e4457294e6 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 17 Jun 2024 20:16:25 +0800 Subject: [PATCH 08/62] Create dependabot.yml --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..31b6e3b0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" From 9c6464ebd1174b8150dda621486cadde7ba356d2 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 18 Jun 2024 13:30:47 +0800 Subject: [PATCH 09/62] Update version getting function --- binder/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binder/__init__.py b/binder/__init__.py index f3ed0c1f..218adb22 100644 --- a/binder/__init__.py +++ b/binder/__init__.py @@ -24,7 +24,7 @@ def _get_version(): # Only shell out to a git subprocess if really needed, and not on a # shallow clone, such as those used by CI, as the latter would trigger # a warning from setuptools_scm. - root = Path(__file__).resolve().parent + root = Path(__file__).resolve().parents[1] if (root / ".git").exists() and not (root / ".git/shallow").exists(): try: import setuptools_scm From 1b9e6a0de02a4523d5fbbe7acdfddfa99bc87fa3 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 18 Jun 2024 15:45:41 +0800 Subject: [PATCH 10/62] Support both Python 2 and Python 3 (#3) --- .github/workflows/wheels.yml | 1 + binder/__init__.py | 34 ++-------------------------------- binder/__main__.py | 5 +++++ pyproject.toml | 14 ++++++++++++-- 4 files changed, 20 insertions(+), 34 deletions(-) create mode 100644 binder/__main__.py diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 93e6b0a5..17acdfb9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -6,6 +6,7 @@ on: - master paths: - ".github/workflows/wheels.yml" + - "source/**" release: types: [published] diff --git a/binder/__init__.py b/binder/__init__.py index 218adb22..119a42e8 100644 --- a/binder/__init__.py +++ b/binder/__init__.py @@ -1,43 +1,13 @@ import os import sys import subprocess -from pathlib import Path -try: - from ._version import __version__ as _default_version -except ImportError: - _default_version = "0.0.1" - -__all__ = ["binder", "__version__"] +__all__ = ["binder"] BINDER_BIN_DIR = os.path.join(os.path.dirname(__file__), "bin") def binder(): - raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder"), *sys.argv[1:]], close_fds=False)) - - -def _get_version(): - """Return the version string used for __version__.""" - # Only shell out to a git subprocess if really needed, and not on a - # shallow clone, such as those used by CI, as the latter would trigger - # a warning from setuptools_scm. - root = Path(__file__).resolve().parents[1] - if (root / ".git").exists() and not (root / ".git/shallow").exists(): - try: - import setuptools_scm - - return setuptools_scm.get_version( - root=str(root), - version_scheme="post-release", - fallback_version=_default_version, - ) - except (ImportError, LookupError): - return _default_version - else: # Get the version from the _version.py setuptools_scm file. - return _default_version - - -__version__: str = _get_version() + raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder")] + sys.argv[1:], close_fds=False)) diff --git a/binder/__main__.py b/binder/__main__.py new file mode 100644 index 00000000..5f033177 --- /dev/null +++ b/binder/__main__.py @@ -0,0 +1,5 @@ +from binder import binder + + +if __name__ == "__main__": + binder() diff --git a/pyproject.toml b/pyproject.toml index 3d8df0a0..a1d25d4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,17 @@ authors = [ ] classifiers = [ "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.0", + "Programming Language :: Python :: 3.1", + "Programming Language :: Python :: 3.2", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "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", @@ -21,7 +31,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] -requires-python = ">=3.8" +requires-python = ">=2.7" [project.urls] Homepage = "https://github.com/RosettaCommons/binder/" @@ -52,7 +62,7 @@ cmake.define.LLVM_ENABLE_PROJECTS = "clang" # Wheel configuration wheel.packages = ["binder"] -wheel.py-api = "py3" +wheel.py-api = "py2.py3" wheel.expand-macos-universal-tags = true [tool.cibuildwheel] From 459ddde1d2e26faa401829e1cb969e2abbbcf14d Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 18 Jun 2024 16:22:29 +0800 Subject: [PATCH 11/62] Use scikit-build-core to write version to _version.py file --- binder/__init__.py | 29 ++++++++++++++++++++++++++++- pyproject.toml | 7 ++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/binder/__init__.py b/binder/__init__.py index 119a42e8..b80096ec 100644 --- a/binder/__init__.py +++ b/binder/__init__.py @@ -2,8 +2,13 @@ import sys import subprocess +try: + from ._version import version as _default_version +except ImportError: + _default_version = "0.0.1" -__all__ = ["binder"] + +__all__ = ["binder", "__version__"] BINDER_BIN_DIR = os.path.join(os.path.dirname(__file__), "bin") @@ -11,3 +16,25 @@ def binder(): raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder")] + sys.argv[1:], close_fds=False)) + +def _get_version(): + """Return the version string used for __version__.""" + # Only shell out to a git subprocess if really needed, and not on a + # shallow clone, such as those used by CI, as the latter would trigger + # a warning from setuptools_scm. + root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + if os.path.exists(os.path.join(root, ".git")) and not os.path.exists(os.path.join(root, ".git/shallow")): + try: + import setuptools_scm + + return setuptools_scm.get_version( + root=root, + version_scheme="post-release", + fallback_version=_default_version, + ) + except (ImportError, LookupError): + return _default_version + else: # Get the version from the _version.py setuptools_scm file. + return _default_version + +__version__ = _get_version() diff --git a/pyproject.toml b/pyproject.toml index a1d25d4d..ced97e8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,12 @@ wheel.packages = ["binder"] wheel.py-api = "py2.py3" wheel.expand-macos-universal-tags = true +[[tool.scikit-build.generate]] +path = "binder/_version.py" +template = ''' +version = "${version}" +''' + [tool.cibuildwheel] build = "cp312-*" musllinux-x86_64-image = "musllinux_1_1" @@ -79,5 +85,4 @@ archs = ["universal2"] [tool.setuptools_scm] root = "." version_scheme = "post-release" -write_to = "binder/_version.py" fallback_version = "0.0.1" From fc0008acffd743e9b1174cbc6ec67bb788936856 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 19 Jun 2024 22:41:21 +0800 Subject: [PATCH 12/62] Move the project to sub-directory python --- .github/workflows/wheels.yml | 17 ++- .gitignore | 147 +--------------------- .gitmodules | 2 +- CMakeLists.txt | 156 +++++++++++++++++++++++- binder/bin/.gitkeep | 0 build-binder.py => build.py | 0 documentation/install.rst | 2 +- llvm-project | 1 - python/.gitignore | 143 ++++++++++++++++++++++ python/CMakeLists.txt | 4 + {binder => python/binder}/__init__.py | 0 {binder => python/binder}/__main__.py | 0 python/llvm-project | 1 + pyproject.toml => python/pyproject.toml | 0 14 files changed, 319 insertions(+), 154 deletions(-) delete mode 100644 binder/bin/.gitkeep rename build-binder.py => build.py (100%) delete mode 160000 llvm-project create mode 100644 python/.gitignore create mode 100644 python/CMakeLists.txt rename {binder => python/binder}/__init__.py (100%) rename {binder => python/binder}/__main__.py (100%) create mode 160000 python/llvm-project rename pyproject.toml => python/pyproject.toml (100%) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 17acdfb9..9d45e8e3 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -34,20 +34,25 @@ jobs: fetch-depth: 0 submodules: recursive + - name: Setup cibuildwheel + run: | + pipx install cibuildwheel + - name: Build wheels - uses: pypa/cibuildwheel@v2.19.1 + run: + cd python && cibuildwheel --output-dir wheelhouse - uses: actions/upload-artifact@v4 if: always() with: name: cppbinder-wheels-${{ matrix.os }} - path: ./wheelhouse/*.whl + path: ./python/wheelhouse/*.whl - name: Upload wheels to release if: github.event_name == 'release' shell: bash run: | - gh release upload ${{ github.ref_name }} ./wheelhouse/*.whl --clobber + gh release upload ${{ github.ref_name }} ./python/wheelhouse/*.whl --clobber env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -70,18 +75,18 @@ jobs: - name: Build source distribution run: | - python -m build --sdist --outdir dist + cd python && python -m build --sdist --outdir dist - uses: actions/upload-artifact@v4 if: always() with: name: cppbinder-sdist - path: ./dist/*.tar.gz + path: ./python/dist/*.tar.gz - name: Upload wheels to release if: github.event_name == 'release' run: | - gh release upload ${{ github.ref_name }} ./dist/*.tar.gz --clobber + gh release upload ${{ github.ref_name }} ./python/dist/*.tar.gz --clobber env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 9a0dfc3d..384cfb91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,143 +1,8 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class +*.pyc -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# IDE config files -.vs/ -.vscode/ -.VSCodeCounter/ +build +documentation/.build/ +source/.gitignore .idea/ - -# CMake build/debug directory -cmake-build-*/ - -# Binder build files -binder/_version.py -binder/bin +cmake-*/ +dist/ diff --git a/.gitmodules b/.gitmodules index 856de7de..1e04769a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "llvm-project"] - path = llvm-project + path = python/llvm-project url = https://github.com/haiiliin/llvm-project.git diff --git a/CMakeLists.txt b/CMakeLists.txt index aa997190..ed5546cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,152 @@ -cmake_minimum_required(VERSION 3.4.3) -project(binder LANGUAGES CXX C) - -add_subdirectory(llvm-project/llvm) +#This file can be used to build binder using preinstalled LLVM/Clang +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) +PROJECT(binder CXX C) +SET(VERSION 1.4.1) +option(STATIC "Statically compile Binder. See `documentation/install.rst` for more information." OFF) +set(CMAKE_VERBOSE_MAKEFILE ON) +#So far there are exceptions in config.cpp +set(LLVM_REQUIRES_EH ON) +set(USE_EXTERNAL_LLVM ON) +include("GNUInstallDirs") +set(LLVM_DIR_ORIG ${LLVM_DIR}) +set(Clang_DIR_ORIG ${Clang_DIR}) +# cmake version >= 3.19 includes all our modules +if(${CMAKE_VERSION} VERSION_LESS "3.19") + set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) +else() + # set CMP0054 to NEW + # https://cmake.org/cmake/help/latest/policy/CMP0054.html + cmake_policy(SET CMP0054 NEW) +endif() +SET(CMAKE_MODULE_PATH_ORIG "${CMAKE_MODULE_PATH}") +set (CMAKE_MODULE_PATH "${LLVM_DIR};${Clang_DIR};${CMAKE_MODULE_PATH}") +option(BINDER_ENABLE_TEST "Enables building of tests" ON) +option(BINDER_MOCK_TEST "Mock running of binder on tests" OFF) +option(BINDER_USE_PYTHON_IN_TEST "Try to import python modules during tests" ON) +if (NOT DEFINED BINDER_TEST_PYTHON_VERSIONS) + set(BINDER_TEST_PYTHON_VERSIONS "0,2.7,3") +endif() +MESSAGE(STATUS "binder: BINDER_ENABLE_TEST=${BINDER_ENABLE_TEST} with BINDER_TEST_PYTHON_VERSIONS=${BINDER_TEST_PYTHON_VERSIONS}. Note that version 0 can be used to check the generated sources agains the references.") +MESSAGE(STATUS "binder: BINDER_USE_PYTHON_IN_TEST=${BINDER_USE_PYTHON_IN_TEST}") +MESSAGE(STATUS "binder: Using LLVM_DIR=${LLVM_DIR} to search for cmake configurations.") +MESSAGE(STATUS "binder: Using Clang_DIR=${Clang_DIR} to search for cmake configurations.") +MESSAGE(STATUS "binder: Using CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH} to search for cmake configurations.") +find_package(Clang CONFIG QUIET PATHS /usr/lib64/cmake/clang /usr/lib/cmake/clang /usr/share/clang/cmake ) +find_package(LLVM CONFIG QUIET PATHS /usr/lib64/cmake/clang /usr/lib/cmake/llvm /usr/share/llvm/cmake ) +if (Clang_FOUND AND LLVM_FOUND AND NOT LLVMCONFIG ) + set(CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR};${CMAKE_MODULE_PATH}") + MESSAGE(STATUS "binder: cmake configurations llvm and clang were found. LLVM_CMAKE_DIR=${LLVM_CMAKE_DIR}") + include(AddLLVM) + include(LLVMConfig) + MESSAGE(STATUS "binder: LLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}") + MESSAGE(STATUS "binder: LLVM_VERSION=${LLVM_VERSION}") + find_path(LibClang_INCLUDE_DIR stddef.h HINTS + ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION}/include + ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION}/include + ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION}/include + ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION}/include + ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION}/include + ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}/include + ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}/include + ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}/include + ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION_MAJOR}/include + ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION_MAJOR}/include + ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include + ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include + ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include + ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include + ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include + ${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include + ${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include + ${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include + ${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include + ${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.0/include + ${CLANG_INCLUDE_DIRS} + ) + include_directories( ${CLANG_INCLUDE_DIRS} ) + MESSAGE(STATUS "binder: CLANG_INCLUDE_DIRS=${CLANG_INCLUDE_DIRS}") +else() + MESSAGE(STATUS "binder: llvm or clang cmake configurations were not found.") + MESSAGE(STATUS "binder: CLang_FOUND=${Clang_FOUND}") + MESSAGE(STATUS "binder: LLVM_FOUND=${LLVM_FOUND}") + MESSAGE(STATUS "binder: Trying to look for llvm-config.") + set(LLVM_DIR ${LLVM_DIR_ORIG}) + set(Clang_DIR ${Clang_DIR_ORIG}) + SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH_ORIG}") + MESSAGE(STATUS "binder: Restored original LLVM_DIR=${LLVM_DIR}") + MESSAGE(STATUS "binder: Restored original Clang_DIR=${Clang_DIR}") + if (LLVMCONFIG) + MESSAGE(STATUS "binder: The explicit location of llvm-config is set to LLVMCONFIG=${LLVMCONFIG}") + if (EXISTS ${LLVMCONFIG}) + set (LLVMCONFIGEXE ${LLVMCONFIG}) + else() + MESSAGE(FATAL_ERROR "binder: File ${LLVMCONFIG} does not exist") + endif() + else() + MESSAGE(STATUS "binder: Searching for llvm-config in ${LLVM_DIR}/bin $ENV{PATH} /usr/bin/ /usr/local/bin") + find_program(LLVMCONFIGEXE NAMES llvm-config HINTS ${LLVM_DIR}/bin $ENV{PATH} /usr/bin/ /usr/local/bin) + endif() + if (LLVMCONFIGEXE) + MESSAGE(STATUS "binder: llvm-config found in ${LLVMCONFIGEXE}") + execute_process (COMMAND ${LLVMCONFIGEXE} --version OUTPUT_VARIABLE LLVMVERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND ${LLVMCONFIGEXE} --libdir OUTPUT_VARIABLE LLVMLIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND ${LLVMCONFIGEXE} --includedir OUTPUT_VARIABLE LLVMINCLUDEDIR OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND ${LLVMCONFIGEXE} --cxxflags OUTPUT_VARIABLE LLVMCXXFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + set(LLVM_COMPILE_FLAGS ${LLVMCXXFLAGS}) + include_directories( ${LLVMINCLUDEDIR}) + include_directories( ${CLANG_INCLUDE_DIRS} ) + link_directories(${LLVMLIBDIR} ) + string(REPLACE "." ";" VERSION_LIST ${LLVMVERSION}) + list(GET VERSION_LIST 0 LLVM_VERSION_MAJOR) + list(GET VERSION_LIST 1 LLVM_VERSION_MINOR) + list(GET VERSION_LIST 2 LLVM_VERSION_PATCH) + find_path(LibClang_INCLUDE_DIR stddef.h HINTS + ${LLVMINCLUDEDIR}/clang/${LLVMVERSION}/include + ${LLVMINCLUDEDIR}/../clang/${LLVMVERSION}/include + ${LLVMINCLUDEDIR}/../../lib/clang/${LLVMVERSION}/include + ${LLVMINCLUDEDIR}/../../lib64/clang/${LLVMVERSION}/include + ${CLANG_INCLUDE_DIRS}/clang/${LLVMVERSION}/include + ${CLANG_INCLUDE_DIRS} + ) + MESSAGE(STATUS "binder: llvm version from ${LLVMCONFIGEXE} is ${LLVMVERSION}") + MESSAGE(STATUS "binder: llvm library dir from ${LLVMCONFIGEXE} is ${LLVMLIBDIR}") + MESSAGE(STATUS "binder: llvm includedir dir from ${LLVMCONFIGEXE} is ${LLVMINCLUDEDIR}") + else() + MESSAGE(FATAL_ERROR "binder: llvm-config not found") + endif() +endif() +IF( NOT LibClang_INCLUDE_DIR ) +#This will assure non-empty argument for binder in tests. + set(LibClang_INCLUDE_DIR "/") +endif() +MESSAGE(STATUS "binder: LibClang_INCLUDE_DIR, the location of headers is ${LibClang_INCLUDE_DIR}") +MESSAGE(STATUS "binder: LLVM_VERSION_MAJOR=${LLVM_VERSION_MAJOR}") +MESSAGE(STATUS "binder: LLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}") +MESSAGE(STATUS "binder: LLVM_VERSION_PATCH=${LLVM_VERSION_PATCH}") +if( ${LLVM_VERSION_MAJOR} GREATER_EQUAL 16 ) +# LLVM 16 introduces the use of C++ features from C++17 +set(CMAKE_CXX_STANDARD 17) +else() +set(CMAKE_CXX_STANDARD 14) +endif() +macro(add_clang_executable name) + add_executable( ${name} ${ARGN} ) +# set_target_properties(${name} PROPERTIES FOLDER "Clang executables") + message(STATUS "binder: We have cmake functions to update LLVM_COMPILE_FLAGS") + if (LLVM_COMPILER_IS_GCC_COMPATIBLE) + list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti") + elseif (MSVC) + list(APPEND LLVM_COMPILE_FLAGS "/GR-") + endif () +endmacro(add_clang_executable) +include_directories(source) +add_subdirectory(source) +if (BINDER_ENABLE_TEST) + if(${CMAKE_VERSION} VERSION_LESS "3.0.0") + message("You are running cmake version ${CMAKE_VERSION}.") + message("The testing suite will be disabled as it requires cmake 3.0.0 or higher.") + else() + ENABLE_TESTING() + add_subdirectory(test) + endif() +endif() diff --git a/binder/bin/.gitkeep b/binder/bin/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/build-binder.py b/build.py similarity index 100% rename from build-binder.py rename to build.py diff --git a/documentation/install.rst b/documentation/install.rst index a699977d..c81fd856 100644 --- a/documentation/install.rst +++ b/documentation/install.rst @@ -28,7 +28,7 @@ may not be compatible with the header files on the system Binder where is run. Building ******** -The steps below are encoded in `binder/build-binder.py` and `binder/build-and-run-tests.py` +The steps below are encoded in `binder/build.py` and `binder/build-and-run-tests.py` files so for default install you can just run `build-and-run-tests.py` script directly. This section describes how to build a dynamically-linked ``binder`` executable. To *statically* compile binder, see :ref:`building-static`. diff --git a/llvm-project b/llvm-project deleted file mode 160000 index c6aee8f1..00000000 --- a/llvm-project +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6aee8f17b27ae0328fa7fd50acbfcea477c3c79 diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 00000000..9a0dfc3d --- /dev/null +++ b/python/.gitignore @@ -0,0 +1,143 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# IDE config files +.vs/ +.vscode/ +.VSCodeCounter/ +.idea/ + +# CMake build/debug directory +cmake-build-*/ + +# Binder build files +binder/_version.py +binder/bin diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 00000000..aa997190 --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.4.3) +project(binder LANGUAGES CXX C) + +add_subdirectory(llvm-project/llvm) diff --git a/binder/__init__.py b/python/binder/__init__.py similarity index 100% rename from binder/__init__.py rename to python/binder/__init__.py diff --git a/binder/__main__.py b/python/binder/__main__.py similarity index 100% rename from binder/__main__.py rename to python/binder/__main__.py diff --git a/python/llvm-project b/python/llvm-project new file mode 160000 index 00000000..d587a972 --- /dev/null +++ b/python/llvm-project @@ -0,0 +1 @@ +Subproject commit d587a972a49438988e07b0a65033c1a55e0b854b diff --git a/pyproject.toml b/python/pyproject.toml similarity index 100% rename from pyproject.toml rename to python/pyproject.toml From 58fe1ebc16d0a845915bda01df6a96f2120d50df Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 19 Jun 2024 22:43:32 +0800 Subject: [PATCH 13/62] Update documentation --- documentation/install.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/documentation/install.rst b/documentation/install.rst index c81fd856..f8a78e81 100644 --- a/documentation/install.rst +++ b/documentation/install.rst @@ -3,7 +3,18 @@ Installation **Binder** is written in C++11 and must be built before use. This page describes the steps for the build process. Please note that installation require up to ~2.6+ Gb of free disk space. +Install pre-built wheels from PyPI +********************************** +The easiest way to install Binder is to use pre-built wheels from PyPI. To install Binder, run: + +.. code-block:: bash + + pip install cppbinder + +This will install the latest version of Binder and its dependencies. + +To build Binder from source, follow the instructions below. Requirements ************ From d4bfb906f0cfc7227d3684599497f9c46eb961d6 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 19 Jun 2024 22:54:47 +0800 Subject: [PATCH 14/62] Update wheels artifacts name --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 9d45e8e3..47e54ae9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -45,7 +45,7 @@ jobs: - uses: actions/upload-artifact@v4 if: always() with: - name: cppbinder-wheels-${{ matrix.os }} + name: cppbinder-wheels path: ./python/wheelhouse/*.whl - name: Upload wheels to release From a285a52d8aae114d6bad9bda778b28e1872384ce Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 19 Jun 2024 23:11:39 +0800 Subject: [PATCH 15/62] Skip some build on pull request --- .github/workflows/wheels.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 47e54ae9..7866b91b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -41,6 +41,9 @@ jobs: - name: Build wheels run: cd python && cibuildwheel --output-dir wheelhouse + env: + CIBW_ARCHS: ${{ github.event_name == 'release' && 'auto' || 'auto64' }} + CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx* cp312-win* cp312-manylinux*' }} - uses: actions/upload-artifact@v4 if: always() From f81fa9c302abe44a7a4b984e766cbfb9fdab5154 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 19 Jun 2024 23:13:25 +0800 Subject: [PATCH 16/62] Update working directory --- .github/workflows/wheels.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7866b91b..7700bec8 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -39,8 +39,9 @@ jobs: pipx install cibuildwheel - name: Build wheels - run: - cd python && cibuildwheel --output-dir wheelhouse + run: | + cibuildwheel --output-dir wheelhouse + working-directory: python env: CIBW_ARCHS: ${{ github.event_name == 'release' && 'auto' || 'auto64' }} CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx* cp312-win* cp312-manylinux*' }} @@ -78,7 +79,8 @@ jobs: - name: Build source distribution run: | - cd python && python -m build --sdist --outdir dist + python -m build --sdist --outdir dist + working-directory: python - uses: actions/upload-artifact@v4 if: always() From a685a9a0aa6c7677191b42e17b12fc475bfd7880 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 19 Jun 2024 23:21:31 +0800 Subject: [PATCH 17/62] Update README and LICENSE in pyproject.toml Revert "Update README and LICENSE in pyproject.toml" This reverts commit edd669d05569df7ab3be8bc44e0a05109f06295c. Update symbolic links Not using symbolic links for README and LICENSE --- python/LICENSE | 13 +++++++++++++ python/README.md | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 120000 python/LICENSE create mode 120000 python/README.md diff --git a/python/LICENSE b/python/LICENSE new file mode 120000 index 00000000..bb861ef3 --- /dev/null +++ b/python/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2016 Sergey Lyskov + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/python/README.md b/python/README.md new file mode 120000 index 00000000..9388c8f8 --- /dev/null +++ b/python/README.md @@ -0,0 +1,11 @@ +# Binder + +**Binder** is a tool for automatic generation of Python bindings for C++11 projects using [Pybind11](https://github.com/pybind/pybind11) and [Clang LibTooling](http://clang.llvm.org/docs/LibTooling.html) libraries. That is, Binder, takes a C++ project and compiles it into objects and functions that are all usable within Python. Binder is different from prior tools in that it handles special features new in C++11. + +[![Documentation Status](https://readthedocs.org/projects/cppbinder/badge/?version=latest)](http://cppbinder.readthedocs.org/en/latest/?badge=latest) +![](https://github.com/RosettaCommons/binder/workflows/build/badge.svg) + +Reference documentation is provided at +[http://cppbinder.readthedocs.org/en/latest](http://cppbinder.readthedocs.org/en/latest). +A PDF version of the manual is available +[here](https://media.readthedocs.org/pdf/cppbinder/latest/cppbinder.pdf). From cacebb186e6264088fe69b6f4ff40a6b68320c6a Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 03:20:26 +0800 Subject: [PATCH 18/62] [skip ci] Update root directory for setuptools-scm --- python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index ced97e8f..57d2a7ed 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -83,6 +83,6 @@ musllinux-s390x-image = "musllinux_1_1" archs = ["universal2"] [tool.setuptools_scm] -root = "." +root = ".." version_scheme = "post-release" fallback_version = "0.0.1" From ed28689852fc7d461d31b12355dbf4469510a546 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 03:25:08 +0800 Subject: [PATCH 19/62] Update wheels.yml --- .github/workflows/wheels.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7700bec8..baf60c70 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -43,8 +43,7 @@ jobs: cibuildwheel --output-dir wheelhouse working-directory: python env: - CIBW_ARCHS: ${{ github.event_name == 'release' && 'auto' || 'auto64' }} - CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx* cp312-win* cp312-manylinux*' }} + CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx_universal2 cp312-win_amd64 cp312-manylinux_x86_64' }} - uses: actions/upload-artifact@v4 if: always() From d83a3acf23f3295f49fd2f2ee465f8eab5b5ac77 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 03:28:48 +0800 Subject: [PATCH 20/62] Delete --- python/LICENSE | 13 ------------- python/README.md | 11 ----------- 2 files changed, 24 deletions(-) delete mode 120000 python/LICENSE delete mode 120000 python/README.md diff --git a/python/LICENSE b/python/LICENSE deleted file mode 120000 index bb861ef3..00000000 --- a/python/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2016 Sergey Lyskov - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files -(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/python/README.md b/python/README.md deleted file mode 120000 index 9388c8f8..00000000 --- a/python/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Binder - -**Binder** is a tool for automatic generation of Python bindings for C++11 projects using [Pybind11](https://github.com/pybind/pybind11) and [Clang LibTooling](http://clang.llvm.org/docs/LibTooling.html) libraries. That is, Binder, takes a C++ project and compiles it into objects and functions that are all usable within Python. Binder is different from prior tools in that it handles special features new in C++11. - -[![Documentation Status](https://readthedocs.org/projects/cppbinder/badge/?version=latest)](http://cppbinder.readthedocs.org/en/latest/?badge=latest) -![](https://github.com/RosettaCommons/binder/workflows/build/badge.svg) - -Reference documentation is provided at -[http://cppbinder.readthedocs.org/en/latest](http://cppbinder.readthedocs.org/en/latest). -A PDF version of the manual is available -[here](https://media.readthedocs.org/pdf/cppbinder/latest/cppbinder.pdf). From da8a9c708b16cd35d933e39fde56d7b6523acbf1 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 03:29:02 +0800 Subject: [PATCH 21/62] Add --- python/LICENSE | 13 +++++++++++++ python/README.md | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 python/LICENSE create mode 100644 python/README.md diff --git a/python/LICENSE b/python/LICENSE new file mode 100644 index 00000000..bb861ef3 --- /dev/null +++ b/python/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2016 Sergey Lyskov + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/python/README.md b/python/README.md new file mode 100644 index 00000000..9388c8f8 --- /dev/null +++ b/python/README.md @@ -0,0 +1,11 @@ +# Binder + +**Binder** is a tool for automatic generation of Python bindings for C++11 projects using [Pybind11](https://github.com/pybind/pybind11) and [Clang LibTooling](http://clang.llvm.org/docs/LibTooling.html) libraries. That is, Binder, takes a C++ project and compiles it into objects and functions that are all usable within Python. Binder is different from prior tools in that it handles special features new in C++11. + +[![Documentation Status](https://readthedocs.org/projects/cppbinder/badge/?version=latest)](http://cppbinder.readthedocs.org/en/latest/?badge=latest) +![](https://github.com/RosettaCommons/binder/workflows/build/badge.svg) + +Reference documentation is provided at +[http://cppbinder.readthedocs.org/en/latest](http://cppbinder.readthedocs.org/en/latest). +A PDF version of the manual is available +[here](https://media.readthedocs.org/pdf/cppbinder/latest/cppbinder.pdf). From 355a879a7cdcea1fdbbfdf9ddb38043270b6d83e Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 03:58:04 +0800 Subject: [PATCH 22/62] Update wheels.yml --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index baf60c70..672bd1cb 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -48,7 +48,7 @@ jobs: - uses: actions/upload-artifact@v4 if: always() with: - name: cppbinder-wheels + name: cppbinder-wheels-${{ matrix.os }} path: ./python/wheelhouse/*.whl - name: Upload wheels to release From 534dc4e1b27cabd381da3955eff4aead23f14889 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 04:09:33 +0800 Subject: [PATCH 23/62] Build the package in the root directory --- .github/workflows/wheels.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 672bd1cb..4bc342f8 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -40,8 +40,7 @@ jobs: - name: Build wheels run: | - cibuildwheel --output-dir wheelhouse - working-directory: python + cibuildwheel --output-dir wheelhouse python env: CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx_universal2 cp312-win_amd64 cp312-manylinux_x86_64' }} @@ -49,13 +48,13 @@ jobs: if: always() with: name: cppbinder-wheels-${{ matrix.os }} - path: ./python/wheelhouse/*.whl + path: ./wheelhouse/*.whl - name: Upload wheels to release if: github.event_name == 'release' shell: bash run: | - gh release upload ${{ github.ref_name }} ./python/wheelhouse/*.whl --clobber + gh release upload ${{ github.ref_name }} ./wheelhouse/*.whl --clobber env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 441c9137d1ea86af1495c8d882bb3ba0b1fcad38 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 04:19:59 +0800 Subject: [PATCH 24/62] Delete README and LICENSE --- python/LICENSE | 13 ------------- python/README.md | 11 ----------- 2 files changed, 24 deletions(-) delete mode 100644 python/LICENSE delete mode 100644 python/README.md diff --git a/python/LICENSE b/python/LICENSE deleted file mode 100644 index bb861ef3..00000000 --- a/python/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2016 Sergey Lyskov - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files -(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/python/README.md b/python/README.md deleted file mode 100644 index 9388c8f8..00000000 --- a/python/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Binder - -**Binder** is a tool for automatic generation of Python bindings for C++11 projects using [Pybind11](https://github.com/pybind/pybind11) and [Clang LibTooling](http://clang.llvm.org/docs/LibTooling.html) libraries. That is, Binder, takes a C++ project and compiles it into objects and functions that are all usable within Python. Binder is different from prior tools in that it handles special features new in C++11. - -[![Documentation Status](https://readthedocs.org/projects/cppbinder/badge/?version=latest)](http://cppbinder.readthedocs.org/en/latest/?badge=latest) -![](https://github.com/RosettaCommons/binder/workflows/build/badge.svg) - -Reference documentation is provided at -[http://cppbinder.readthedocs.org/en/latest](http://cppbinder.readthedocs.org/en/latest). -A PDF version of the manual is available -[here](https://media.readthedocs.org/pdf/cppbinder/latest/cppbinder.pdf). From 22e4431f8648be0cc089ee762fb9bf7cbd6fa9d9 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 04:20:42 +0800 Subject: [PATCH 25/62] Add README and LICENSE back to symbolic links --- python/LICENSE | 1 + python/README.md | 1 + 2 files changed, 2 insertions(+) create mode 120000 python/LICENSE create mode 120000 python/README.md diff --git a/python/LICENSE b/python/LICENSE new file mode 120000 index 00000000..ea5b6064 --- /dev/null +++ b/python/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/python/README.md b/python/README.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/python/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file From b26f4fcf8d4721f31aa2db8dd9c8bd6db7b0a44d Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 09:06:07 +0800 Subject: [PATCH 26/62] Update __init__.py --- python/binder/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/binder/__init__.py b/python/binder/__init__.py index b80096ec..3e99166c 100644 --- a/python/binder/__init__.py +++ b/python/binder/__init__.py @@ -22,7 +22,7 @@ def _get_version(): # Only shell out to a git subprocess if really needed, and not on a # shallow clone, such as those used by CI, as the latter would trigger # a warning from setuptools_scm. - root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) if os.path.exists(os.path.join(root, ".git")) and not os.path.exists(os.path.join(root, ".git/shallow")): try: import setuptools_scm From 70319d404f4d2bac79126e590b9c4dcb76fbee3d Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 09:54:46 +0800 Subject: [PATCH 27/62] Update artifacts name --- .github/workflows/wheels.yml | 46 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 4bc342f8..73ca3f44 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -29,25 +29,24 @@ jobs: - macos-14 fail-fast: false steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 with: fetch-depth: 0 submodules: recursive - - name: Setup cibuildwheel + - name: Setup cibuildwheel and build wheels run: | pipx install cibuildwheel - - - name: Build wheels - run: | - cibuildwheel --output-dir wheelhouse python + pipx run cibuildwheel python env: CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx_universal2 cp312-win_amd64 cp312-manylinux_x86_64' }} - - uses: actions/upload-artifact@v4 + - name: Upload wheels to artifacts + uses: actions/upload-artifact@v4 if: always() with: - name: cppbinder-wheels-${{ matrix.os }} + name: cppbinder-wheels-${{ matrix.os }}-${{ github.event_name == 'release' && github.ref_name || github.sha }} path: ./wheelhouse/*.whl - name: Upload wheels to release @@ -61,32 +60,26 @@ jobs: build-sdist: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 with: fetch-depth: 0 submodules: recursive - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - - name: Build source distribution + - name: Setup build and build source distribution run: | - python -m build --sdist --outdir dist + pipx install build + pipx run build --sdist --outdir dist working-directory: python - - uses: actions/upload-artifact@v4 + - name: Upload source distribution to artifacts + uses: actions/upload-artifact@v4 if: always() with: - name: cppbinder-sdist + name: cppbinder-sdist-${{ github.event_name == 'release' && github.ref_name || github.sha }} path: ./python/dist/*.tar.gz - - name: Upload wheels to release + - name: Upload source distribution to release if: github.event_name == 'release' run: | gh release upload ${{ github.ref_name }} ./python/dist/*.tar.gz --clobber @@ -98,12 +91,15 @@ jobs: if: github.event_name == 'release' runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 - - name: Download wheels + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download wheels and source distribution run: | gh release download ${{ github.ref_name }} --pattern *.whl --pattern *.tar.gz --dir dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@v1.8.14 with: From f51a330af6cb82c55ee74f1b31ba3e140cb41525 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 20 Jun 2024 16:57:05 +0800 Subject: [PATCH 28/62] Update installation documentation --- documentation/install.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/documentation/install.rst b/documentation/install.rst index f8a78e81..f5c5915f 100644 --- a/documentation/install.rst +++ b/documentation/install.rst @@ -1,10 +1,5 @@ -Installation -============ -**Binder** is written in C++11 and must be built before use. This page describes the steps for the build process. -Please note that installation require up to ~2.6+ Gb of free disk space. - -Install pre-built wheels from PyPI -********************************** +Installation with pre-built wheels +================================== The easiest way to install Binder is to use pre-built wheels from PyPI. To install Binder, run: @@ -16,6 +11,13 @@ This will install the latest version of Binder and its dependencies. To build Binder from source, follow the instructions below. +Installation from source +======================== +**Binder** is written in C++11 and must be built before use. This page describes the steps for the build process. +Please note that installation require up to ~2.6+ Gb of free disk space. + + + Requirements ************ The following tools need to be present in order to build and use **Binder** From 68ecb1ad78cb21d11f186219a16f2170b193b8df Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Fri, 21 Jun 2024 14:11:31 +0800 Subject: [PATCH 29/62] Update llvm-project --- python/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/llvm-project b/python/llvm-project index d587a972..51e587a9 160000 --- a/python/llvm-project +++ b/python/llvm-project @@ -1 +1 @@ -Subproject commit d587a972a49438988e07b0a65033c1a55e0b854b +Subproject commit 51e587a970b65ef1c8f551374cbc1a35c0fce591 From 9c348cecf137ad74df16d7fedf76e360e505e533 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 23 Jun 2024 18:30:03 +0800 Subject: [PATCH 30/62] Update version scheme to no-guess-dev --- python/binder/__init__.py | 6 +++--- python/pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/binder/__init__.py b/python/binder/__init__.py index 3e99166c..72eccd58 100644 --- a/python/binder/__init__.py +++ b/python/binder/__init__.py @@ -7,16 +7,15 @@ except ImportError: _default_version = "0.0.1" - __all__ = ["binder", "__version__"] - BINDER_BIN_DIR = os.path.join(os.path.dirname(__file__), "bin") def binder(): raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder")] + sys.argv[1:], close_fds=False)) + def _get_version(): """Return the version string used for __version__.""" # Only shell out to a git subprocess if really needed, and not on a @@ -29,7 +28,7 @@ def _get_version(): return setuptools_scm.get_version( root=root, - version_scheme="post-release", + version_scheme="no-guess-dev", fallback_version=_default_version, ) except (ImportError, LookupError): @@ -37,4 +36,5 @@ def _get_version(): else: # Get the version from the _version.py setuptools_scm file. return _default_version + __version__ = _get_version() diff --git a/python/pyproject.toml b/python/pyproject.toml index 57d2a7ed..c4fc27e3 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -84,5 +84,5 @@ archs = ["universal2"] [tool.setuptools_scm] root = ".." -version_scheme = "post-release" +version_scheme = "no-guess-dev" fallback_version = "0.0.1" From 0e6a79eef1259e48aef726865e2299690bf41962 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 23 Jun 2024 18:49:33 +0800 Subject: [PATCH 31/62] Add test to check binder and llvm versions --- python/pyproject.toml | 2 ++ python/tests/test_binder.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 python/tests/test_binder.py diff --git a/python/pyproject.toml b/python/pyproject.toml index c4fc27e3..005c0e8d 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -73,6 +73,8 @@ version = "${version}" [tool.cibuildwheel] build = "cp312-*" +test-requires = ["pytest", "packaging"] +test-command = "pytest {package}/tests" musllinux-x86_64-image = "musllinux_1_1" musllinux-i686-image = "musllinux_1_1" musllinux-aarch64-image = "musllinux_1_1" diff --git a/python/tests/test_binder.py b/python/tests/test_binder.py new file mode 100644 index 00000000..a0d390ac --- /dev/null +++ b/python/tests/test_binder.py @@ -0,0 +1,17 @@ +import re +import subprocess + +from binder import __version__ +from packaging.version import Version + + +def test_check_binder_llvm_version(): + # Check the output of the `binder -version` command to obtain the versions of Binder and LLVM + output = subprocess.check_output(["binder", "-version"]).decode() + pattern = r"binder ([\d\.]+)\nLLVM ([\d\.]+)" + binder_version, llvm_version = re.match(pattern, output).groups() + + # Check the versions of Binder and LLVM + binder_base_version = Version(__version__).base_version + assert binder_base_version == binder_version, f"Binder version mismatch: {binder_base_version} != {binder_version}" + assert llvm_version == "6.0.1", f"LLVM version mismatch: {llvm_version} != 6.0.1" From aa1ec55ea1839658ab3a5cfca5a7739fc196d10a Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 23 Jun 2024 19:01:52 +0800 Subject: [PATCH 32/62] Do not check binder version --- python/pyproject.toml | 2 +- python/tests/test_binder.py | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 005c0e8d..66df8393 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -73,7 +73,7 @@ version = "${version}" [tool.cibuildwheel] build = "cp312-*" -test-requires = ["pytest", "packaging"] +test-requires = ["pytest"] test-command = "pytest {package}/tests" musllinux-x86_64-image = "musllinux_1_1" musllinux-i686-image = "musllinux_1_1" diff --git a/python/tests/test_binder.py b/python/tests/test_binder.py index a0d390ac..cc97dc76 100644 --- a/python/tests/test_binder.py +++ b/python/tests/test_binder.py @@ -1,9 +1,6 @@ import re import subprocess -from binder import __version__ -from packaging.version import Version - def test_check_binder_llvm_version(): # Check the output of the `binder -version` command to obtain the versions of Binder and LLVM @@ -11,7 +8,5 @@ def test_check_binder_llvm_version(): pattern = r"binder ([\d\.]+)\nLLVM ([\d\.]+)" binder_version, llvm_version = re.match(pattern, output).groups() - # Check the versions of Binder and LLVM - binder_base_version = Version(__version__).base_version - assert binder_base_version == binder_version, f"Binder version mismatch: {binder_base_version} != {binder_version}" + # Check the versions of LLVM assert llvm_version == "6.0.1", f"LLVM version mismatch: {llvm_version} != 6.0.1" From a4e13b1a1462ae52f1e8822a5638381d127c0847 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 10 Jul 2024 11:03:06 +0800 Subject: [PATCH 33/62] Build wheels on all archs --- python/pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/pyproject.toml b/python/pyproject.toml index 66df8393..b743e3b5 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -81,9 +81,15 @@ musllinux-aarch64-image = "musllinux_1_1" musllinux-ppc64le-image = "musllinux_1_1" musllinux-s390x-image = "musllinux_1_1" +[tool.cibuildwheel.windows] +archs = ["AMD64", "ARM64", "x86"] + [tool.cibuildwheel.macos] archs = ["universal2"] +[tool.cibuildwheel.linux] +archs = ["x86_64", "i686", "aarch64", "ppc64le", "s390x"] + [tool.setuptools_scm] root = ".." version_scheme = "no-guess-dev" From bde1fe96ff5cca7d2d4d1a9479a2d082b9d064d1 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 10 Jul 2024 16:39:54 +0800 Subject: [PATCH 34/62] Revert: install binder to CMAKE_INSTALL_BINDIR --- python/pyproject.toml | 1 + source/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index b743e3b5..42633ccb 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -62,6 +62,7 @@ cmake.define.LLVM_ENABLE_PROJECTS = "clang" # Wheel configuration wheel.packages = ["binder"] +wheel.install-dir = "binder" wheel.py-api = "py2.py3" wheel.expand-macos-universal-tags = true diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 985335f8..26153abe 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -129,4 +129,4 @@ else() endif() install(TARGETS binder PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_WRITE OWNER_READ OWNER_EXECUTE -DESTINATION binder/bin COMPONENT binder) +DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binder) From 9ba40397a68427f9525d2d4ed263f81ae2e03f8a Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 29 Jul 2024 23:34:32 +0800 Subject: [PATCH 35/62] Setup QEMU on linux when building wheels --- .github/workflows/wheels.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 73ca3f44..b74fdd96 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -35,6 +35,12 @@ jobs: fetch-depth: 0 submodules: recursive + - name: Setup QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Setup cibuildwheel and build wheels run: | pipx install cibuildwheel From 1e07666fad22588a6a7b525f6731839be437edb9 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 29 Jul 2024 23:38:31 +0800 Subject: [PATCH 36/62] Always upload wheels to release assets --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b74fdd96..f5012daa 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -56,7 +56,7 @@ jobs: path: ./wheelhouse/*.whl - name: Upload wheels to release - if: github.event_name == 'release' + if: always() && github.event_name == 'release' shell: bash run: | gh release upload ${{ github.ref_name }} ./wheelhouse/*.whl --clobber From 6ea8f96826321a779eb37b3cd43b989d7ecf59dd Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 29 Jul 2024 23:47:28 +0800 Subject: [PATCH 37/62] Skip some archs --- python/pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 42633ccb..b1552da8 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -83,10 +83,10 @@ musllinux-ppc64le-image = "musllinux_1_1" musllinux-s390x-image = "musllinux_1_1" [tool.cibuildwheel.windows] -archs = ["AMD64", "ARM64", "x86"] +archs = ["AMD64", "x86"] [tool.cibuildwheel.macos] -archs = ["universal2"] +archs = ["x86_64", "arm64"] [tool.cibuildwheel.linux] archs = ["x86_64", "i686", "aarch64", "ppc64le", "s390x"] From 79a13dbd97e5c820b77375f65fd311bc640d0b6d Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 29 Jul 2024 23:59:20 +0800 Subject: [PATCH 38/62] Build universal2 wheels on macos --- python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index b1552da8..53153932 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -86,7 +86,7 @@ musllinux-s390x-image = "musllinux_1_1" archs = ["AMD64", "x86"] [tool.cibuildwheel.macos] -archs = ["x86_64", "arm64"] +archs = ["universal2"] [tool.cibuildwheel.linux] archs = ["x86_64", "i686", "aarch64", "ppc64le", "s390x"] From f2741d1fd3325a0d8e1f9a8d09a5f5be4b296eef Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 3 Sep 2024 16:45:45 +0800 Subject: [PATCH 39/62] Do not build aarch64, ppc64le and s390x wheels --- python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 53153932..a52cf026 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -89,7 +89,7 @@ archs = ["AMD64", "x86"] archs = ["universal2"] [tool.cibuildwheel.linux] -archs = ["x86_64", "i686", "aarch64", "ppc64le", "s390x"] +archs = ["x86_64", "i686"] [tool.setuptools_scm] root = ".." From aaca9144d55aed10bd4d794a8fff5a653eaba374 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 3 Sep 2024 16:51:12 +0800 Subject: [PATCH 40/62] Wheels can be built manually --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f5012daa..c12a4670 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -9,6 +9,7 @@ on: - "source/**" release: types: [published] + workflow_dispatch: concurrency: group: wheels-${{ github.workflow }}-${{ github.ref }} From dbd076d5a416745d31b578bb17ab6fd99ae4c60a Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 3 Sep 2024 16:52:27 +0800 Subject: [PATCH 41/62] Build the default wheels --- python/pyproject.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index a52cf026..8807759b 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -82,15 +82,9 @@ musllinux-aarch64-image = "musllinux_1_1" musllinux-ppc64le-image = "musllinux_1_1" musllinux-s390x-image = "musllinux_1_1" -[tool.cibuildwheel.windows] -archs = ["AMD64", "x86"] - [tool.cibuildwheel.macos] archs = ["universal2"] -[tool.cibuildwheel.linux] -archs = ["x86_64", "i686"] - [tool.setuptools_scm] root = ".." version_scheme = "no-guess-dev" From d0d9f7bf1619e3708149c02cde014997ca1da47e Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Wed, 4 Sep 2024 10:13:21 +0800 Subject: [PATCH 42/62] Update version configurations --- python/binder/__init__.py | 38 ++++++++++++++++---------------------- python/binder/__main__.py | 1 - 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/python/binder/__init__.py b/python/binder/__init__.py index 72eccd58..9d94cb9e 100644 --- a/python/binder/__init__.py +++ b/python/binder/__init__.py @@ -1,11 +1,7 @@ import os -import sys import subprocess - -try: - from ._version import version as _default_version -except ImportError: - _default_version = "0.0.1" +import sys +from re import error as RegexError __all__ = ["binder", "__version__"] @@ -13,28 +9,26 @@ def binder(): - raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder")] + sys.argv[1:], close_fds=False)) + raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder"), *sys.argv[1:]], close_fds=False)) def _get_version(): - """Return the version string used for __version__.""" - # Only shell out to a git subprocess if really needed, and not on a - # shallow clone, such as those used by CI, as the latter would trigger - # a warning from setuptools_scm. root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) - if os.path.exists(os.path.join(root, ".git")) and not os.path.exists(os.path.join(root, ".git/shallow")): + if os.path.exists(os.path.join(root, ".git")) and not os.path.exists( + os.path.join(root, ".git/shallow") + ): try: import setuptools_scm - return setuptools_scm.get_version( - root=root, - version_scheme="no-guess-dev", - fallback_version=_default_version, - ) - except (ImportError, LookupError): - return _default_version - else: # Get the version from the _version.py setuptools_scm file. - return _default_version + return setuptools_scm.get_version(root=str(root)) + except (ImportError, RegexError, LookupError): + pass + try: + from ._version import version + + return version + except ImportError: + return "0.0.1" -__version__ = _get_version() +__version__: str = _get_version() diff --git a/python/binder/__main__.py b/python/binder/__main__.py index 5f033177..03d32031 100644 --- a/python/binder/__main__.py +++ b/python/binder/__main__.py @@ -1,5 +1,4 @@ from binder import binder - if __name__ == "__main__": binder() From dbf1ec824955b95b75e07e588f9214e4d57cc94b Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sat, 12 Oct 2024 13:16:37 +0800 Subject: [PATCH 43/62] Use cp313 to build the wheels --- .github/workflows/wheels.yml | 2 +- python/pyproject.toml | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c12a4670..37aab76a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -47,7 +47,7 @@ jobs: pipx install cibuildwheel pipx run cibuildwheel python env: - CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx_universal2 cp312-win_amd64 cp312-manylinux_x86_64' }} + CIBW_BUILD: ${{ github.event_name == 'release' && 'cp313-*' || 'cp313-macosx_universal2 cp313-win_amd64 cp313-manylinux_x86_64' }} - name: Upload wheels to artifacts uses: actions/upload-artifact@v4 diff --git a/python/pyproject.toml b/python/pyproject.toml index 8807759b..e8b0f537 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,21 +13,7 @@ authors = [ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.0", - "Programming Language :: Python :: 3.1", - "Programming Language :: Python :: 3.2", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "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 :: 3.12", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] @@ -73,7 +59,7 @@ version = "${version}" ''' [tool.cibuildwheel] -build = "cp312-*" +build = "cp313-*" test-requires = ["pytest"] test-command = "pytest {package}/tests" musllinux-x86_64-image = "musllinux_1_1" From 1b614662f928f1dd16031ed70f56e70ad434a45b Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sat, 12 Oct 2024 13:22:30 +0800 Subject: [PATCH 44/62] Only build source distribution on release --- .github/workflows/wheels.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 37aab76a..6d4f575b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -65,6 +65,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build-sdist: + if: github.event_name == 'release' runs-on: ubuntu-22.04 steps: - name: Checkout repository @@ -81,13 +82,11 @@ jobs: - name: Upload source distribution to artifacts uses: actions/upload-artifact@v4 - if: always() with: name: cppbinder-sdist-${{ github.event_name == 'release' && github.ref_name || github.sha }} path: ./python/dist/*.tar.gz - name: Upload source distribution to release - if: github.event_name == 'release' run: | gh release upload ${{ github.ref_name }} ./python/dist/*.tar.gz --clobber env: From e731726ffb74466e1fa7b9a6125d72ebc4e17403 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 13 Oct 2024 00:53:39 +0800 Subject: [PATCH 45/62] Test wheels on different platforms and archs (#4) --- .github/workflows/wheels.yml | 42 +++++++++++++++++++++++++++++++----- .gitmodules | 4 ++-- python/llvm-project | 2 +- python/pyproject.toml | 14 +++++++----- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6d4f575b..07376808 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,11 +1,19 @@ name: Wheels on: + push: + branches: + - master + paths: + - ".github/workflows/wheels.yml" + - "python/**" + - "source/**" pull_request: branches: - master paths: - ".github/workflows/wheels.yml" + - "python/**" - "source/**" release: types: [published] @@ -25,9 +33,20 @@ jobs: strategy: matrix: os: - - windows-2022 - ubuntu-22.04 - - macos-14 + archs: + - "x86_64" + - "i686" + impl: + - "manylinux" + - "musllinux" + include: + - os: windows-2022 + archs: "AMD64" + - os: windows-2022 + archs: "x86" + - os: macos-13 + archs: "universal2" fail-fast: false steps: - name: Checkout repository @@ -36,24 +55,31 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Setup QEMU + - name: Setup QEMU for Linux cross-compilation if: runner.os == 'Linux' uses: docker/setup-qemu-action@v3 with: platforms: all + - name: Setup LLVM project + shell: bash + run: | + echo 'add_subdirectory(binder)' > python/llvm-project/clang-tools-extra/CMakeLists.txt + cp -r source python/llvm-project/clang-tools-extra/binder + - name: Setup cibuildwheel and build wheels run: | pipx install cibuildwheel pipx run cibuildwheel python env: - CIBW_BUILD: ${{ github.event_name == 'release' && 'cp313-*' || 'cp313-macosx_universal2 cp313-win_amd64 cp313-manylinux_x86_64' }} + CIBW_BUILD: cp313-${{ matrix.impl }}* + CIBW_ARCHS: ${{ matrix.archs == '' && 'auto' || matrix.archs }} - name: Upload wheels to artifacts uses: actions/upload-artifact@v4 if: always() with: - name: cppbinder-wheels-${{ matrix.os }}-${{ github.event_name == 'release' && github.ref_name || github.sha }} + name: cppbinder-wheels-${{ matrix.os }}-${{ matrix.archs }}-${{ matrix.impl }}-${{ github.event_name == 'release' && github.ref_name || github.sha }} path: ./wheelhouse/*.whl - name: Upload wheels to release @@ -74,6 +100,12 @@ jobs: fetch-depth: 0 submodules: recursive + - name: Setup LLVM project + shell: bash + run: | + echo 'add_subdirectory(binder)' > python/llvm-project/llvm/clang-tools-extra/CMakeLists.txt + cp -r source python/llvm-project/llvm/clang-tools-extra/binder + - name: Setup build and build source distribution run: | pipx install build diff --git a/.gitmodules b/.gitmodules index 1e04769a..afa07c24 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "llvm-project"] +[submodule "python/llvm-project"] path = python/llvm-project - url = https://github.com/haiiliin/llvm-project.git + url = https://github.com/llvm/llvm-project.git diff --git a/python/llvm-project b/python/llvm-project index 51e587a9..d359f209 160000 --- a/python/llvm-project +++ b/python/llvm-project @@ -1 +1 @@ -Subproject commit 51e587a970b65ef1c8f551374cbc1a35c0fce591 +Subproject commit d359f2096850c68b708bc25a7baca4282945949f diff --git a/python/pyproject.toml b/python/pyproject.toml index e8b0f537..02062e92 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core", "setuptools", "setuptools-scm", "pybind11"] +requires = ["scikit-build-core>=0.10.0", "setuptools", "setuptools-scm", "pybind11"] build-backend = "scikit_build_core.build" [project] @@ -28,9 +28,13 @@ Documentation = "https://cppbinder.readthedocs.io/" binder = "binder:binder" [tool.scikit-build] -minimum-version = "0.8" +minimum-version = "build-system.requires" build-dir = "build/{wheel_tag}" +# Print verbose output +build.verbose = true +logging.level = "INFO" + # Dynamic versioning metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" @@ -39,7 +43,7 @@ sdist.include = ["binder/_version.py"] # Components to install and targets to build install.components = ["binder"] -cmake.targets = ["binder"] +build.targets = ["binder"] # Cmake defines cmake.define.LLVM_ENABLE_EH = "ON" @@ -60,6 +64,7 @@ version = "${version}" [tool.cibuildwheel] build = "cp313-*" +build-verbosity = 1 test-requires = ["pytest"] test-command = "pytest {package}/tests" musllinux-x86_64-image = "musllinux_1_1" @@ -73,5 +78,4 @@ archs = ["universal2"] [tool.setuptools_scm] root = ".." -version_scheme = "no-guess-dev" -fallback_version = "0.0.1" +git_describe_command = ["git", "describe", "--long", "--tags", "--match", "*[0-9]*"] From 61c1b6bea052696a1ff039fe0414fce56656bcde Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 13 Oct 2024 11:53:56 +0800 Subject: [PATCH 46/62] Update wheels.yml --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 07376808..7000b56e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,7 +73,7 @@ jobs: pipx run cibuildwheel python env: CIBW_BUILD: cp313-${{ matrix.impl }}* - CIBW_ARCHS: ${{ matrix.archs == '' && 'auto' || matrix.archs }} + CIBW_ARCHS: ${{ matrix.archs }} - name: Upload wheels to artifacts uses: actions/upload-artifact@v4 From 0b809de91d274fafe11dabb6eddc810801581560 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 14 Oct 2024 11:31:16 +0800 Subject: [PATCH 47/62] Update .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 384cfb91..bfa70639 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,3 @@ build documentation/.build/ source/.gitignore -.idea/ -cmake-*/ -dist/ From 264c34de8b15b5da140df73fe94c4448228f0abb Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 14 Oct 2024 11:39:41 +0800 Subject: [PATCH 48/62] Remove `__version__` in the root package --- python/binder/__init__.py | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/python/binder/__init__.py b/python/binder/__init__.py index 9d94cb9e..845e0c64 100644 --- a/python/binder/__init__.py +++ b/python/binder/__init__.py @@ -1,34 +1,8 @@ import os import subprocess import sys -from re import error as RegexError - -__all__ = ["binder", "__version__"] - -BINDER_BIN_DIR = os.path.join(os.path.dirname(__file__), "bin") def binder(): + BINDER_BIN_DIR = os.path.join(os.path.dirname(__file__), "bin") raise SystemExit(subprocess.call([os.path.join(BINDER_BIN_DIR, "binder"), *sys.argv[1:]], close_fds=False)) - - -def _get_version(): - root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) - if os.path.exists(os.path.join(root, ".git")) and not os.path.exists( - os.path.join(root, ".git/shallow") - ): - try: - import setuptools_scm - - return setuptools_scm.get_version(root=str(root)) - except (ImportError, RegexError, LookupError): - pass - try: - from ._version import version - - return version - except ImportError: - return "0.0.1" - - -__version__: str = _get_version() From 5bcdf7d886b5cbe13135b23fb9ecd4459a8d7030 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 14 Oct 2024 12:30:34 +0800 Subject: [PATCH 49/62] Revert `CMAKE_CXX_FLAGS` changes (#6) --- source/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 26153abe..5523d3b1 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -122,10 +122,6 @@ else() clangAST clangFrontend ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_COMPILE_FLAGS}") - list(REMOVE_ITEM CMAKE_CXX_FLAGS "-fno-exceptions") - string (REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - message(STATUS "binder: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") endif() install(TARGETS binder PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_WRITE OWNER_READ OWNER_EXECUTE From b7ec5b5b93ba964166dd9d3e56930f9c0a48ddf0 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 14 Oct 2024 12:48:09 +0800 Subject: [PATCH 50/62] Update install.rst --- documentation/install.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/documentation/install.rst b/documentation/install.rst index f5c5915f..cb9ec537 100644 --- a/documentation/install.rst +++ b/documentation/install.rst @@ -1,7 +1,7 @@ -Installation with pre-built wheels -================================== +Install from PyPI +================= -The easiest way to install Binder is to use pre-built wheels from PyPI. To install Binder, run: +The easiest way to install Binder is to use pip to install pre-built wheels from PyPI: .. code-block:: bash @@ -11,8 +11,8 @@ This will install the latest version of Binder and its dependencies. To build Binder from source, follow the instructions below. -Installation from source -======================== +Build and install from source +============================= **Binder** is written in C++11 and must be built before use. This page describes the steps for the build process. Please note that installation require up to ~2.6+ Gb of free disk space. From 42bff71683631862900b57c76ff00406cd0cd263 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 01:21:15 +0800 Subject: [PATCH 51/62] Do not include version file in source distribution --- python/pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 02062e92..0c0f5626 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -38,9 +38,6 @@ logging.level = "INFO" # Dynamic versioning metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" -# Source distribution -sdist.include = ["binder/_version.py"] - # Components to install and targets to build install.components = ["binder"] build.targets = ["binder"] From a6c79a427b09696111553a61da3368d331a0c85c Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 01:32:49 +0800 Subject: [PATCH 52/62] Do not generate version file --- python/pyproject.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 0c0f5626..badee6ba 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -53,12 +53,6 @@ wheel.install-dir = "binder" wheel.py-api = "py2.py3" wheel.expand-macos-universal-tags = true -[[tool.scikit-build.generate]] -path = "binder/_version.py" -template = ''' -version = "${version}" -''' - [tool.cibuildwheel] build = "cp313-*" build-verbosity = 1 From 3da932e81dfd6edba2322a24fc4d78aa036bc50e Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 09:06:40 +0800 Subject: [PATCH 53/62] Build source distribution always --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7000b56e..962e116b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -91,7 +91,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build-sdist: - if: github.event_name == 'release' runs-on: ubuntu-22.04 steps: - name: Checkout repository @@ -119,6 +118,7 @@ jobs: path: ./python/dist/*.tar.gz - name: Upload source distribution to release + if: github.event_name == 'release' run: | gh release upload ${{ github.ref_name }} ./python/dist/*.tar.gz --clobber env: From 9101aa76286b10e1210e026174576c7213d5ffa2 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 09:15:55 +0800 Subject: [PATCH 54/62] Do not always upload wheels --- .github/workflows/wheels.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 962e116b..0a59260f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -77,13 +77,12 @@ jobs: - name: Upload wheels to artifacts uses: actions/upload-artifact@v4 - if: always() with: name: cppbinder-wheels-${{ matrix.os }}-${{ matrix.archs }}-${{ matrix.impl }}-${{ github.event_name == 'release' && github.ref_name || github.sha }} path: ./wheelhouse/*.whl - name: Upload wheels to release - if: always() && github.event_name == 'release' + if: github.event_name == 'release' shell: bash run: | gh release upload ${{ github.ref_name }} ./wheelhouse/*.whl --clobber From 9a9ac91b23b4c628c648e500d5af36c9fba05696 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 09:19:47 +0800 Subject: [PATCH 55/62] Update wheels.yml --- .github/workflows/wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0a59260f..a8b6d403 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -101,8 +101,8 @@ jobs: - name: Setup LLVM project shell: bash run: | - echo 'add_subdirectory(binder)' > python/llvm-project/llvm/clang-tools-extra/CMakeLists.txt - cp -r source python/llvm-project/llvm/clang-tools-extra/binder + echo 'add_subdirectory(binder)' > python/llvm-project/clang-tools-extra/CMakeLists.txt + cp -r source python/llvm-project/clang-tools-extra/binder - name: Setup build and build source distribution run: | From 8249e09a63d4baf042597b382be267f7b2fd9845 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 10:44:54 +0800 Subject: [PATCH 56/62] Do not upload wheels to release (#8) --- .github/workflows/wheels.yml | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index a8b6d403..d4eb471d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -23,10 +23,6 @@ concurrency: group: wheels-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -permissions: - contents: write - pull-requests: write - jobs: build-wheels: runs-on: ${{ matrix.os }} @@ -81,14 +77,6 @@ jobs: name: cppbinder-wheels-${{ matrix.os }}-${{ matrix.archs }}-${{ matrix.impl }}-${{ github.event_name == 'release' && github.ref_name || github.sha }} path: ./wheelhouse/*.whl - - name: Upload wheels to release - if: github.event_name == 'release' - shell: bash - run: | - gh release upload ${{ github.ref_name }} ./wheelhouse/*.whl --clobber - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-sdist: runs-on: ubuntu-22.04 steps: @@ -116,13 +104,6 @@ jobs: name: cppbinder-sdist-${{ github.event_name == 'release' && github.ref_name || github.sha }} path: ./python/dist/*.tar.gz - - name: Upload source distribution to release - if: github.event_name == 'release' - run: | - gh release upload ${{ github.ref_name }} ./python/dist/*.tar.gz --clobber - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - publish: needs: [build-wheels, build-sdist] if: github.event_name == 'release' @@ -132,10 +113,11 @@ jobs: uses: actions/checkout@v4 - name: Download wheels and source distribution - run: | - gh release download ${{ github.ref_name }} --pattern *.whl --pattern *.tar.gz --dir dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/download-artifact@v4 + with: + pattern: cppbinder-* + path: dist + merge-multiple: true - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@v1.8.14 From 2b65ece94375a94389b1045884de06e4ba9ccc13 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 11:26:34 +0800 Subject: [PATCH 57/62] Clone the LLVM project on building phase (#7) --- .github/workflows/wheels.yml | 14 ++++++++++++-- .gitmodules | 3 --- python/llvm-project | 1 - 3 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 .gitmodules delete mode 160000 python/llvm-project diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index d4eb471d..188d8b25 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -49,7 +49,6 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - submodules: recursive - name: Setup QEMU for Linux cross-compilation if: runner.os == 'Linux' @@ -57,6 +56,12 @@ jobs: with: platforms: all + - name: Clone LLVM project + shell: bash + run: | + git clone -b release/6.x https://github.com/llvm/llvm-project.git + working-directory: python + - name: Setup LLVM project shell: bash run: | @@ -84,7 +89,12 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - submodules: recursive + + - name: Clone LLVM project + shell: bash + run: | + git clone -b release/6.x https://github.com/llvm/llvm-project.git + working-directory: python - name: Setup LLVM project shell: bash diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index afa07c24..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "python/llvm-project"] - path = python/llvm-project - url = https://github.com/llvm/llvm-project.git diff --git a/python/llvm-project b/python/llvm-project deleted file mode 160000 index d359f209..00000000 --- a/python/llvm-project +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d359f2096850c68b708bc25a7baca4282945949f From c326299e00053b73c85292611a529a9651d0bf2d Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 11:57:11 +0800 Subject: [PATCH 58/62] [skip ci] Set `impl` for windows and macos wheels --- .github/workflows/wheels.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 188d8b25..c462734d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -39,10 +39,13 @@ jobs: include: - os: windows-2022 archs: "AMD64" + impl: win - os: windows-2022 archs: "x86" + impl: win - os: macos-13 archs: "universal2" + impl: macosx fail-fast: false steps: - name: Checkout repository From e207c5e15fed7397149d2a10e8d4c028fc66d0ee Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 21 Oct 2024 15:35:11 +0800 Subject: [PATCH 59/62] Delete .github/dependabot.yml --- .github/dependabot.yml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 31b6e3b0..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2 -updates: - # Dependencies for GitHub Actions - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" From 332c4868ab0061eff1e9094e890b06794f3f50dc Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Sun, 27 Oct 2024 21:51:33 +0800 Subject: [PATCH 60/62] Remove pybind11 build dependency --- python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index badee6ba..0ec63185 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core>=0.10.0", "setuptools", "setuptools-scm", "pybind11"] +requires = ["scikit-build-core>=0.10.0", "setuptools", "setuptools-scm"] build-backend = "scikit_build_core.build" [project] From 29ed8d6bf13862afcef195a36ca9e05521c758e6 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 10 Jun 2025 11:18:11 +0800 Subject: [PATCH 61/62] Update required cmake version to `>=3.15,<4` `scikit-build-core` requires 3.15+: https://scikit-build-core.readthedocs.io/en/latest/#features `cmake` 4.0 requires 3.5+: https://cmake.org/cmake/help/latest/release/4.0.html#deprecated-and-removed-features --- python/CMakeLists.txt | 2 +- python/pyproject.toml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index aa997190..2d3d1f1b 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.15) project(binder LANGUAGES CXX C) add_subdirectory(llvm-project/llvm) diff --git a/python/pyproject.toml b/python/pyproject.toml index 0ec63185..5eabf49e 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -42,10 +42,14 @@ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" install.components = ["binder"] build.targets = ["binder"] +# Cmake version +cmake.version = ">=3.15,<4" + # Cmake defines cmake.define.LLVM_ENABLE_EH = "ON" cmake.define.LLVM_ENABLE_RTTI = "ON" cmake.define.LLVM_ENABLE_PROJECTS = "clang" +cmake.define.CMAKE_POLICY_VERSION_MINIMUM = "3.15" # Wheel configuration wheel.packages = ["binder"] From c9097197949461ef47126c13f060b175c6c7719b Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Tue, 10 Jun 2025 15:52:44 +0800 Subject: [PATCH 62/62] Update runner images to build wheels (#9) --- .github/workflows/wheels.yml | 14 +++++++------- python/pyproject.toml | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c462734d..4a646e20 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: os: - - ubuntu-22.04 + - ubuntu-latest archs: - "x86_64" - "i686" @@ -37,10 +37,10 @@ jobs: - "manylinux" - "musllinux" include: - - os: windows-2022 + - os: windows-latest archs: "AMD64" impl: win - - os: windows-2022 + - os: windows-latest archs: "x86" impl: win - os: macos-13 @@ -71,13 +71,13 @@ jobs: echo 'add_subdirectory(binder)' > python/llvm-project/clang-tools-extra/CMakeLists.txt cp -r source python/llvm-project/clang-tools-extra/binder - - name: Setup cibuildwheel and build wheels - run: | - pipx install cibuildwheel - pipx run cibuildwheel python + - name: Build wheels + uses: pypa/cibuildwheel@v2.23.3 env: CIBW_BUILD: cp313-${{ matrix.impl }}* CIBW_ARCHS: ${{ matrix.archs }} + with: + package-dir: python - name: Upload wheels to artifacts uses: actions/upload-artifact@v4 diff --git a/python/pyproject.toml b/python/pyproject.toml index 5eabf49e..0892bb46 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -62,11 +62,11 @@ build = "cp313-*" build-verbosity = 1 test-requires = ["pytest"] test-command = "pytest {package}/tests" -musllinux-x86_64-image = "musllinux_1_1" -musllinux-i686-image = "musllinux_1_1" -musllinux-aarch64-image = "musllinux_1_1" -musllinux-ppc64le-image = "musllinux_1_1" -musllinux-s390x-image = "musllinux_1_1" +musllinux-x86_64-image = "quay.io/pypa/musllinux_1_1_x86_64:latest" +musllinux-i686-image = "quay.io/pypa/musllinux_1_1_i686:latest" +musllinux-aarch64-image = "quay.io/pypa/musllinux_1_1_aarch64:latest" +musllinux-ppc64le-image = "quay.io/pypa/musllinux_1_1_ppc64le:latest" +musllinux-s390x-image = "quay.io/pypa/musllinux_1_1_s390x:latest" [tool.cibuildwheel.macos] archs = ["universal2"]