Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
46 changes: 46 additions & 0 deletions .github/workflows/llvm-update-autocheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Auto-update LLVM Version
on:
workflow_dispatch:
schedule:
- cron: '0 10 * * 1'
jobs:
update-dep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check and update LLVM version
id: check-llvm
run: |
old_version="$(grep -Po '(?<=LLVM_VERSION )\d+(\.\d+)+' llvm_version.cmake)"
echo "Old version: $old_version"
echo "old_version=$old_version" >> $GITHUB_OUTPUT

new_version=$(git -c 'versionsort.suffix=-' \
ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/llvm/llvm-project 'llvmorg-*.*.*'\
| grep -Po '\d+\.\d+(\.\d+)?$' \
| tail --lines=1)

echo "New version: $new_version"
echo "new_version=$new_version" >> $GITHUB_OUTPUT

if [ "$old_version" != "$new_version" ]; then
echo "set(LLVM_VERSION $new_version)" > llvm_version.cmake
curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-${new_version}/clang-${new_version}.src.tar.xz -o clang-${new_version}.src.tar.xz
hash=$(sha256sum clang-${new_version}.src.tar.xz | cut -d ' ' -f1)
echo "set(LLVM_SHA256 $hash)" >> llvm_version.cmake
echo "LLVM version updated"
else
echo "No change in LLVM version"
fi

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update LLVM to version ${{ steps.check-llvm.outputs.new_version }}
title: Update LLVM version (${{ steps.check-llvm.outputs.new_version }})
body: |
- Update LLVM version to ${{ steps.check-llvm.outputs.new_version }}
Auto-generated by ${{ github.server_url }}/${{ github.repository }}/runs/${{ github.job }}?check_suite_focus=true
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
branch: llvm-version-update/${{ steps.check-llvm.outputs.new_version }}
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Release on PyPI

on:
workflow_dispatch:
push:
tags:
- v*

jobs:
build-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Build wheel
run: |
pip install build twine
python -m build
python -m twine check dist/*
- name: Upload Python package dist artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-dist
path: dist

pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: build-release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
environment:
name: pypi
url: https://pypi.org/p/clang
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:
name: python-package-dist
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.15)
project(clang NONE)

include(ExternalProject)

include(llvm_version.cmake)

# Set the URL and local paths
set(CLANG_TARBALL_URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang-${LLVM_VERSION}.src.tar.xz")
set(CLANG_TARBALL "${CMAKE_BINARY_DIR}/clang-${LLVM_VERSION}.src.tar.xz")
set(CLANG_SOURCE_DIR "${CMAKE_BINARY_DIR}/clang-src")
set(PYTHON_BINDINGS_OUTPUT "${CLANG_SOURCE_DIR}/bindings/python/clang/")

# Download the tarball using ExternalProject_Add
ExternalProject_Add(clang
URL ${CLANG_TARBALL_URL}
URL_HASH SHA256=${LLVM_SHA256}
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}
SOURCE_DIR ${CLANG_SOURCE_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD OFF
DOWNLOAD_EXTRACT_TIMESTAMP ON
)

# Define installation so that scikit-build packages the python files into the wheel
install(DIRECTORY ${PYTHON_BINDINGS_OUTPUT} DESTINATION clang USE_SOURCE_PERMISSIONS)
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
Clang Python ppackage for pypi
------------------------------
# Clang Python package for PyPI

This is the python bindings subdir of llvm clang repository.
https://github.com/llvm/llvm-project/tree/main/clang/bindings/python

The debian packages are pulled from llvm repo, extracted and pushed to pypi.

Installation
------------
## Installation

`pip install clang`
You can install the package using pip:

For a specific version
```bash
pip install clang
```

`pip install clang==14`
Or for a specific version:

```bash
pip install clang==14
```

## License

This project is licensed under the Apache-2.0 License with LLVM exception. See the LICENSE file for more details.
2 changes: 2 additions & 0 deletions llvm_version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(LLVM_VERSION 18.1.8)
set(LLVM_SHA256 5724fe0a13087d5579104cedd2f8b3bc10a212fb79a0fcdac98f4880e19f4519)
118 changes: 0 additions & 118 deletions make-from-packages.py

This file was deleted.

14 changes: 0 additions & 14 deletions packages.lst

This file was deleted.

41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
name = "clang"
description = "libclang python bindings"
readme = "README.md"
license = { text = "Apache-2.0 with LLVM exception" }
authors = [
{ name = "LLVM team - pypi upload by Loic Jaquemet" }
]
keywords = ["llvm", "clang", "libclang"]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Development Status :: 5 - Production/Stable",
"Topic :: Software Development :: Compilers",
"Programming Language :: Python :: 3",
]
dynamic = ["version"]

[project.urls]
Homepage = "http://clang.llvm.org/"
Download = "http://llvm.org/releases/download.html"

[dependecy-groups]
dev = ["build", "twine"]

[tool.scikit-build]
wheel.py-api = "py3"
wheel.platlib = false
wheel.license-files = []

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "llvm_version.cmake"
regex = '''(?sx)
set\(\s*LLVM_VERSION\s+(?P<version>\d+(?:\.\d+)+)\s*\)
'''
result = "{version}"
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

35 changes: 0 additions & 35 deletions setup.py.tpl

This file was deleted.