File: setup.py

package info (click to toggle)
mshr 2019.2.0~git20230811.ff54a68%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,432 kB
  • sloc: cpp: 9,828; python: 689; makefile: 295; sh: 65; ansic: 11
file content (52 lines) | stat: -rw-r--r-- 2,101 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os, sys
import subprocess
import json

from setuptools import setup, Extension


# Call cmake to generate json file with include and link information about dolfin and pybind11
MSHR_LIB_NAME_EXT = os.environ.get('MSHR_LIB_NAME_EXT') or ''
DOLFIN_LIB_NAME_EXT = os.environ.get('DOLFIN_LIB_NAME_EXT') or ''
config_dir="build" + MSHR_LIB_NAME_EXT
if not os.path.isfile(os.path.join(config_dir, "config.json")) :
    if not os.path.exists(config_dir) :
        os.mkdir(config_dir)
    cmake_command=["cmake", os.getcwd()]
    if os.environ.get('CMAKE_PREFIX_PATH'):
        cmake_command.extend(['-DCMAKE_PREFIX_PATH={}'.format(os.environ['CMAKE_PREFIX_PATH'])])
    if MSHR_LIB_NAME_EXT:
        cmake_command.extend(['-DMSHR_LIB_NAME_EXT={}'.format(MSHR_LIB_NAME_EXT)])
    if DOLFIN_LIB_NAME_EXT:
        cmake_command.extend(['-DDOLFIN_LIB_NAME_EXT={}'.format(DOLFIN_LIB_NAME_EXT)])
    elif MSHR_LIB_NAME_EXT:
        cmake_command.extend(['-DDOLFIN_LIB_NAME_EXT={}'.format(MSHR_LIB_NAME_EXT)])
    subprocess.check_call(cmake_command, cwd=os.path.abspath(config_dir))

with open(os.path.join(config_dir, "config.json"), 'r') as infile :
    config = json.load(infile)

include_dirs = config["pybind11"]["include_dirs"].split(";") + \
               config["dolfin"]["include_dirs"].split(";")   + \
               config["mshr"]["include_dirs"].split(";")


mshr_ext = Extension('mshr.cpp',
                     ['src/mshr.cpp'],
                     include_dirs=include_dirs,
                     library_dirs=config['mshr']['lib_dirs'].split(";"),
                     libraries=config['mshr']['libs'].split(";"),
                     extra_compile_args=['-std=c++17'],
                     language='c++17')


setup(name             = 'mshr',
      version          = '2019.2.0.dev0',
      author           = 'FEniCS Project',
      description      = 'mshr python interface (via pybind11)',
      long_description = '',
      packages         = ["mshr",],
      ext_modules      = [mshr_ext],
      install_requires = ["numpy", "fenics-dolfin"]
      #zip_safe         = False)
      )