mirror of
https://github.com/luxfhe/torus.git
synced 2026-10-30 17:07:26 +00:00
The MLIR dialect, its conversion passes (TFHEToConcrete, ConcreteToCAPI, ConcreteToLLVM), the optimizer component, the compiler binary, the Rust crate and the program_info parameter file all still carried the upstream project's name. They now carry this one's. Two things deliberately keep the word, because in them it is not the name. mlir::OpTrait CRTP parameters mean "the derived type", so they are spelled Derived and OpTy — LLVM's other conventional spelling for the same idiom. concreteShape is a capnp field: renaming it would change the serialized protocol, and the prose describing it is ordinary English. This also repairs references the earlier partial rename left dangling: Security.cpp included concrete/curves.gen.h and the directory is torus/, torus-cpu.h included concrete-num_complex.h, the Torus dialect CMakeLists named ConcreteOps.td, and compiler/setup.py asked find_namespace_packages for a "concrete" package that no longer exists — so it built without the package it ships.
87 lines
2.7 KiB
Python
87 lines
2.7 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():
|
|
path = os.environ.get("TORUS_COMPILER_BUILD_DIR", "build/")
|
|
return os.path.relpath(path)
|
|
|
|
|
|
class MakeBuild(build_ext):
|
|
def run(self):
|
|
for ext in self.extensions:
|
|
self.build_extension(ext)
|
|
|
|
def build_extension(self, ext):
|
|
cmd = ["make", "CCACHE=ON"]
|
|
# default to dataflow_exec to ON
|
|
dataflow_build = os.environ.get("TORUS_COMPILER_DATAFLOW_EXECUTION_ENABLED", "ON")
|
|
cmd.append(f"DATAFLOW_EXECUTION_ENABLED={dataflow_build}")
|
|
py_exec = os.environ.get("TORUS_COMPILER_Python3_EXECUTABLE")
|
|
if py_exec:
|
|
cmd.append(f"Python3_EXECUTABLE={py_exec}")
|
|
cuda_support = os.environ.get("TORUS_COMPILER_CUDA_SUPPORT")
|
|
if cuda_support:
|
|
cmd.append(f"CUDA_SUPPORT={cuda_support}")
|
|
cmd.append(f"BUILD_DIR={build_dir()}")
|
|
cmd.append("python-bindings")
|
|
subprocess.check_call(cmd)
|
|
|
|
|
|
setuptools.setup(
|
|
name="torus-compiler",
|
|
version=find_version(),
|
|
author="Lux Industries",
|
|
author_email="[email protected]",
|
|
description="Torus Compiler",
|
|
license="BSD-3",
|
|
keywords="homomorphic encryption compiler",
|
|
long_description=read("RELEASE_README.md"),
|
|
long_description_content_type="text/markdown",
|
|
url="https://github.com/luxfhe.com/torus-compiler",
|
|
packages=setuptools.find_namespace_packages(
|
|
where=build_dir() + "/tools/toruslang/python_packages/toruslang_core",
|
|
include=["torus", "torus.*"],
|
|
)
|
|
+ setuptools.find_namespace_packages(
|
|
where=build_dir() + "/tools/toruslang/python_packages/toruslang_core",
|
|
include=["mlir", "mlir.*"],
|
|
),
|
|
setup_requires=['wheel'],
|
|
install_requires=["numpy", "PyYAML", "setuptools"],
|
|
package_dir={"": build_dir() + "/tools/toruslang/python_packages/toruslang_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,
|
|
)
|