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

Adding source distribution #415

Merged
merged 27 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a02150f
add sdist distribution
step21 Apr 3, 2024
4ebd08c
Fix some minor nits
jtraglia Apr 5, 2024
0e8dc45
added MANIFEST.in to include source files
step21 Apr 14, 2024
8923c65
Move Python setup.py to repo's root dir
jtraglia Apr 16, 2024
c996170
Remove debug print
jtraglia Apr 16, 2024
9b2e4e1
Add custom build extension with setuptools
jtraglia Apr 16, 2024
23eb978
Fix some things
jtraglia Apr 16, 2024
70f784d
Add sdist test
jtraglia Apr 16, 2024
a109872
Run sdist test on more OSes
jtraglia Apr 16, 2024
4c3d613
Try to fix sdist test on Windows
jtraglia Apr 16, 2024
59b0e15
Fix ls command
jtraglia Apr 16, 2024
446a97e
Build blst.lib on Windows
jtraglia Apr 16, 2024
54c1170
Give up on Windows
jtraglia Apr 16, 2024
e97b3ee
Update ckzg's python package version
jtraglia Apr 16, 2024
d3d22f9
Try building with windows again
jtraglia Apr 16, 2024
affaff2
Add windows back to matrix
jtraglia Apr 16, 2024
81ae8cf
Don't use * in path
jtraglia Apr 16, 2024
b838cbf
Try better custom build
jtraglia Apr 16, 2024
70e0cf2
Wrap move headers with try except
jtraglia Apr 16, 2024
e21be3c
Add custom exceptions
jtraglia Apr 16, 2024
4237742
Try not building first
jtraglia Apr 16, 2024
e7c3440
Debug windows build
jtraglia Apr 16, 2024
2d8cf2c
Fix path to blst.lib
jtraglia Apr 16, 2024
3d71573
Once again fix path to blst.lib
jtraglia Apr 16, 2024
2de876a
Hail mary for Windows
jtraglia Apr 16, 2024
e36ae40
Give up on msvc & run with bash
jtraglia Apr 16, 2024
f23a0f2
Try build.bat first
jtraglia Apr 16, 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
27 changes: 26 additions & 1 deletion .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,32 @@ jobs:
name: wheels
path: wheelhouse/*

# Build the source distribution under Linux
build-sdist:
name: Source distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Build source distribution
run: python setup.py sdist

- name: Store artifacts
uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
name: wheels

publish:
needs: [build-wheels]
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
Expand All @@ -93,3 +117,4 @@ jobs:
with:
password: ${{ secrets.PYPI_PASSWORD }}
packages-dir: wheelhouse

34 changes: 34 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- main

defaults:
run:
shell: bash

jobs:
tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -37,3 +41,33 @@ jobs:
run: |
cd bindings/python
make test

test-sdist:
runs-on: ${{matrix.os}}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install PyYAML
- name: Build sdist
run: python setup.py sdist
- name: Set up Visual Studio shell
if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2
- name: Install via sdist
working-directory: dist
run: pip install ckzg-*.tar.gz
- name: Run tests
run: make -C bindings/python test
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is a manifest for the Python bindings
include bindings/python/ckzg.c
include bindings/python/README.md
recursive-include blst *
recursive-include lib *
recursive-include inc *
recursive-include src *
include setup.py
include LICENSE
include README.md
7 changes: 2 additions & 5 deletions bindings/python/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
.PHONY: all
all: install test

../../src/c_kzg_4844.o:
make -C../../src c_kzg_4844.o

.PHONY: install
install: setup.py ckzg.c ../../src/c_kzg_4844.o
python3 setup.py install
install: ../../setup.py ckzg.c
python3 ../../setup.py install --force

.PHONY: test
test: tests.py
Expand Down
29 changes: 0 additions & 29 deletions bindings/python/setup.py

This file was deleted.

53 changes: 53 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from pathlib import Path
from platform import system
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from subprocess import check_call

this_dir = Path(__file__).parent
long_description = (this_dir / "bindings/python/README.md").read_text()


def f(path_str):
return str(this_dir / path_str)


class CustomBuild(build_ext):
def run(self):
if system() == "Windows":
try:
check_call([f("blst\\build.bat")])
except Exception:
pass
check_call(["make", "-C", f("src"), "c_kzg_4844.o"])
super().run()


def main():
setup(
name="ckzg",
version="1.0.1",
author="Ethereum Foundation",
author_email="[email protected]",
url="https://github.com/ethereum/c-kzg-4844",
description="Python bindings for C-KZG-4844",
long_description=long_description,
long_description_content_type="text/markdown",
license="Apache-2.0",
ext_modules=[
Extension(
"ckzg",
sources=[f("bindings/python/ckzg.c"), f("src/c_kzg_4844.c")],
include_dirs=[f("inc"), f("src")],
library_dirs=[f("lib")],
libraries=["blst"]
)
],
cmdclass={
"build_ext": CustomBuild,
}
)


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