From caa259cd6f449e9fd076f4e1d1abc197116ed149 Mon Sep 17 00:00:00 2001 From: Ryan Mast Date: Fri, 24 Jan 2025 12:52:57 -0800 Subject: [PATCH] Switch to using cibuildwheel for builds --- .github/free-disk-space.sh | 51 ---- .github/script-to-build-aarch64.sh | 19 -- .github/script-to-build-alpine.sh | 20 -- .github/script-to-build-manylinux2010.sh | 20 -- .github/workflows/build.yml | 253 ++++++++++++++++++ .github/workflows/libclang-alpine-amd64.yml | 73 ----- .github/workflows/libclang-linux-aarch64.yml | 123 --------- .github/workflows/libclang-linux-amd64.yml | 109 -------- .github/workflows/libclang-linux-arm.yml | 123 --------- .github/workflows/libclang-macosx-amd64.yml | 94 ------- .github/workflows/libclang-macosx-arm64.yml | 97 ------- .../workflows/libclang-windows-aarch64.yml | 106 -------- .github/workflows/libclang-windows-amd64.yml | 82 ------ CMakeLists.txt | 152 +++++++++++ README.md | 2 +- force_glibc_2_17.h | 25 -- llvm_version.cmake | 1 + native/.gitignore | 2 - pyproject.toml | 86 ++++++ python/clang/cindex.py | 2 +- python/clang/native/.gitignore | 4 - setup.cfg | 10 - setup.py | 60 ----- setup_ext.py | 109 -------- 24 files changed, 494 insertions(+), 1129 deletions(-) delete mode 100755 .github/free-disk-space.sh delete mode 100755 .github/script-to-build-aarch64.sh delete mode 100755 .github/script-to-build-alpine.sh delete mode 100755 .github/script-to-build-manylinux2010.sh create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/libclang-alpine-amd64.yml delete mode 100644 .github/workflows/libclang-linux-aarch64.yml delete mode 100644 .github/workflows/libclang-linux-amd64.yml delete mode 100644 .github/workflows/libclang-linux-arm.yml delete mode 100644 .github/workflows/libclang-macosx-amd64.yml delete mode 100644 .github/workflows/libclang-macosx-arm64.yml delete mode 100644 .github/workflows/libclang-windows-aarch64.yml delete mode 100644 .github/workflows/libclang-windows-amd64.yml create mode 100644 CMakeLists.txt delete mode 100644 force_glibc_2_17.h create mode 100644 llvm_version.cmake delete mode 100644 native/.gitignore create mode 100644 pyproject.toml delete mode 100644 python/clang/native/.gitignore delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 setup_ext.py diff --git a/.github/free-disk-space.sh b/.github/free-disk-space.sh deleted file mode 100755 index 52d311d..0000000 --- a/.github/free-disk-space.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# -# The Azure provided machines typically have the following disk allocation: -# Total space: 85GB -# Allocated: 67 GB -# Free: 17 GB -# This script frees up 28 GB of disk space by deleting unneeded packages and -# large directories. -# The Flink end to end tests download and generate more than 17 GB of files, -# causing unpredictable behavior and build failures. -# -echo "==============================================================================" -echo "Freeing up disk space on CI system" -echo "==============================================================================" - -echo "Listing 100 largest packages" -dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100 -df -h -echo "Removing large packages" -sudo apt-get remove -y '^ghc-8.*' -sudo apt-get remove -y '^dotnet-.*' -sudo apt-get remove -y '^llvm-.*' -sudo apt-get remove -y 'php.*' -sudo apt-get remove -y azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel -sudo apt-get autoremove -y -sudo apt-get clean -df -h -echo "Removing large directories" -# deleting 15GB -rm -rf /usr/share/dotnet/ -sudo rm -rf /usr/share/dotnet -sudo rm -rf /usr/local/lib/android -sudo rm -rf /opt/ghc -sudo rm -rf /opt/hostedtoolcache/CodeQL -df -h diff --git a/.github/script-to-build-aarch64.sh b/.github/script-to-build-aarch64.sh deleted file mode 100755 index 9fe1d36..0000000 --- a/.github/script-to-build-aarch64.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -x - -sudo docker run --privileged --network=host --rm -v `pwd`:/work quay.io/pypa/manylinux2014_aarch64:latest \ - sh -c 'mkdir -p /work/build && \ - cd /work/build && \ - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_TARGETS_TO_BUILD=AArch64 \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" && \ - make libclang -j$(nproc) && \ - aarch64-linux-gnu-strip lib/libclang.so' -sudo chmod -R a+wr `pwd`/build diff --git a/.github/script-to-build-alpine.sh b/.github/script-to-build-alpine.sh deleted file mode 100755 index 4b8deea..0000000 --- a/.github/script-to-build-alpine.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -x - -sudo docker run --privileged --network=host --rm -v `pwd`:/work frolvlad/alpine-gxx \ - sh -c 'apk add python3 cmake make && \ - mkdir -p /work/build && \ - cd /work/build && \ - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_TARGETS_TO_BUILD=X86 \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" && \ - make libclang -j$(nproc) && \ - strip lib/libclang.so' -sudo chmod -R a+wr `pwd`/build diff --git a/.github/script-to-build-manylinux2010.sh b/.github/script-to-build-manylinux2010.sh deleted file mode 100755 index 0331ff2..0000000 --- a/.github/script-to-build-manylinux2010.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -x - -sudo docker run --privileged --network=host --rm -v `pwd`:/work quay.io/pypa/manylinux2010_x86_64:latest \ - sh -c 'export PATH=$PATH:/opt/python/cp39-cp39/bin && \ - mkdir -p /work/build && \ - cd /work/build && \ - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_TARGETS_TO_BUILD=X86 \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" && \ - make libclang -j$(nproc) && \ - strip lib/libclang.so' -sudo chmod -R a+wr `pwd`/build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3919493 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,253 @@ +name: CI + +on: + workflow_dispatch: + inputs: + skip_qemu: + description: "Skip builds that require qemu (placeholder - not functional yet)" + type: boolean + required: false + default: false + pull_request: + push: + branches: + - main + tags: + - "*.*.*" + +concurrency: + group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + build_wheels: + name: Build ${{ matrix.build }}${{ matrix.arch }} wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + arch: "x86_64" + build: "manylinux_" + artifact_suffix: "manylinux_x86_64" + - os: ubuntu-latest + arch: "x86_64" + build: "musllinux_" + artifact_suffix: "musllinux_x86_64" + - os: ubuntu-latest + arch: "i686" + build: "manylinux_" + artifact_suffix: "manylinux_i686" + - os: ubuntu-latest + arch: "i686" + build: "musllinux_" + artifact_suffix: "musllinux_i686" + - os: ubuntu-24.04-arm + arch: "aarch64" + build: "manylinux_" + artifact_suffix: "manylinux_aarch64" + - os: ubuntu-24.04-arm + arch: "aarch64" + build: "musllinux_" + artifact_suffix: "musllinux_aarch64" + - os: ubuntu-24.04-arm + arch: "armv7l" + build: "manylinux_" + artifact_suffix: "manylinux_armv7l" + - os: ubuntu-24.04-arm + arch: "armv7l" + build: "musllinux_" + artifact_suffix: "musllinux_armv7l" + - os: ubuntu-latest + arch: "ppc64le" + build: "manylinux_" + artifact_suffix: "manylinux_ppc64le" + use_qemu: true + - os: ubuntu-latest + arch: "ppc64le" + build: "musllinux_" + artifact_suffix: "musllinux_ppc64le" + use_qemu: true + - os: ubuntu-latest + arch: "s390x" + build: "manylinux_" + artifact_suffix: "manylinux_s390x" + use_qemu: true + - os: ubuntu-latest + arch: "s390x" + build: "musllinux_" + artifact_suffix: "musllinux_s390x" + use_qemu: true + - os: windows-latest + arch: "AMD64" + artifact_suffix: "windows_x86_64" + - os: windows-latest + arch: "x86" + artifact_suffix: "windows_x86" + - os: windows-latest + arch: "ARM64" + artifact_suffix: "windows_arm64" + - os: macos-14 + arch: "x86_64" + artifact_suffix: "macos_x86_64" + - os: macos-14 + arch: "arm64" + artifact_suffix: "macos_arm64" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # ensure history is present for automatic versioning + + - name: Support long paths on Windows + if: runner.os == 'Windows' + run: git config --system core.longpaths true + + - name: Build tblgen for Windows ARM64 cross-compilation + if: runner.os == 'Windows' && matrix.arch == 'ARM64' + run: | + $env:LLVM_VER = (Get-Content .\llvm_version.cmake | Select-String 'set\(LLVM_VERSION (.*?)\)').Matches.Groups[1].Value.Trim() + git clone https://github.com/llvm/llvm-project.git llvm-project-$env:LLVM_VER -b llvmorg-$env:LLVM_VER --depth=1 + mkdir -p llvm-project-$env:LLVM_VER/build + cd llvm-project-$env:LLVM_VER/build + cmake ../llvm ` + -Thost=x64 ` + -DLLVM_ENABLE_PROJECTS=clang ` + -DBUILD_SHARED_LIBS=OFF ` + -DLLVM_ENABLE_ZLIB=OFF ` + -DLLVM_ENABLE_ZSTD=OFF ` + -DLLVM_ENABLE_TERMINFO=OFF ` + -DLLVM_TARGETS_TO_BUILD=X86 ` + -DCMAKE_BUILD_TYPE=Release ` + -DCMAKE_CXX_FLAGS="/MP" ` + -DLLVM_USE_CRT_MINSIZEREL="MT" + cmake --build . --config Release --target clang-tblgen + cmake --build . --config Release --target llvm-tblgen + cd Release + mkdir C:\llvm + cp bin\clang-tblgen.exe C:\llvm + cp bin\llvm-tblgen.exe C:\llvm + + - name: Set up msvc on Windows + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ runner.os == 'Windows' && matrix.arch != 'ARM64' && matrix.arch || 'amd64_arm64' }} + + # Note: need a newer version of QEMU to avoid failures that recently started happening + - name: Set up QEMU + if: runner.os == 'Linux' && matrix.use_qemu + uses: docker/setup-qemu-action@v3.3.0 + with: + image: tonistiigi/binfmt:qemu-v8.1.5 + + - name: Install ninja (macOS) + if: runner.os == 'macOS' + run: which ninja || brew install ninja + + - name: Install pipx (macOS) + if: runner.os == 'macOS' + run: which pipx || brew install pipx + + - name: Build wheels + uses: pypa/cibuildwheel@v2.22.0 + env: + CIBW_ARCHS: "${{ matrix.arch }}" + CIBW_BUILD: "cp39-${{ matrix.build || '' }}*" + + - uses: actions/upload-artifact@v4 + with: + name: artifact-${{matrix.artifact_suffix}} + path: ./wheelhouse/*.whl + + + - name: Print dependencies (Linux) + if: runner.os == 'Linux' + run: | + for wheel in ./wheelhouse/*.whl; do + echo "Analyzing $wheel" + unzip "$wheel" -d wheel_contents + if [ -f wheel_contents/clang/native/lib/libclang.so ]; then + du -csh wheel_contents/clang/native/lib/libclang.so || true + ldd wheel_contents/clang/native/lib/libclang.so || true + file wheel_contents/clang/native/lib/libclang.so || true + strings wheel_contents/clang/native/lib/libclang.so | grep GLIBC + nm --dynamic --undefined-only --with-symbol-versions wheel_contents/clang/native/lib/libclang.so || true + fi + rm -rf wheel_contents + done + + - name: Print dependencies (macOS) + if: runner.os == 'macOS' + run: | + for wheel in ./wheelhouse/*.whl; do + echo "Analyzing $wheel" + unzip "$wheel" -d wheel_contents + if [ -f wheel_contents/clang/native/lib/libclang.dylib ]; then + du -csh wheel_contents/clang/native/lib/libclang.dylib || true + file wheel_contents/clang/native/lib/libclang.dylib || true + otool -L wheel_contents/clang/native/lib/libclang.dylib || true + dyldinfo -platform -dependents libclang.dylib || true + lipo -info wheel_contents/clang/native/lib/libclang.dylib || true + fi + rm -rf wheel_contents + done + + - name: Print dependencies (Windows) + if: runner.os == 'Windows' + shell: bash + run: | + for wheel in ./wheelhouse/*.whl; do + echo "Analyzing $wheel" + 7z x -y "$wheel" -owheel_contents + if [ -f wheel_contents/clang/native/lib/libclang.dll ]; then + file wheel_contents/clang/native/lib/libclang.dll || true + fi + rm -rf wheel_contents + done + + build_sdist: + name: Build source distributions + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # ensure history is present for automatic versioning + + - name: Build SDist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: artifact-sdist + path: dist/*.tar.gz + + check_dist: + name: Check dist + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + - run: pipx run twine check --strict dist/* + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + needs: [build_wheels, build_sdist, check_dist] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + environment: + name: pypi + url: https://pypi.org/p/libclang + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Download Python package dist artifacts + uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/libclang-alpine-amd64.yml b/.github/workflows/libclang-alpine-amd64.yml deleted file mode 100644 index b91ebdf..0000000 --- a/.github/workflows/libclang-alpine-amd64.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: libclang-alpine-amd64 - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: free disk spaces - run: | - ./.github/free-disk-space.sh || true - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: get llvm-project - run: | - wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz - tar xf llvm-project-$LLVM_VER.src.tar.xz - mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER - - name: make build directory - run: mkdir -p llvm-project-$LLVM_VER/build - - name: pull docker - run: | - sudo docker pull frolvlad/alpine-gxx - - name: cmake & build in docker - run: | - cp .github/script-to-build-alpine.sh ./llvm-project-$LLVM_VER/ - cd llvm-project-$LLVM_VER - bash ./script-to-build-alpine.sh - - name: print dependencies - run: | - du -csh $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - file $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - - name: create and print sha512sum - run: | - cd llvm-project-$LLVM_VER/build/lib - sha512sum libclang.so > libclang.so.$LLVM_VER.alpine-amd64.sha512sum - echo "Checksum is: " - cat libclang.so.$LLVM_VER.alpine-amd64.sha512sum - tar zcvfh libclang.so.$LLVM_VER.alpine-amd64.tar.gz libclang.so libclang.so.$LLVM_VER.alpine-amd64.sha512sum - shasum -a512 libclang.so.$LLVM_VER.alpine-amd64.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.so.${{env.LLVM_VER}}.alpine-amd64.tar.gz - path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.so.${{env.LLVM_VER}}.alpine-amd64.tar.gz - - name: generate wheel package - run: | - cp llvm-project-$LLVM_VER/build/lib/libclang.so native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=musllinux_1_2_x86_64 - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-musllinux_1_2_x86_64 - path: dist/*.whl - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/.github/workflows/libclang-linux-aarch64.yml b/.github/workflows/libclang-linux-aarch64.yml deleted file mode 100644 index 59121d4..0000000 --- a/.github/workflows/libclang-linux-aarch64.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: libclang-linux-aarch64 - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: free disk spaces - run: | - ./.github/free-disk-space.sh || true - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: get llvm-project - run: | - wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz - tar xf llvm-project-$LLVM_VER.src.tar.xz - mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER - - name: install cross compilation toolchain - run: | - sudo apt-get update - sudo apt-get install -y \ - binutils-aarch64-linux-gnu \ - gcc-8 \ - g++-8 \ - gcc-8-aarch64-linux-gnu \ - g++-8-aarch64-linux-gnu - - name: build host llvmtblgen/clangtblgen - run: | - mkdir llvm-project-$LLVM_VER/build-host - cd llvm-project-$LLVM_VER/build-host - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_TARGETS_TO_BUILD=X86 \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \ - -DCMAKE_C_COMPILER=gcc-8 \ - -DCMAKE_CXX_COMPILER=g++-8 - make clang-tblgen llvm-tblgen -j$(nproc) - - # copy the artifacts to an absolute path - sudo cp ./bin/* /usr/bin/ - - name: make build directory - run: mkdir -p llvm-project-$LLVM_VER/build - - name: cmake - run: | - cd llvm-project-$LLVM_VER/build - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DCMAKE_SYSTEM_NAME=Linux \ - -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu \ - -DLLVM_TARGET_ARCH=AArch64 \ - -DLLVM_TARGETS_TO_BUILD=AArch64 \ - -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen \ - -DCLANG_TABLEGEN=/usr/bin/clang-tblgen \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \ - -DCMAKE_C_FLAGS="-include $(realpath ../../force_glibc_2_17.h)" \ - -DCMAKE_CXX_FLAGS="-include $(realpath ../../force_glibc_2_17.h)" \ - -DCMAKE_EXE_LINKER_FLAGS="-lm" \ - -DCMAKE_SHARED_LINKER_FLAGS="-lm" \ - -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc-8 \ - -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++-8 - - name: build - run: | - cd llvm-project-$LLVM_VER/build - make libclang -j$(nproc) - aarch64-linux-gnu-strip lib/libclang.so - - name: print dependencies - run: | - du -csh $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - file $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - strings llvm-project-$LLVM_VER/build/lib/libclang.so | grep GLIBC - nm --dynamic --undefined-only --with-symbol-versions llvm-project-$LLVM_VER/build/lib/libclang.so - - name: create and print sha512sum - run: | - cd llvm-project-$LLVM_VER/build/lib - sha512sum libclang.so > libclang.so.$LLVM_VER.linux-aarch64.sha512sum - echo "Checksum is: " - cat libclang.so.$LLVM_VER.linux-aarch64.sha512sum - tar zcvfh libclang.so.$LLVM_VER.linux-aarch64.tar.gz libclang.so libclang.so.$LLVM_VER.linux-aarch64.sha512sum - shasum -a512 libclang.so.$LLVM_VER.linux-aarch64.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.so.${{env.LLVM_VER}}.linux-aarch64.tar.gz - path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.so.${{env.LLVM_VER}}.linux-aarch64.tar.gz - - name: generate wheel package - run: | - cp llvm-project-$LLVM_VER/build/lib/libclang.so native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=manylinux2014_aarch64 - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-manylinux2014_aarch64 - path: dist/*.whl - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/.github/workflows/libclang-linux-amd64.yml b/.github/workflows/libclang-linux-amd64.yml deleted file mode 100644 index c05998c..0000000 --- a/.github/workflows/libclang-linux-amd64.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: libclang-linux-amd64 - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: free disk spaces - run: | - ./.github/free-disk-space.sh || true - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: get llvm-project - run: | - wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz - tar xf llvm-project-$LLVM_VER.src.tar.xz - mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER - - name: make build directory - run: mkdir -p llvm-project-$LLVM_VER/build - - name: pull docker - run: | - sudo docker pull quay.io/pypa/manylinux2010_x86_64:latest - - name: cmake & build in docker - run: | - cp .github/script-to-build-manylinux2010.sh ./llvm-project-$LLVM_VER/ - cd llvm-project-$LLVM_VER - bash ./script-to-build-manylinux2010.sh - - name: print dependencies - run: | - du -csh $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - file $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - ldd llvm-project-$LLVM_VER/build/lib/libclang.so - strings llvm-project-$LLVM_VER/build/lib/libclang.so | grep GLIBC - nm --dynamic --undefined-only --with-symbol-versions llvm-project-$LLVM_VER/build/lib/libclang.so - - name: create and print sha512sum - run: | - cd llvm-project-$LLVM_VER/build/lib - sha512sum libclang.so > libclang.so.$LLVM_VER.linux-amd64.sha512sum - echo "Checksum is: " - cat libclang.so.$LLVM_VER.linux-amd64.sha512sum - tar zcvfh libclang.so.$LLVM_VER.linux-amd64.tar.gz libclang.so libclang.so.$LLVM_VER.linux-amd64.sha512sum - shasum -a512 libclang.so.$LLVM_VER.linux-amd64.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.so.${{env.LLVM_VER}}.linux-amd64.tar.gz - path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.so.${{env.LLVM_VER}}.linux-amd64.tar.gz - - name: generate wheel package - run: | - cp llvm-project-$LLVM_VER/build/lib/libclang.so native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=manylinux2010_x86_64 - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-manylinux2010_x86_64 - path: dist/*.whl - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true - - build-and-deploy-sdist: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: ubuntu-latest - needs: [build-and-deploy] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: get llvm-project - run: | - wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz - tar xf llvm-project-$LLVM_VER.src.tar.xz - mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER - - name: generate wheel package - run: | - python3 setup.py sdist - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-sdist - path: dist/*.tar.gz - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/.github/workflows/libclang-linux-arm.yml b/.github/workflows/libclang-linux-arm.yml deleted file mode 100644 index 5af8216..0000000 --- a/.github/workflows/libclang-linux-arm.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: libclang-linux-arm - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: free disk spaces - run: | - ./.github/free-disk-space.sh || true - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: get llvm-project - run: | - wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz - tar xf llvm-project-$LLVM_VER.src.tar.xz - mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER - - name: install cross compilation toolchain - run: | - sudo apt-get update - sudo apt-get install -y \ - binutils-arm-linux-gnueabihf \ - gcc-8 \ - g++-8 \ - gcc-8-arm-linux-gnueabihf \ - g++-8-arm-linux-gnueabihf - - name: build host llvmtblgen/clangtblgen - run: | - mkdir llvm-project-$LLVM_VER/build-host - cd llvm-project-$LLVM_VER/build-host - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_TARGETS_TO_BUILD=X86 \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \ - -DCMAKE_C_COMPILER=gcc-8 \ - -DCMAKE_CXX_COMPILER=g++-8 - make clang-tblgen llvm-tblgen -j$(nproc) - - # copy the artifacts to an absolute path - sudo cp ./bin/* /usr/bin/ - - name: make build directory - run: mkdir -p llvm-project-$LLVM_VER/build - - name: cmake - run: | - cd llvm-project-$LLVM_VER/build - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DCMAKE_SYSTEM_NAME=Linux \ - -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf \ - -DLLVM_TARGET_ARCH=ARM \ - -DLLVM_TARGETS_TO_BUILD=ARM \ - -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen \ - -DCLANG_TABLEGEN=/usr/bin/clang-tblgen \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \ - -DCMAKE_C_FLAGS="-march=armv7 -include $(realpath ../../force_glibc_2_17.h)" \ - -DCMAKE_CXX_FLAGS="-march=armv7 -include $(realpath ../../force_glibc_2_17.h)" \ - -DCMAKE_EXE_LINKER_FLAGS="-lm" \ - -DCMAKE_SHARED_LINKER_FLAGS="-lm" \ - -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc-8 \ - -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++-8 - - name: build - run: | - cd llvm-project-$LLVM_VER/build - make libclang -j$(nproc) - arm-linux-gnueabihf-strip lib/libclang.so - - name: print dependencies - run: | - du -csh $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - file $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so) - strings llvm-project-$LLVM_VER/build/lib/libclang.so | grep GLIBC - nm --dynamic --undefined-only --with-symbol-versions llvm-project-$LLVM_VER/build/lib/libclang.so - - name: create and print sha512sum - run: | - cd llvm-project-$LLVM_VER/build/lib - sha512sum libclang.so > libclang.so.$LLVM_VER.linux-arm.sha512sum - echo "Checksum is: " - cat libclang.so.$LLVM_VER.linux-arm.sha512sum - tar zcvfh libclang.so.$LLVM_VER.linux-arm.tar.gz libclang.so libclang.so.$LLVM_VER.linux-arm.sha512sum - shasum -a512 libclang.so.$LLVM_VER.linux-arm.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.so.${{env.LLVM_VER}}.linux-arm.tar.gz - path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.so.${{env.LLVM_VER}}.linux-arm.tar.gz - - name: generate wheel package - run: | - cp llvm-project-$LLVM_VER/build/lib/libclang.so native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=manylinux2014_armv7l - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-manylinux2014_armv7l - path: dist/*.whl - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/.github/workflows/libclang-macosx-amd64.yml b/.github/workflows/libclang-macosx-amd64.yml deleted file mode 100644 index 1485c8a..0000000 --- a/.github/workflows/libclang-macosx-amd64.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: libclang-macosx-amd64 - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - MACOSX_DEPLOYMENT_TARGET: "10.9" - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: macos-11 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: install gnu-tar - run: | - brew install gnu-tar - - name: get llvm-project - run: | - wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz - tar xf llvm-project-$LLVM_VER.src.tar.xz - mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER - - name: make build directory - run: mkdir -p llvm-project-$LLVM_VER/build - - name: cmake - run: | - cd llvm-project-$LLVM_VER/build - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_TARGETS_TO_BUILD=X86 \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \ - -DCMAKE_C_COMPILER=gcc-10 \ - -DCMAKE_CXX_COMPILER=g++-10 \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET - - name: build - run: cd llvm-project-$LLVM_VER/build && make libclang -j$(sysctl -n hw.ncpu) - - name: print dependencies - run: | - du -csh llvm-project-$LLVM_VER/build/lib/libclang.dylib - file llvm-project-$LLVM_VER/build/lib/libclang.dylib - otool -L llvm-project-$LLVM_VER/build/lib/libclang.dylib - dyldinfo -platform -dependents libclang.dylib || true - - name: create and print sha512sum - run: | - cd llvm-project-$LLVM_VER/build/lib - shasum -a512 libclang.dylib > libclang.dylib.$LLVM_VER.macosx-amd64.sha512sum - echo "Checksum is: " - cat libclang.dylib.$LLVM_VER.macosx-amd64.sha512sum - gtar zcvf libclang.dylib.$LLVM_VER.macosx-amd64.tar.gz libclang.dylib libclang.dylib.$LLVM_VER.macosx-amd64.sha512sum - shasum -a512 libclang.dylib.$LLVM_VER.macosx-amd64.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.dylib.${{env.LLVM_VER}}.macosx-amd64.tar.gz - path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.dylib.${{env.LLVM_VER}}.macosx-amd64.tar.gz - - name: generate wheel package - run: | - cp llvm-project-$LLVM_VER/build/lib/libclang.dylib native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=macosx_10_9_x86_64 - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-macosx_10_9_x86_64 - path: dist/*.whl - - upload-to-pypi: - runs-on: ubuntu-latest - needs: [build-and-deploy] - steps: - - uses: actions/download-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-macosx_10_9_x86_64 - path: dist/ - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/.github/workflows/libclang-macosx-arm64.yml b/.github/workflows/libclang-macosx-arm64.yml deleted file mode 100644 index be791ff..0000000 --- a/.github/workflows/libclang-macosx-arm64.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: libclang-macosx-arm64 - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - MACOSX_DEPLOYMENT_TARGET: "10.15" - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: install gnu-tar - run: | - brew install gnu-tar - - name: install gcc@11 - run: | - brew install gcc@11 - - name: get llvm-project - run: | - wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz - tar xf llvm-project-$LLVM_VER.src.tar.xz - mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER - - name: make build directory - run: mkdir -p llvm-project-$LLVM_VER/build - - name: cmake - run: | - cd llvm-project-$LLVM_VER/build - cmake ../llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_TARGETS_TO_BUILD=AArch64 \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \ - -DCMAKE_C_COMPILER=$(brew --prefix gcc@11)/bin/gcc-11 \ - -DCMAKE_CXX_COMPILER=$(brew --prefix gcc@11)/bin/g++-11 \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET - - name: build - run: cd llvm-project-$LLVM_VER/build && make libclang -j$(sysctl -n hw.ncpu) - - name: print dependencies - run: | - du -csh llvm-project-$LLVM_VER/build/lib/libclang.dylib - file llvm-project-$LLVM_VER/build/lib/libclang.dylib - otool -L llvm-project-$LLVM_VER/build/lib/libclang.dylib - dyldinfo -platform -dependents libclang.dylib || true - - name: create and print sha512sum - run: | - cd llvm-project-$LLVM_VER/build/lib - shasum -a512 libclang.dylib > libclang.dylib.$LLVM_VER.macosx-arm64.sha512sum - echo "Checksum is: " - cat libclang.dylib.$LLVM_VER.macosx-arm64.sha512sum - gtar zcvf libclang.dylib.$LLVM_VER.macosx-arm64.tar.gz libclang.dylib libclang.dylib.$LLVM_VER.macosx-arm64.sha512sum - shasum -a512 libclang.dylib.$LLVM_VER.macosx-arm64.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.dylib.${{env.LLVM_VER}}.macosx-arm64.tar.gz - path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.dylib.${{env.LLVM_VER}}.macosx-arm64.tar.gz - - name: generate wheel package - run: | - cp llvm-project-$LLVM_VER/build/lib/libclang.dylib native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=macosx_11_0_arm64 - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-macosx_11_0_arm64 - path: dist/*.whl - - upload-to-pypi: - runs-on: ubuntu-latest - needs: [build-and-deploy] - steps: - - uses: actions/download-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-macosx_11_0_arm64 - path: dist/ - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/.github/workflows/libclang-windows-aarch64.yml b/.github/workflows/libclang-windows-aarch64.yml deleted file mode 100644 index 5f88239..0000000 --- a/.github/workflows/libclang-windows-aarch64.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: libclang-windows-aarch64 - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: get llvm-project - run: | - choco install wget git - git clone https://github.com/llvm/llvm-project.git llvm-project-$env:LLVM_VER -b llvmorg-$env:LLVM_VER --depth=1 - - name: build host llvm-tblgen/clang-tblgen - run: | - mkdir llvm-project-$env:LLVM_VER/build-host - cd llvm-project-$env:LLVM_VER/build-host - cmake ../llvm ` - -Thost=x64 ` - -DLLVM_ENABLE_PROJECTS=clang ` - -DBUILD_SHARED_LIBS=OFF ` - -DLLVM_ENABLE_ZLIB=OFF ` - -DLLVM_ENABLE_ZSTD=OFF ` - -DLLVM_ENABLE_TERMINFO=OFF ` - -DLLVM_TARGETS_TO_BUILD=X86 ` - -DCMAKE_BUILD_TYPE=RelWithDebInfo ` - -DCMAKE_CXX_FLAGS="/MP" ` - -DLLVM_USE_CRT_MINSIZEREL="MT" - cmake --build . --config RelWithDebInfo --target clang-tblgen - cmake --build . --config RelWithDebInfo --target llvm-tblgen - cd RelWithDebInfo - mkdir C:\llvm - cp bin\clang-tblgen.exe C:\llvm - cp bin\llvm-tblgen.exe C:\llvm - - name: cmake - run: | - mkdir -p llvm-project-$env:LLVM_VER/build - cd llvm-project-$env:LLVM_VER/build - cmake ../llvm ` - -A ARM64 ` - -Thost=x64 ` - -DCMAKE_SYSTEM_NAME=Windows ` - -DLLVM_ENABLE_PROJECTS=clang ` - -DBUILD_SHARED_LIBS=OFF ` - -DLLVM_ENABLE_ZLIB=OFF ` - -DLLVM_ENABLE_ZSTD=OFF ` - -DLLVM_ENABLE_TERMINFO=OFF ` - -DLLVM_TARGETS_TO_BUILD=AArch64 ` - -DLLVM_TABLEGEN=C:\llvm\llvm-tblgen.exe ` - -DCLANG_TABLEGEN=C:\llvm\clang-tblgen.exe ` - -DCMAKE_CXX_FLAGS="/MP" ` - -DLLVM_USE_CRT_MINSIZEREL="MT" - - name: build - run: cd llvm-project-$env:LLVM_VER/build && cmake --build . --config RelWithDebInfo --target libclang - - name: create and print sha512sum - run: | - $env:Path = "C:\Program Files\Git\usr\bin;$env:Path" - cd llvm-project-$env:LLVM_VER\build\RelWithDebInfo\bin - sha512sum.exe libclang.dll > libclang.dll.$env:LLVM_VER.windows-aarch64.sha512sum - echo "Checksum is: " - Get-Content -Path libclang.dll.$env:LLVM_VER.windows-aarch64.sha512sum - tar zcvf libclang.dll.$env:LLVM_VER.windows-aarch64.tar.gz libclang.dll libclang.dll.$env:LLVM_VER.windows-aarch64.sha512sum - sha512sum.exe libclang.dll.$env:LLVM_VER.windows-aarch64.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.dll.${{env.LLVM_VER}}.windows-aarch64.tar.gz - path: llvm-project-${{env.LLVM_VER}}\build\RelWithDebInfo\bin\libclang.dll.${{env.LLVM_VER}}.windows-aarch64.tar.gz - - name: generate wheel package - run: | - cp llvm-project-${{env.LLVM_VER}}\build\RelWithDebInfo\bin\libclang.dll native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=win_arm64 - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-win_arm64 - path: dist/*.whl - - upload-to-pypi: - runs-on: ubuntu-latest - needs: [build-and-deploy] - steps: - - uses: actions/download-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-win_arm64 - path: dist/ - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/.github/workflows/libclang-windows-amd64.yml b/.github/workflows/libclang-windows-amd64.yml deleted file mode 100644 index bbb484f..0000000 --- a/.github/workflows/libclang-windows-amd64.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: libclang-windows-amd64 - -on: [push, pull_request] - -env: - LLVM_VER: 18.1.1 - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - build-and-deploy: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: install wheel dependencies - run: | - pip3 install wheel - - name: get llvm-project - run: | - choco install wget git - git clone https://github.com/llvm/llvm-project.git llvm-project-$env:LLVM_VER -b llvmorg-$env:LLVM_VER --depth=1 - - name: make build directory - run: mkdir -p llvm-project-$env:LLVM_VER/build - - name: cmake - run: | - cd llvm-project-$env:LLVM_VER/build - cmake ../llvm ` - -Thost=x64 ` - -DLLVM_ENABLE_PROJECTS=clang ` - -DBUILD_SHARED_LIBS=OFF ` - -DLLVM_ENABLE_ZLIB=OFF ` - -DLLVM_ENABLE_ZSTD=OFF ` - -DLLVM_ENABLE_TERMINFO=OFF ` - -DLLVM_TARGETS_TO_BUILD=X86 ` - -DCMAKE_CXX_FLAGS="/MP" ` - -DLLVM_USE_CRT_MINSIZEREL="MT" - - name: build - run: cd llvm-project-$env:LLVM_VER/build && cmake --build . --config RelWithDebInfo --target libclang - - name: create and print sha512sum - run: | - $env:Path = "C:\Program Files\Git\usr\bin;$env:Path" - cd llvm-project-$env:LLVM_VER\build\RelWithDebInfo\bin - sha512sum.exe libclang.dll > libclang.dll.$env:LLVM_VER.windows-amd64.sha512sum - echo "Checksum is: " - Get-Content -Path libclang.dll.$env:LLVM_VER.windows-amd64.sha512sum - tar zcvf libclang.dll.$env:LLVM_VER.windows-amd64.tar.gz libclang.dll libclang.dll.$env:LLVM_VER.windows-amd64.sha512sum - sha512sum.exe libclang.dll.$env:LLVM_VER.windows-amd64.tar.gz - - uses: actions/upload-artifact@v4 - with: - name: libclang.dll.${{env.LLVM_VER}}.windows-amd64.tar.gz - path: llvm-project-${{env.LLVM_VER}}\build\RelWithDebInfo\bin\libclang.dll.${{env.LLVM_VER}}.windows-amd64.tar.gz - - name: generate wheel package - run: | - cp llvm-project-${{env.LLVM_VER}}\build\RelWithDebInfo\bin\libclang.dll native/ - python3 setup_ext.py bdist_wheel --universal --plat-name=win_amd64 - - uses: actions/upload-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-win_amd64 - path: dist/*.whl - - upload-to-pypi: - runs-on: ubuntu-latest - needs: [build-and-deploy] - steps: - - uses: actions/download-artifact@v4 - with: - name: wheel-${{env.LLVM_VER}}-win_amd64 - path: dist/ - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true - print_hash: true diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..26a145d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,152 @@ +cmake_minimum_required(VERSION 3.18...3.31) + +project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES C CXX) + +# Set a default build type if none was specified +# scikit-build-core defaults to setting this to release, but not sure if it will be empty for multi-config generators? +if(NOT CMAKE_BUILD_TYPE) #AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) + mark_as_advanced(CMAKE_BUILD_TYPE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +include(llvm_version.cmake) + +include(ExternalProject) + +# Should eventually update this to handle bundling in the LLVM source code for an SDIST + +set(_llvm_cache_args) +set(_llvm_build_flags) + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + message(STATUS "Setting LLVM target triple to arm-linux-gnueabihf for 32-bit ARM build") + list(APPEND _llvm_cache_args + -DLLVM_DEFAULT_TARGET_TRIPLE:STRING=arm-linux-gnueabihf + ) +endif() + +# Based on manylinux standards, may not actually be necessary to static link libgcc and libstdc++ +if(UNIX AND NOT APPLE) + # LLVM_STATIC_LINK_CXX_STDLIB is used to static link with -static-libstdc++ + # Which performs compile flag checks to make sure it is possible, so not handled here + include(CheckCXXCompilerFlag) + include(CheckLinkerFlag) + check_cxx_compiler_flag("-static-libgcc" CXX_COMPILER_SUPPORTS_STATIC_LIBGCC) + check_linker_flag(CXX "-static-libgcc" CXX_LINKER_SUPPORTS_STATIC_LIBGCC) + if(CXX_COMPILER_SUPPORTS_STATIC_LIBGCC AND CXX_LINKER_SUPPORTS_STATIC_LIBGCC) + message(STATUS "Setting Linux build flags for static linking libgcc") + string(JOIN " " _llvm_build_flags "-static-libgcc") + endif() +endif() + +if(APPLE) + message(STATUS "Setting macOS deployment target to ${MACOSX_DEPLOYMENT_TARGET}") + message(STATUS "Setting macOS architectures to ${CMAKE_OSX_ARCHITECTURES}") + list(APPEND _llvm_cache_args + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${MACOSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} + ) +endif() + +if(WIN32) + message(STATUS "Setting LLVM USE_CRT_MINSIZEREL to MT for Windows build") + list(APPEND _llvm_cache_args + -DLLVM_USE_CRT_MINSIZEREL:STRING="MT" + ) + if(LLVM_TABLEGEN) + message(STATUS "Setting LLVM tablegen path to ${LLVM_TABLEGEN}") + list(APPEND _llvm_cache_args + -DLLVM_TABLEGEN:FILEPATH=${LLVM_TABLEGEN} + ) + endif() + # LLVM_NATIVE_TOOL_DIR may be better than setting LLVM_TABLEGEN and CLANG_TABLEGEN separately (built with LLVM_OPTIMIZED_TABLEGEN?) + # Pre-built versions of the native tools for cross-compilation could be split into a separate project, as perhaps useful for others cross-compiling clang as well? + # LLVM_BUILD_TOOLS -- native tools for cross-compilation, such as llvm-as, etc? Maybe some useful tools that would be useful to have pre-compiled here as well? + if(CLANG_TABLEGEN) + message(STATUS "Setting clang tablegen path to ${CLANG_TABLEGEN}") + list(APPEND _llvm_cache_args + -DCLANG_TABLEGEN:FILEPATH=${CLANG_TABLEGEN} # TODO does this actually exist? + ) + endif() + if(MSVC) + message(STATUS "Setting LLVM build flags for parallel compilation on MSVC") + string(JOIN " " _llvm_build_flags "/MP") + endif() +endif() + +if(_llvm_build_flags) + message(STATUS "C/CXX build flags set to ${_llvm_build_flags}") + list(APPEND _llvm_cache_args + -DCMAKE_C_FLAGS:STRING=${_llvm_build_flags} + -DCMAKE_CXX_FLAGS:STRING=${_llvm_build_flags} + ) +endif() + +# LLVM_TARGETS_TO_BUILD -- set by CI workflows when cross-compiling, otherwise default to host +if(NOT DEFINED LLVM_TARGETS_TO_BUILD) + set(LLVM_TARGETS_TO_BUILD "host") +endif() +message(STATUS "Setting LLVM_TARGETS_TO_BUILD to ${LLVM_TARGETS_TO_BUILD}") + +# Setting CMAKE_SYSTEM_NAME in the cache causes CMake to set CMAKE_CROSSCOMPILING +# This is needed to prevent LLVM from trying to run certain cross-compiled tools like clang-ast-dump +# https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/clang/lib/Tooling/CMakeLists.txt#L63 (removed in LLVM v19) +if(DEFINED CACHE{CMAKE_SYSTEM_NAME}) + message(STATUS "Setting CMAKE_SYSTEM_NAME in the cache to ${CMAKE_SYSTEM_NAME} (cross-compiling)") + list(APPEND _llvm_cache_args + -DCMAKE_SYSTEM_NAME:STRING=${CMAKE_SYSTEM_NAME} + ) +endif() + +set(LLVM_SOURCE_DIR ${CMAKE_BINARY_DIR}/llvm-src) +set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR}/llvm-build) +ExternalProject_add(build-libclang + SOURCE_SUBDIR llvm + SOURCE_DIR ${LLVM_SOURCE_DIR} + BINARY_DIR ${LLVM_BINARY_DIR} + URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/llvm-project-${LLVM_VERSION}.src.tar.xz" + CMAKE_CACHE_ARGS + -DBUILD_TESTING:BOOL=OFF + -DLLVM_ENABLE_PROJECTS:STRING=clang + -DBUILD_SHARED_LIBS:BOOL=OFF + -DLLVM_BUILD_TOOLS:BOOL=OFF + -DLLVM_ENABLE_ZLIB:BOOL=OFF + -DLLVM_ENABLE_ZSTD:BOOL=OFF + -DLLVM_ENABLE_TERMINFO:BOOL=OFF + -DLLVM_TARGETS_TO_BUILD:STRING=${LLVM_TARGETS_TO_BUILD} + -DLLVM_STATIC_LINK_CXX_STDLIB:BOOL=ON + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + ${_llvm_cache_args} + UPDATE_COMMAND "" + INSTALL_COMMAND "" + # Specify target to build as libclang + BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel --target libclang --config ${CMAKE_BUILD_TYPE} +) + +# The install line below can install libclang shared library in a cross-platform way +# Unfortunately the LLVM CMake build system doesn't respect CMAKE_INSTALL_LIBDIR/CMAKE_INSTALL_BINDIR +# hopefully a future version of LLVM will fix this +# install(SCRIPT ${LLVM_BINARY_DIR}/tools/clang/tools/libclang/cmake_install.cmake COMPONENT libclang) + +if(WIN32) + set(libclang-library ${LLVM_BINARY_DIR}/bin/libclang${CMAKE_SHARED_LIBRARY_SUFFIX}) +elseif(APPLE) + set(libclang-library ${LLVM_BINARY_DIR}/lib/libclang${CMAKE_SHARED_LIBRARY_SUFFIX}) +else() + # On Linux (and probably other BSD systems?) the shared library is named libclang.so. + # The libclang.so file is just a symlink to the actual shared library + set(libclang-library ${LLVM_BINARY_DIR}/lib/libclang${CMAKE_SHARED_LIBRARY_SUFFIX}.${LLVM_VERSION}) +endif() + +install( + PROGRAMS + ${libclang-library} + DESTINATION lib + RENAME libclang${CMAKE_SHARED_LIBRARY_SUFFIX} +) \ No newline at end of file diff --git a/README.md b/README.md index e1997e0..cc549c4 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Internals Update class variable `library_path` of `Config` in `cindex.py` as: ```python - library_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'native') + library_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'native', 'lib') ``` License diff --git a/force_glibc_2_17.h b/force_glibc_2_17.h deleted file mode 100644 index ed0045d..0000000 --- a/force_glibc_2_17.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __FORCE_GLIBC_2_17_H__ -#define __FORCE_GLIBC_2_17_H__ - -#if defined(__x86_64__) && __x86_64__ -__asm__(".symver exp,exp@GLIBC_2.2.5"); -__asm__(".symver pow,pow@GLIBC_2.2.5"); -__asm__(".symver log,log@GLIBC_2.2.5"); -__asm__(".symver log2,log2@GLIBC_2.2.5"); -#endif - -#if defined(__aarch64__) && __aarch64__ -__asm__(".symver exp,exp@GLIBC_2.17"); -__asm__(".symver pow,pow@GLIBC_2.17"); -__asm__(".symver log,log@GLIBC_2.17"); -__asm__(".symver log2,log2@GLIBC_2.17"); -#endif - -#if defined(__arm__) && __arm__ -__asm__(".symver exp,exp@GLIBC_2.4"); -__asm__(".symver pow,pow@GLIBC_2.4"); -__asm__(".symver log,log@GLIBC_2.4"); -__asm__(".symver log2,log2@GLIBC_2.4"); -#endif - -#endif // __FORCE_GLIBC_2_17_H__ diff --git a/llvm_version.cmake b/llvm_version.cmake new file mode 100644 index 0000000..44866bb --- /dev/null +++ b/llvm_version.cmake @@ -0,0 +1 @@ +set(LLVM_VERSION 18.1.1) \ No newline at end of file diff --git a/native/.gitignore b/native/.gitignore deleted file mode 100644 index 11b4bb1..0000000 --- a/native/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/* -!/.gitignore \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..acced72 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,86 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "libclang" +dynamic = ["version"] +description = "Clang Python Bindings, mirrored from the official LLVM repo: https://github.com/llvm/llvm-project/tree/main/clang/bindings/python, to make the installation process easier." +readme = "README.md" +readme-content-type = "text/markdown" +authors = [ + { name = "Tao He", email = "sighingnow@gmail.com" } +] +license = { text = "Apache License 2.0" } +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Compilers", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "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 :: Apache Software License" +] +keywords = ["Clang", "Python", "Bindings"] +dependencies = [] + +[project.urls] +Homepage = "https://github.com/sighingnow/libclang" +Documentation = "https://libclang.readthedocs.io" +"Source Code" = "https://github.com/sighingnow/libclang" +"Issue Tracker" = "https://github.com/sighingnow/libclang/issues" + +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +regex = '^set\(LLVM_VERSION\s+(?P\d+\.\d+\.\d+)\)' +input = "llvm_version.cmake" + +[tool.scikit-build] +wheel.packages = ["python/clang"] +wheel.install-dir = "clang/native" +wheel.py-api = "py2.py3" +# ensure that only libclang shared library gets installed +# install.components = ["libclang"] +cmake.version = ">=3.18.0" +ninja.version = ">=1.10.0" +# armv7l Linux images don't have a version of ninja that gets found? +ninja.make-fallback = false +cmake.build-type = "Release" +# scikit-build-core sets install.strip to true for Release builds +install.strip = true +build.verbose = true +logging.level = "DEBUG" + +[tool.cibuildwheel] +test-command = [ + "python -c 'from clang.cindex import conf; conf.lib; print(conf.get_filename()); print(conf.loaded)'", +] +build-verbosity = 3 +# Use Ninja on all platforms (Windows uses MSVC by default) +environment.CMAKE_GENERATOR = "Ninja" +environment.PIP_ONLY_BINARY = ":all:" + +[tool.cibuildwheel.linux] +manylinux-x86_64-image = "manylinux2010" +manylinux-i686-image = "manylinux2010" + +[[tool.cibuildwheel.overrides]] +select = "*-win_arm64" +config-settings."cmake.define.LLVM_TABLEGEN" = "C:/llvm/llvm-tblgen.exe" +config-settings."cmake.define.CLANG_TABLEGEN" = "C:/llvm/clang-tblgen.exe" +config-settings."cmake.define.LLVM_TARGETS_TO_BUILD" = "AArch64" +config-settings."cmake.define.CMAKE_SYSTEM_NAME" = "Windows" \ No newline at end of file diff --git a/python/clang/cindex.py b/python/clang/cindex.py index 66eeac8..04b9b18 100644 --- a/python/clang/cindex.py +++ b/python/clang/cindex.py @@ -3960,7 +3960,7 @@ def register(item): class Config: - library_path = os.environ.get("LIBCLANG_LIBRARY_PATH", os.path.join(os.path.dirname(os.path.realpath(__file__)), "native")) + library_path = os.environ.get("LIBCLANG_LIBRARY_PATH", os.path.join(os.path.dirname(os.path.realpath(__file__)), "native", "lib")) library_file = None compatibility_check = True loaded = False diff --git a/python/clang/native/.gitignore b/python/clang/native/.gitignore deleted file mode 100644 index a397256..0000000 --- a/python/clang/native/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.dylib -*.so -*.dll -*.lib diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index fd7e7b9..0000000 --- a/setup.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[bdist_wheel] -universal = 1 - -[build_sphinx] -source-dir = docs -build-dir = build -all_files = 1 - -[upload_docs] -upload-dir = build/html diff --git a/setup.py b/setup.py deleted file mode 100644 index 77b6fb0..0000000 --- a/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -from setuptools import setup, find_packages - - -with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md'), encoding='utf-8', mode='r') as fp: - long_description = fp.read() - -setup( - name='libclang', - version='18.1.1', - description='Clang Python Bindings, mirrored from the official LLVM repo: https://github.com/llvm/llvm-project/tree/main/clang/bindings/python, to make the installation process easier.', - long_description=long_description, - long_description_content_type='text/markdown', - author='Tao He', - author_email='sighingnow@gmail.com', - url='https://github.com/sighingnow/libclang', - license='Apache License 2.0', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - "Topic :: Software Development :: Compilers", - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - '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 :: Apache Software License", - ], - platforms='any', - keywords='Clang Python Bindings', - - - zip_safe=False, - - package_dir={'': 'python'}, - packages=find_packages('python'), - - test_suite='python/tests', - - project_urls={ - 'Documentation': 'https://libclang.readthedocs.io', - 'Source': 'https://github.com/sighingnow/libclang', - 'Tracker': 'https://github.com/sighingnow/libclang/issues', - }, -) diff --git a/setup_ext.py b/setup_ext.py deleted file mode 100644 index 8831a0f..0000000 --- a/setup_ext.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os - -from distutils.command.build import build -from distutils.dir_util import mkpath -from setuptools import setup, find_packages, Extension -from setuptools.command.build_ext import build_ext -from wheel.bdist_wheel import get_platform, bdist_wheel - - -def platform_ext(plat): - if 'linux' in plat: - return '.so' - if 'macosx' in plat: - return '.dylib' - if 'win' in plat: - return '.dll' - raise RuntimeError('Invalid platform value: %s' % plat) - - -platform = get_platform(None) - - -class bdist_wheel_injected(bdist_wheel): - def finalize_options(self): - super(bdist_wheel_injected, self).finalize_options() - self.root_is_pure = True - - def run(self): - global platform - platform = self.plat_name - super(bdist_wheel_injected, self).run() - - -class CopyNativeExtension(Extension): - def __init__(self, name): - super(CopyNativeExtension, self).__init__(name, sources=[]) - - -class CopyNativeCommand(build_ext): - def run(self): - for ext in self.extensions: - source_dir = './native/' - target_dir = os.path.dirname(self.get_ext_fullpath(ext.name)) - libname = 'libclang' + platform_ext(platform) - mkpath(target_dir) - self.copy_file(os.path.join(source_dir, libname), - os.path.join(target_dir, libname)) - -with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md'), encoding='utf-8', mode='r') as fp: - long_description = fp.read() - -setup( - name='libclang', - version='18.1.1', - description='Clang Python Bindings, mirrored from the official LLVM repo: https://github.com/llvm/llvm-project/tree/main/clang/bindings/python, to make the installation process easier.', - long_description=long_description, - long_description_content_type='text/markdown', - author='Tao He', - author_email='sighingnow@gmail.com', - url='https://github.com/sighingnow/libclang', - license='Apache License 2.0', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - "Topic :: Software Development :: Compilers", - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - '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 :: Apache Software License", - ], - platforms='any', - keywords='Clang Python Bindings', - - ext_modules=[CopyNativeExtension('clang.native.clang')], - cmdclass={ - 'build_ext': CopyNativeCommand, - 'bdist_wheel': bdist_wheel_injected, - }, - - zip_safe=False, - - package_dir={'': 'python'}, - packages=find_packages('python'), - - test_suite='python/tests', - - project_urls={ - 'Documentation': 'https://libclang.readthedocs.io', - 'Source': 'https://github.com/sighingnow/libclang', - 'Tracker': 'https://github.com/sighingnow/libclang/issues', - }, -)