xref: /libCEED/setup.py (revision d416dc2b8eb8ab8cb4fa3546f1e63962299dc06a)
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
82Operating System :: POSIX
83Programming Language :: C
84Programming Language :: C++
85Programming Language :: Fortran
86Programming Language :: Python
87Programming Language :: Python :: 3.5
88Programming Language :: Python :: 3.6
89Programming Language :: Python :: 3.7
90Programming Language :: Python :: 3.8
91Programming Language :: Python :: 3 :: Only
92Topic :: Scientific/Engineering
93Topic :: Software Development :: Libraries
94"""
95
96setup(name="libceed",
97      version=version(),
98      description="libCEED: Code for Efficient Extensible Discretization",
99      long_description=description,
100      long_description_content_type='text/x-rst',
101      classifiers=classifiers.split("\n")[1:-1],
102      keywords=["libCEED"],
103      platforms=["POSIX"],
104      license="BSD 2",
105      license_file='LICENSE',
106      url="https://libceed.org",
107      download_url="https://github.com/CEED/libCEED/releases",
108      project_urls={
109          "Bug Tracker": "https://github.com/CEED/libCEED/issues",
110          "Documentation": "https://libceed.org",
111          "Source Code": "https://github.com/CEED/libCEED",
112      },
113      author="libCEED Team",
114      author_email="ceed-users@llnl.gov",
115
116      install_requires=requirements(),
117      packages=["libceed"],
118      package_dir={"libceed": "python"},
119      include_package_data=True,
120
121      setup_requires=["cffi"],
122      cffi_modules=["python/build_ceed_cffi.py:ffibuilder"],
123      cmdclass={'build_ext': libceed_build_ext},
124
125      extras_require={
126          'cuda': ['numba']
127      },
128      )
129
130# ------------------------------------------------------------------------------
131