2022-12-05 08:45:21 +08:00
|
|
|
# Copyright (C) 2022 Exaloop Inc. <https://exaloop.io>
|
|
|
|
|
2022-03-31 16:22:26 +08:00
|
|
|
import os
|
2022-06-27 05:38:29 +08:00
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
from pathlib import Path
|
2022-03-31 16:22:26 +08:00
|
|
|
from Cython.Distutils import build_ext
|
|
|
|
from setuptools import setup
|
|
|
|
from setuptools.extension import Extension
|
2022-09-16 21:03:57 +08:00
|
|
|
import tempfile
|
2022-08-03 02:53:17 +08:00
|
|
|
from config.config import *
|
2022-03-31 16:22:26 +08:00
|
|
|
|
2022-09-16 21:03:57 +08:00
|
|
|
codon_dir = Path(os.environ.get(
|
|
|
|
"CODON_DIR", os.path.realpath(f"{os.getcwd()}/../../build")
|
|
|
|
))
|
2022-06-27 05:38:29 +08:00
|
|
|
ext = "dylib" if sys.platform == "darwin" else "so"
|
|
|
|
|
2022-09-16 21:03:57 +08:00
|
|
|
root = Path(__file__).resolve().parent
|
|
|
|
def symlink(target):
|
|
|
|
tmp = tempfile.mktemp()
|
2022-08-04 04:36:03 +08:00
|
|
|
os.symlink(str(target.resolve()), tmp)
|
2022-09-16 21:03:57 +08:00
|
|
|
shutil.move(tmp, str(root / "codon" / target.name))
|
|
|
|
symlink(codon_dir / ".." / "stdlib")
|
|
|
|
symlink(codon_dir / "lib" / "codon" / ("libcodonc." + ext))
|
|
|
|
symlink(codon_dir / "lib" / "codon" / ("libcodonrt." + ext))
|
|
|
|
symlink(codon_dir / "lib" / "codon" / ("libomp." + ext))
|
2022-06-27 05:38:29 +08:00
|
|
|
|
|
|
|
if sys.platform == "darwin":
|
|
|
|
linker_args = "-Wl,-rpath,@loader_path"
|
|
|
|
else:
|
|
|
|
linker_args = "-Wl,-rpath=$ORIGIN"
|
2022-03-31 16:22:26 +08:00
|
|
|
|
|
|
|
jit_extension = Extension(
|
2022-06-27 05:38:29 +08:00
|
|
|
"codon.codon_jit",
|
2022-08-04 04:36:03 +08:00
|
|
|
sources=["codon/jit.pyx"],
|
2022-03-31 16:22:26 +08:00
|
|
|
libraries=["codonc", "codonrt"],
|
|
|
|
language="c++",
|
|
|
|
extra_compile_args=["-w", "-std=c++17"],
|
2022-06-27 05:38:29 +08:00
|
|
|
extra_link_args=[linker_args],
|
2022-09-16 21:03:57 +08:00
|
|
|
library_dirs=[str(root / "codon")],
|
2022-03-31 16:22:26 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name="codon",
|
2022-08-03 02:53:17 +08:00
|
|
|
version=CODON_VERSION,
|
2022-08-04 04:36:03 +08:00
|
|
|
install_requires=["astunparse"],
|
2022-06-27 05:38:29 +08:00
|
|
|
python_requires='>=3.6',
|
|
|
|
description="Codon JIT decorator",
|
2022-08-03 02:53:17 +08:00
|
|
|
url="https://exaloop.io",
|
2022-06-27 05:38:29 +08:00
|
|
|
long_description="Please see https://exaloop.io for more details.",
|
|
|
|
author="Exaloop Inc.",
|
2022-08-03 02:53:17 +08:00
|
|
|
author_email="info@exaloop.io",
|
2022-06-27 05:38:29 +08:00
|
|
|
license="Commercial",
|
2022-03-31 16:22:26 +08:00
|
|
|
cmdclass={"build_ext": build_ext},
|
|
|
|
ext_modules=[jit_extension],
|
|
|
|
packages=["codon"],
|
2022-06-27 05:38:29 +08:00
|
|
|
include_package_data=True
|
2022-03-31 16:22:26 +08:00
|
|
|
)
|