2022-12-04 16:45:21 -08:00
|
|
|
# Copyright (C) 2022 Exaloop Inc. <https://exaloop.io>
|
|
|
|
|
2022-03-31 01:22:26 -07:00
|
|
|
import os
|
2022-06-26 17:38:29 -04:00
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
from pathlib import Path
|
2022-03-31 01:22:26 -07:00
|
|
|
from Cython.Distutils import build_ext
|
|
|
|
from setuptools import setup
|
|
|
|
from setuptools.extension import Extension
|
|
|
|
|
2022-12-12 20:54:01 -05:00
|
|
|
exec(open("codon/version.py").read())
|
|
|
|
|
2022-06-26 17:38:29 -04:00
|
|
|
ext = "dylib" if sys.platform == "darwin" else "so"
|
|
|
|
|
2022-12-12 20:54:01 -05:00
|
|
|
codon_path = os.environ.get("CODON_DIR")
|
|
|
|
if not codon_path:
|
|
|
|
c = shutil.which("codon")
|
|
|
|
if c:
|
|
|
|
codon_path = Path(c).parent / ".."
|
|
|
|
else:
|
|
|
|
codon_path = Path(codon_path)
|
|
|
|
for path in [
|
|
|
|
os.path.expanduser("~") + "/.codon",
|
|
|
|
os.getcwd() + "/..",
|
|
|
|
]:
|
|
|
|
path = Path(path)
|
|
|
|
if not codon_path and path.exists():
|
|
|
|
codon_path = path
|
|
|
|
break
|
|
|
|
|
|
|
|
if (
|
|
|
|
not codon_path
|
|
|
|
or not (codon_path / "include" / "codon").exists()
|
|
|
|
or not (codon_path / "lib" / "codon").exists()
|
|
|
|
):
|
|
|
|
print(
|
|
|
|
"Cannot find Codon.",
|
|
|
|
'Please either install Codon (/bin/bash -c "$(curl -fsSL https://exaloop.io/install.sh)"),',
|
|
|
|
"or set CODON_DIR if Codon is not in PATH or installed in ~/.codon",
|
|
|
|
file=sys.stderr,
|
|
|
|
)
|
|
|
|
sys.exit(1)
|
|
|
|
codon_path = codon_path.resolve()
|
|
|
|
print("Codon: " + str(codon_path))
|
|
|
|
|
2022-06-26 17:38:29 -04:00
|
|
|
|
|
|
|
if sys.platform == "darwin":
|
2022-12-12 20:54:01 -05:00
|
|
|
linker_args = "-Wl,-rpath," + str(codon_path / "lib" / "codon")
|
2022-06-26 17:38:29 -04:00
|
|
|
else:
|
2022-12-12 20:54:01 -05:00
|
|
|
linker_args = "-Wl,-rpath=" + str(codon_path / "lib" / "codon")
|
|
|
|
|
2022-03-31 01:22:26 -07:00
|
|
|
|
|
|
|
jit_extension = Extension(
|
2022-06-26 17:38:29 -04:00
|
|
|
"codon.codon_jit",
|
2022-12-12 20:54:01 -05:00
|
|
|
sources=["codon/jit.pyx", "codon/jit.pxd"],
|
2022-03-31 01:22:26 -07:00
|
|
|
libraries=["codonc", "codonrt"],
|
|
|
|
language="c++",
|
|
|
|
extra_compile_args=["-w", "-std=c++17"],
|
2022-06-26 17:38:29 -04:00
|
|
|
extra_link_args=[linker_args],
|
2022-12-12 20:54:01 -05:00
|
|
|
library_dirs=[str(codon_path / "lib" / "codon")],
|
2022-03-31 01:22:26 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name="codon",
|
2022-12-12 20:54:01 -05:00
|
|
|
version=__version__,
|
|
|
|
install_requires=["cython", "astunparse"],
|
|
|
|
python_requires=">=3.6",
|
2022-06-26 17:38:29 -04:00
|
|
|
description="Codon JIT decorator",
|
2022-08-02 14:53:17 -04:00
|
|
|
url="https://exaloop.io",
|
2022-06-26 17:38:29 -04:00
|
|
|
long_description="Please see https://exaloop.io for more details.",
|
|
|
|
author="Exaloop Inc.",
|
2022-08-02 14:53:17 -04:00
|
|
|
author_email="info@exaloop.io",
|
2022-06-26 17:38:29 -04:00
|
|
|
license="Commercial",
|
2022-03-31 01:22:26 -07:00
|
|
|
ext_modules=[jit_extension],
|
|
|
|
packages=["codon"],
|
2022-12-12 20:54:01 -05:00
|
|
|
include_package_data=True,
|
|
|
|
cmdclass={
|
|
|
|
"build_ext": build_ext,
|
|
|
|
},
|
2022-03-31 01:22:26 -07:00
|
|
|
)
|