/ setup.py
setup.py
 1  from os import chdir
 2  from pathlib import Path
 3  from platform import system
 4  from setuptools import setup, Extension
 5  from setuptools.command.build_ext import build_ext
 6  from subprocess import check_call
 7  
 8  
 9  class CustomBuild(build_ext):
10      def run(self):
11          if system() == "Windows":
12              try:
13                  check_call(["blst\\build.bat"])
14              except Exception:
15                  pass
16          check_call(["make", "-C", "src", "blst"])
17          super().run()
18  
19  
20  def main():
21      # Change directory so we don't have to deal with paths.
22      setup_dir = Path(__file__).parent.resolve()
23      chdir(setup_dir)
24  
25      setup(
26          name="ckzg",
27          version="1.0.2",
28          author="Ethereum Foundation",
29          author_email="security@ethereum.org",
30          url="https://github.com/ethereum/c-kzg-4844",
31          description="Python bindings for C-KZG-4844",
32          long_description=Path("bindings/python/README.md").read_text(),
33          long_description_content_type="text/markdown",
34          license="Apache-2.0",
35          ext_modules=[
36              Extension(
37                  "ckzg",
38                  sources=["bindings/python/ckzg.c", "src/c_kzg_4844.c"],
39                  include_dirs=["inc", "src"],
40                  library_dirs=["lib"],
41                  libraries=["blst"]
42              )
43          ],
44          cmdclass={
45              "build_ext": CustomBuild,
46          }
47      )
48  
49  
50  if __name__ == "__main__":
51      main()