In Python setup file, change directory instead of using absolute paths (#419)

This commit is contained in:
Justin Traglia 2024-04-24 20:58:04 -05:00 committed by GitHub
parent a874006744
commit 4d3e76d500
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 13 deletions

View File

@ -1,29 +1,27 @@
from os import chdir
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")])
check_call(["blst\\build.bat"])
except Exception:
pass
check_call(["make", "-C", f("src"), "blst"])
check_call(["make", "-C", "src", "blst"])
super().run()
def main():
# Change directory so we don't have to deal with paths.
setup_dir = Path(__file__).parent.resolve()
chdir(setup_dir)
setup(
name="ckzg",
version="1.0.1",
@ -31,15 +29,15 @@ def main():
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=Path("bindings/python/README.md").read_text(),
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")],
sources=["bindings/python/ckzg.c", "src/c_kzg_4844.c"],
include_dirs=["inc", "src"],
library_dirs=["lib"],
libraries=["blst"]
)
],