xref: /libCEED/setup.py (revision 4fd67f616b05b2bd901aef1527a932ecb3d8f696)
1ee05e790Sjeremylt# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2ee05e790Sjeremylt# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3ee05e790Sjeremylt# reserved. See files LICENSE and NOTICE for details.
4ee05e790Sjeremylt#
5ee05e790Sjeremylt# This file is part of CEED, a collection of benchmarks, miniapps, software
6ee05e790Sjeremylt# libraries and APIs for efficient high-order finite element and spectral
7ee05e790Sjeremylt# element discretizations for exascale applications. For more information and
83d8e8822SJeremy L Thompson# source code availability see http://github.com/ceed
9ee05e790Sjeremylt#
10ee05e790Sjeremylt# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11ee05e790Sjeremylt# a collaborative effort of two U.S. Department of Energy organizations (Office
12ee05e790Sjeremylt# of Science and the National Nuclear Security Administration) responsible for
13ee05e790Sjeremylt# the planning and preparation of a capable exascale ecosystem, including
14ee05e790Sjeremylt# software, applications, hardware, advanced system engineering and early
15ee05e790Sjeremylt# testbed platforms, in support of the nation"s exascale computing imperative.
16ee05e790Sjeremylt# pylint: disable=no-name-in-module,import-error,unused-variable
17ee05e790Sjeremyltimport os
18ee05e790Sjeremyltfrom setuptools import setup
1937c134eaSJed Brownfrom setuptools.command.build_ext import build_ext
20ee05e790Sjeremylt
21ee05e790Sjeremylt# ------------------------------------------------------------------------------
22ee05e790Sjeremylt# Setup
23ee05e790Sjeremylt# ------------------------------------------------------------------------------
247a7b0fa3SJed Brown
257a7b0fa3SJed Brown
26ee05e790Sjeremyltdef version():
27ee05e790Sjeremylt    with open(os.path.abspath("ceed.pc.template")) as template:
28ee05e790Sjeremylt        ceed_version = [line.split("Version:", 1)[1].strip() for line in template if
29ee05e790Sjeremylt                        line.startswith("Version: ")]
30ee05e790Sjeremylt    return ceed_version[0]
31ee05e790Sjeremylt
327a7b0fa3SJed Brown
3337c134eaSJed Browndef requirements():
3437c134eaSJed Brown    with open('requirements.txt') as f:
3537c134eaSJed Brown        return f.readlines()
3637c134eaSJed Brown
377a7b0fa3SJed Brown
3837c134eaSJed Brownclass libceed_build_ext(build_ext):
3937c134eaSJed Brown    def run(self):
40*dd8ab4d9SJed Brown        prefix = os.path.join(self.build_lib, 'libceed')
41*dd8ab4d9SJed Brown        self.make_libceed_so(prefix)
4237c134eaSJed Brown        build_ext.run(self)
4337c134eaSJed Brown
44*dd8ab4d9SJed Brown    def make_libceed_so(self, prefix):
4537c134eaSJed Brown        import subprocess
4680a9ef05SNatalie Beams        if hasattr(os, 'sched_getaffinity'):
4780a9ef05SNatalie Beams            # number of available logical cores
4880a9ef05SNatalie Beams            nproc = len(os.sched_getaffinity(0))
4980a9ef05SNatalie Beams        else:
5080a9ef05SNatalie Beams            nproc = os.cpu_count()
5180a9ef05SNatalie Beams        subprocess.check_call([
5280a9ef05SNatalie Beams            'make',
5380a9ef05SNatalie Beams            '-j{}'.format(nproc),
5480a9ef05SNatalie Beams            '--always-make',
5580a9ef05SNatalie Beams            'install',
56*dd8ab4d9SJed Brown            'prefix=' + prefix,
5780a9ef05SNatalie Beams            'FC=',  # Don't try to find Fortran (unused library build/install)
5880a9ef05SNatalie Beams        ])
597a7b0fa3SJed Brown
6037c134eaSJed Brown
61ee05e790Sjeremyltdescription = """
6237c134eaSJed BrownlibCEED: Code for Efficient Extensible Discretization
6337c134eaSJed Brown=====================================================
64ee05e790Sjeremylt
6537c134eaSJed BrownlibCEED is a lightweight library for expressing and manipulating operators that
6637c134eaSJed Brownarise in high-order element-based discretization of partial differential
6737c134eaSJed Brownequations.  libCEED's representations are much for efficient than assembled
6837c134eaSJed Brownsparse matrices, and can achieve very high performance on modern CPU and GPU
6937c134eaSJed Brownhardware.  This approach is applicable to a broad range of linear and nonlinear
7037c134eaSJed Brownproblems, and includes facilities for preconditioning.  libCEED is meant to be
7137c134eaSJed Browneasy to incorporate into existing libraries and applications, and to build new
7237c134eaSJed Browntools on top of.
73ee05e790Sjeremylt
7437c134eaSJed BrownlibCEED has been developed as part of the DOE Exascale Computing Project
7537c134eaSJed Brownco-design Center for Efficient Exascale Discretizations (CEED).
76ee05e790Sjeremylt"""
77ee05e790Sjeremylt
78ee05e790Sjeremyltclassifiers = """
7937c134eaSJed BrownDevelopment Status :: 4 - Beta
80ee05e790SjeremyltIntended Audience :: Developers
81ee05e790SjeremyltIntended Audience :: Science/Research
82ee05e790SjeremyltOperating System :: POSIX
83ee05e790SjeremyltProgramming Language :: C
84ee05e790SjeremyltProgramming Language :: C++
85ee05e790SjeremyltProgramming Language :: Fortran
86ee05e790SjeremyltProgramming Language :: Python
8737c134eaSJed BrownProgramming Language :: Python :: 3.5
8837c134eaSJed BrownProgramming Language :: Python :: 3.6
8937c134eaSJed BrownProgramming Language :: Python :: 3.7
9037c134eaSJed BrownProgramming Language :: Python :: 3.8
9137c134eaSJed BrownProgramming Language :: Python :: 3 :: Only
92ee05e790SjeremyltTopic :: Scientific/Engineering
93ee05e790SjeremyltTopic :: Software Development :: Libraries
94ee05e790Sjeremylt"""
95ee05e790Sjeremylt
96ee05e790Sjeremyltsetup(name="libceed",
97ee05e790Sjeremylt      version=version(),
9837c134eaSJed Brown      description="libCEED: Code for Efficient Extensible Discretization",
9937c134eaSJed Brown      long_description=description,
10037c134eaSJed Brown      long_description_content_type='text/x-rst',
101ee05e790Sjeremylt      classifiers=classifiers.split("\n")[1:-1],
102ee05e790Sjeremylt      keywords=["libCEED"],
103ee05e790Sjeremylt      platforms=["POSIX"],
104ee05e790Sjeremylt      license="BSD 2",
10537c134eaSJed Brown      license_file='LICENSE',
10613964f07SJed Brown      url="https://libceed.org",
10737c134eaSJed Brown      download_url="https://github.com/CEED/libCEED/releases",
10837c134eaSJed Brown      project_urls={
10937c134eaSJed Brown          "Bug Tracker": "https://github.com/CEED/libCEED/issues",
11013964f07SJed Brown          "Documentation": "https://libceed.org",
11137c134eaSJed Brown          "Source Code": "https://github.com/CEED/libCEED",
11237c134eaSJed Brown      },
113ee05e790Sjeremylt      author="libCEED Team",
114ee05e790Sjeremylt      author_email="ceed-users@llnl.gov",
115ee05e790Sjeremylt
11637c134eaSJed Brown      install_requires=requirements(),
117ee05e790Sjeremylt      packages=["libceed"],
118ee05e790Sjeremylt      package_dir={"libceed": "python"},
11937c134eaSJed Brown      include_package_data=True,
120ee05e790Sjeremylt
121ee05e790Sjeremylt      setup_requires=["cffi"],
122ee05e790Sjeremylt      cffi_modules=["python/build_ceed_cffi.py:ffibuilder"],
12337c134eaSJed Brown      cmdclass={'build_ext': libceed_build_ext},
124962dc42dSJeremy L Thompson
125962dc42dSJeremy L Thompson      extras_require={
126962dc42dSJeremy L Thompson          'cuda': ['numba']
127962dc42dSJeremy L Thompson      },
128ee05e790Sjeremylt      )
129ee05e790Sjeremylt
130ee05e790Sjeremylt# ------------------------------------------------------------------------------
131