Add source distribution for Python package (#415)
Also improves setup.py and moves it to the repo's root directory.
This commit is contained in:
parent
1ef67c17bf
commit
67e5904a04
|
@ -78,8 +78,32 @@ jobs:
|
||||||
name: wheels
|
name: wheels
|
||||||
path: wheelhouse/*
|
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:
|
publish:
|
||||||
needs: [build-wheels]
|
needs: [build-wheels, build-sdist]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
|
@ -93,3 +117,4 @@ jobs:
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.PYPI_PASSWORD }}
|
password: ${{ secrets.PYPI_PASSWORD }}
|
||||||
packages-dir: wheelhouse
|
packages-dir: wheelhouse
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -37,3 +41,33 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cd bindings/python
|
cd bindings/python
|
||||||
make test
|
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
|
||||||
|
|
|
@ -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
|
|
@ -1,12 +1,9 @@
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: install test
|
all: install test
|
||||||
|
|
||||||
../../src/c_kzg_4844.o:
|
|
||||||
make -C../../src c_kzg_4844.o
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: setup.py ckzg.c ../../src/c_kzg_4844.o
|
install: ../../setup.py ckzg.c
|
||||||
python3 setup.py install
|
python3 ../../setup.py install --force
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: tests.py
|
test: tests.py
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
from setuptools import setup, Extension
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
this_directory = Path(__file__).parent
|
|
||||||
long_description = (this_directory / "README.md").read_text()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
setup(
|
|
||||||
name="ckzg",
|
|
||||||
version="1.0.0",
|
|
||||||
author="Ethereum Foundation",
|
|
||||||
author_email="security@ethereum.org",
|
|
||||||
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=["ckzg.c", "../../src/c_kzg_4844.c"],
|
|
||||||
include_dirs=["../../inc", "../../src"],
|
|
||||||
library_dirs=["../../lib"],
|
|
||||||
libraries=["blst"])])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
|
@ -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="security@ethereum.org",
|
||||||
|
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…
Reference in New Issue