xref: /libCEED/setup.py (revision d310b3d31eeeddd20725517a3a61881a36d919f0)
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
18from setuptools import setup
19from setuptools.command.build_ext import build_ext
20
21# ------------------------------------------------------------------------------
22# Setup
23# ------------------------------------------------------------------------------
24
25
26def version():
27    with open(os.path.abspath("ceed.pc.template")) as template:
28        ceed_version = [line.split("Version:", 1)[1].strip() for line in template if
29                        line.startswith("Version: ")]
30    return ceed_version[0]
31
32
33def requirements():
34    with open('requirements.txt') as f:
35        return f.readlines()
36
37
38class libceed_build_ext(build_ext):
39    def run(self):
40        prefix = os.path.join(self.build_lib, 'libceed')
41        self.make_libceed_so(prefix)
42        build_ext.run(self)
43
44    def make_libceed_so(self, prefix):
45        import subprocess
46        if hasattr(os, 'sched_getaffinity'):
47            # number of available logical cores
48            nproc = len(os.sched_getaffinity(0))
49        else:
50            nproc = os.cpu_count()
51        subprocess.check_call([
52            'make',
53            '-j{}'.format(nproc),
54            '--always-make',
55            'install',
56            'prefix=' + prefix,
57            'FC=',  # Don't try to find Fortran (unused library build/install)
58        ])
59
60
61description = """
62libCEED: Code for Efficient Extensible Discretization
63=====================================================
64
65libCEED is a lightweight library for expressing and manipulating operators that
66arise in high-order element-based discretization of partial differential
67equations.  libCEED's representations are much for efficient than assembled
68sparse matrices, and can achieve very high performance on modern CPU and GPU
69hardware.  This approach is applicable to a broad range of linear and nonlinear
70problems, and includes facilities for preconditioning.  libCEED is meant to be
71easy to incorporate into existing libraries and applications, and to build new
72tools on top of.
73
74libCEED has been developed as part of the DOE Exascale Computing Project
75co-design Center for Efficient Exascale Discretizations (CEED).
76"""
77
78classifiers = """
79Development Status :: 4 - Beta
80Intended Audience :: Developers
81Intended Audience :: Science/Research
82License :: OSI Approved :: BSD License
83Operating System :: POSIX
84Programming Language :: C
85Programming Language :: C++
86Programming Language :: Fortran
87Programming Language :: Python
88Programming Language :: Python :: 3.5
89Programming Language :: Python :: 3.6
90Programming Language :: Python :: 3.7
91Programming Language :: Python :: 3.8
92Programming Language :: Python :: 3 :: Only
93Topic :: Scientific/Engineering
94Topic :: Software Development :: Libraries
95"""
96
97setup(name="libceed",
98      version=version(),
99      description="libCEED: Code for Efficient Extensible Discretization",
100      long_description=description,
101      long_description_content_type='text/x-rst',
102      classifiers=classifiers.split("\n")[1:-1],
103      keywords=["libCEED"],
104      platforms=["POSIX"],
105      license="BSD 2",
106      license_file='LICENSE',
107      url="https://libceed.org",
108      download_url="https://github.com/CEED/libCEED/releases",
109      project_urls={
110          "Bug Tracker": "https://github.com/CEED/libCEED/issues",
111          "Documentation": "https://libceed.org",
112          "Source Code": "https://github.com/CEED/libCEED",
113      },
114      author="libCEED Team",
115      author_email="ceed-users@llnl.gov",
116
117      install_requires=requirements(),
118      packages=["libceed"],
119      package_dir={"libceed": "python"},
120      include_package_data=True,
121
122      setup_requires=["cffi"],
123      cffi_modules=["python/build_ceed_cffi.py:ffibuilder"],
124      cmdclass={'build_ext': libceed_build_ext},
125
126      extras_require={
127          'cuda': ['numba']
128      },
129      )
130
131# ------------------------------------------------------------------------------
132