Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup binder as a Python package and publish pre-built wheels to PyPI #303

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e11ff3e
Publish cppbinder as a Python package (#1)
haiiliin Jun 16, 2024
02efc6a
Fix release workflow: move built executable
haiiliin Jun 16, 2024
63f8c74
Set github token when downloading wheels
haiiliin Jun 16, 2024
f440855
Checkout the repository before download wheels
haiiliin Jun 16, 2024
bd74915
Manylinux wheels should be built with cibuildwheel
haiiliin Jun 16, 2024
a8620db
Use scikit-build-core and cibuildwheel to build the package (#2)
haiiliin Jun 17, 2024
90b75da
Rename build.py to build-binder.py to avoid conflicts
haiiliin Jun 17, 2024
b1e4f0d
Create dependabot.yml
haiiliin Jun 17, 2024
9c6464e
Update version getting function
haiiliin Jun 18, 2024
1b9e6a0
Support both Python 2 and Python 3 (#3)
haiiliin Jun 18, 2024
459ddde
Use scikit-build-core to write version to _version.py file
haiiliin Jun 18, 2024
fc0008a
Move the project to sub-directory python
haiiliin Jun 19, 2024
58fe1eb
Update documentation
haiiliin Jun 19, 2024
e0c8c40
Merge remote-tracking branch 'upstream/master'
haiiliin Jun 19, 2024
d4bfb90
Update wheels artifacts name
haiiliin Jun 19, 2024
a285a52
Skip some build on pull request
haiiliin Jun 19, 2024
f81fa9c
Update working directory
haiiliin Jun 19, 2024
a685a9a
Update README and LICENSE in pyproject.toml
haiiliin Jun 19, 2024
cacebb1
[skip ci] Update root directory for setuptools-scm
haiiliin Jun 19, 2024
ed28689
Update wheels.yml
haiiliin Jun 19, 2024
d83a3ac
Delete
haiiliin Jun 19, 2024
da8a9c7
Add
haiiliin Jun 19, 2024
355a879
Update wheels.yml
haiiliin Jun 19, 2024
534dc4e
Build the package in the root directory
haiiliin Jun 19, 2024
441c913
Delete README and LICENSE
haiiliin Jun 19, 2024
22e4431
Add README and LICENSE back to symbolic links
haiiliin Jun 19, 2024
b26f4fc
Update __init__.py
haiiliin Jun 20, 2024
70319d4
Update artifacts name
haiiliin Jun 20, 2024
f51a330
Update installation documentation
haiiliin Jun 20, 2024
68ecb1a
Update llvm-project
haiiliin Jun 21, 2024
9c348ce
Update version scheme to no-guess-dev
haiiliin Jun 23, 2024
0e6a79e
Add test to check binder and llvm versions
haiiliin Jun 23, 2024
aa1ec55
Do not check binder version
haiiliin Jun 23, 2024
a4e13b1
Build wheels on all archs
haiiliin Jul 10, 2024
bde1fe9
Revert: install binder to CMAKE_INSTALL_BINDIR
haiiliin Jul 10, 2024
9ba4039
Setup QEMU on linux when building wheels
haiiliin Jul 29, 2024
1e07666
Always upload wheels to release assets
haiiliin Jul 29, 2024
6ea8f96
Skip some archs
haiiliin Jul 29, 2024
79a13db
Build universal2 wheels on macos
haiiliin Jul 29, 2024
f2741d1
Do not build aarch64, ppc64le and s390x wheels
haiiliin Sep 3, 2024
aaca914
Wheels can be built manually
haiiliin Sep 3, 2024
dbd076d
Build the default wheels
haiiliin Sep 3, 2024
d0d9f7b
Update version configurations
haiiliin Sep 4, 2024
dbf1ec8
Use cp313 to build the wheels
haiiliin Oct 12, 2024
1b61466
Only build source distribution on release
haiiliin Oct 12, 2024
7bfbb06
Merge branch 'RosettaCommons:master' into master
haiiliin Oct 12, 2024
e731726
Test wheels on different platforms and archs (#4)
haiiliin Oct 12, 2024
61c1b6b
Update wheels.yml
haiiliin Oct 13, 2024
0b809de
Update .gitignore
haiiliin Oct 14, 2024
264c34d
Remove `__version__` in the root package
haiiliin Oct 14, 2024
5bcdf7d
Revert `CMAKE_CXX_FLAGS` changes (#6)
haiiliin Oct 14, 2024
b7ec5b5
Update install.rst
haiiliin Oct 14, 2024
42bff71
Do not include version file in source distribution
haiiliin Oct 20, 2024
a6c79a4
Do not generate version file
haiiliin Oct 20, 2024
3da932e
Build source distribution always
haiiliin Oct 21, 2024
9101aa7
Do not always upload wheels
haiiliin Oct 21, 2024
9a9ac91
Update wheels.yml
haiiliin Oct 21, 2024
8249e09
Do not upload wheels to release (#8)
haiiliin Oct 21, 2024
2b65ece
Clone the LLVM project on building phase (#7)
haiiliin Oct 21, 2024
c326299
[skip ci] Set `impl` for windows and macos wheels
haiiliin Oct 21, 2024
e207c5e
Delete .github/dependabot.yml
haiiliin Oct 21, 2024
332c486
Remove pybind11 build dependency
haiiliin Oct 27, 2024
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
140 changes: 140 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
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]
workflow_dispatch:

concurrency:
group: wheels-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-22.04
archs:
- "x86_64"
- "i686"
impl:
- "manylinux"
- "musllinux"
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
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup QEMU for Linux cross-compilation
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
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: |
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: cp313-${{ matrix.impl }}*
CIBW_ARCHS: ${{ matrix.archs }}

- name: Upload wheels to artifacts
uses: actions/upload-artifact@v4
with:
name: cppbinder-wheels-${{ matrix.os }}-${{ matrix.archs }}-${{ matrix.impl }}-${{ github.event_name == 'release' && github.ref_name || github.sha }}
path: ./wheelhouse/*.whl

build-sdist:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- 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: |
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: |
pipx install build
pipx run build --sdist --outdir dist
working-directory: python

- name: Upload source distribution to artifacts
uses: actions/upload-artifact@v4
with:
name: cppbinder-sdist-${{ github.event_name == 'release' && github.ref_name || github.sha }}
path: ./python/dist/*.tar.gz

publish:
needs: [build-wheels, build-sdist]
if: github.event_name == 'release'
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download wheels and source distribution
uses: actions/download-artifact@v4
with:
pattern: cppbinder-*
path: dist
merge-multiple: true

- name: Publish package to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist
17 changes: 15 additions & 2 deletions documentation/install.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
Installation
============
Install from PyPI
=================

The easiest way to install Binder is to use pip to install pre-built wheels from PyPI:

.. code-block:: bash

pip install cppbinder

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked how well this works when deployment system is different (ie lib stdc++ is different) from the the one you build wheels one? For my projects this was significant issue so i end up just rebuilding Binder on target system.

This will install the latest version of Binder and its dependencies.

To build Binder from source, follow the instructions below.

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.

Expand Down
143 changes: 143 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.4.3)
project(binder LANGUAGES CXX C)

add_subdirectory(llvm-project/llvm)
1 change: 1 addition & 0 deletions python/LICENSE
1 change: 1 addition & 0 deletions python/README.md
8 changes: 8 additions & 0 deletions python/binder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
import subprocess
import sys


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))
4 changes: 4 additions & 0 deletions python/binder/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from binder import binder

if __name__ == "__main__":
binder()
Loading
Loading