1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3# reserved. See files LICENSE and NOTICE for details. 4# 5# This file is part of CEED, a collection of benchmarks, miniapps, software 6# libraries and APIs for efficient high-order finite element and spectral 7# element discretizations for exascale applications. For more information and 8# source code availability see http://github.com/ceed. 9# 10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11# a collaborative effort of two U.S. Department of Energy organizations (Office 12# of Science and the National Nuclear Security Administration) responsible for 13# the planning and preparation of a capable exascale ecosystem, including 14# software, applications, hardware, advanced system engineering and early 15# testbed platforms, in support of the nation"s exascale computing imperative. 16# pylint: disable=no-name-in-module,import-error,unused-variable 17import os 18import sys 19import subprocess 20from setuptools import setup 21 22# ------------------------------------------------------------------------------ 23# Setup 24# ------------------------------------------------------------------------------ 25def version(): 26 with open(os.path.abspath("ceed.pc.template")) as template: 27 ceed_version = [line.split("Version:", 1)[1].strip() for line in template if 28 line.startswith("Version: ")] 29 return ceed_version[0] 30 31description = """ 32libCEED: the Code for Efficient Extensible Discretization API Library 33===================================================================== 34 35This low-level API library provides the efficient high-order discretization 36methods developed by the ECP co-design Center for Efficient Exascale 37Discretizations (CEED). While our focus is on high-order finite elements, the 38approach is mostly algebraic and thus applicable to other discretizations in 39factored form, as explained in the API documentation. 40 41One of the challenges with high-order methods is that a global sparse matrix is 42no longer a good representation of a high-order linear operator, both with 43respect to the FLOPs needed for its evaluation, as well as the memory transfer 44needed for a matvec. Thus, high-order methods require a new "format" that still 45represents a linear (or more generally non-linear) operator, but not through a 46sparse matrix. 47 48libCEED is to provides such a format, as well as supporting implementations and 49data structures, that enable efficient operator evaluation on a variety of 50computational device types (CPUs, GPUs, etc.). This new operator description is 51algebraic and easy to incorporate in a wide variety of applications, without 52significant refactoring of their own discretization infrastructure. 53""" 54 55classifiers = """ 56Intended Audience :: Developers 57Intended Audience :: Science/Research 58License :: OSI Approved :: BSD License 59Operating System :: POSIX 60Programming Language :: C 61Programming Language :: C++ 62Programming Language :: CUDA 63Programming Language :: Fortran 64Programming Language :: Python 65Topic :: Scientific/Engineering 66Topic :: Software Development :: Libraries 67""" 68 69from distutils.errors import LibError 70from distutils.command.build import build as _build 71 72if sys.platform == "darwin": 73 library_file = "libceed.dylib" 74else: 75 library_file = "libceed.so" 76 77def _build_libceed(): 78 try: 79 import cffi 80 import numpy 81 except ImportError: 82 raise LibError("You must install cffi and numpy before building libceed") 83 84 env = os.environ.copy() 85 if subprocess.call(["make", "lib"], env=env) != 0: 86 raise LibError("Unable to build libceed") 87 88class build(_build): 89 def run(self, *args): 90 self.execute(_build_libceed, (), msg="Building libceed") 91 _build.run(self, *args) 92 93cmdclass = { 94 "build": build, 95} 96 97try: 98 from setuptools.command.develop import develop as _develop 99 class develop(_develop): 100 def run(self, *args): 101 self.execute(_build_libceed, (), msg="Building libceed") 102 _develop.run(self, *args) 103 104 cmdclass["develop"] = develop 105except ImportError: 106 pass 107 108if "bdist_wheel" in sys.argv: 109 sys.stderr.write("libceed cannot be built as a wheel\n") 110 sys.exit(1) 111 112setup(name="libceed", 113 version=version(), 114 description="libceed python bindings", 115 long_description="\n".join(description), 116 classifiers= classifiers.split("\n")[1:-1], 117 keywords=["libCEED"], 118 platforms=["POSIX"], 119 license="BSD 2", 120 121 url="https://github.com/CEED/libCEED", 122 123 author="libCEED Team", 124 author_email="ceed-users@llnl.gov", 125 126 requires=["numpy"], 127 packages=["libceed"], 128 package_dir={"libceed": "python"}, 129 130 setup_requires=["cffi"], 131 cffi_modules=["python/build_ceed_cffi.py:ffibuilder"], 132 133 cmdclass=cmdclass, 134) 135 136# ------------------------------------------------------------------------------ 137