Files
concrete/compiler/setup.py
youben11 492ce3309a chore(python): change version file
we don't want the version file to be included in the package to not
clash with version files of other subpackages, as it should be part of
the bigger concrete namespace package
2022-01-04 09:28:42 +01:00

81 lines
2.4 KiB
Python

import os
import subprocess
import setuptools
import re
from setuptools import Extension
from setuptools.command.build_ext import build_ext
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
def find_version():
return re.match(
r"__version__ = \"(?P<version>.+)\"",
read("lib/Bindings/Python/version.txt"),
).group("version")
class MakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
def build_dir():
return os.environ.get("CONCRETE_COMPILER_BUILD_DIR", "build/")
class MakeBuild(build_ext):
def run(self):
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
cmd = ["make", f"BUILD_DIR={build_dir()}"]
py_exec = os.environ.get("CONCRETE_COMPILER_Python3_EXECUTABLE")
if py_exec:
cmd.append(f"Python3_EXECUTABLE={py_exec}")
ccache = os.environ.get("CONCRETE_COMPILER_CCACHE")
if ccache:
cmd.append(f"CCACHE={ccache}")
cmd.append("python-bindings")
subprocess.check_call(cmd)
setuptools.setup(
name="concrete-compiler",
version=find_version(),
author="Zama Team",
author_email="hello@zama.ai",
description="Concrete Compiler",
license="",
keywords="homomorphic encryption compiler",
long_description=read("README.md"),
long_description_content_type="text/markdown",
url="https://github.com/zama-ai/homomorphizer",
packages=setuptools.find_namespace_packages(
where=build_dir() + "tools/concretelang/python_packages/concretelang_core",
include=["concrete", "concrete.*"],
)
+ setuptools.find_namespace_packages(
where=build_dir() + "tools/concretelang/python_packages/concretelang_core",
include=["mlir", "mlir.*"],
),
install_requires=["numpy", "PyYAML", "setuptools"],
package_dir={"": build_dir() + "tools/concretelang/python_packages/concretelang_core"},
include_package_data=True,
package_data={"": ["*.so", "*.dylib"]},
classifiers=[
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Compilers",
"Topic :: Security :: Cryptography",
],
ext_modules=[MakeExtension("python-bindings")],
cmdclass=dict(build_ext=MakeBuild),
zip_safe=False,
)