Coverage for setup.py: 0%

22 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-03-01 11:53 +0000

1# This file is part of scarlet_lite. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21 

22# This uses the code at 

23# https://github.com/pybind/python_example/blob/master/setup.py 

24# as a template to integrate pybind11 

25 

26""" 

27Basic setuptools description. 

28This is not a complete definition. 

29* Version number is not correct. 

30* The shared library and include files are not installed. This makes it 

31 unusable with other python packages that directly reference the C++ 

32 interface. 

33""" 

34 

35import glob 

36import os 

37 

38# Importing this automatically enables parallelized builds 

39import numpy.distutils.ccompiler # noqa: F401 

40from pybind11.setup_helpers import Pybind11Extension, build_ext 

41from setuptools import setup 

42 

43eigen_path = None 

44if "EIGEN_DIR" in os.environ: 

45 eigen_path = os.environ["EIGEN_DIR"] 

46 

47 

48class GetEigenInclude(object): 

49 """Helper class to determine the peigen include path 

50 The purpose of this class is to postpone importing peigen 

51 until it is actually installed, so that the ``get_include()`` 

52 method can be invoked. 

53 """ 

54 

55 def __init__(self, user=False): 

56 self.user = user 

57 

58 def __str__(self): 

59 if "EIGEN_INCLUDE" in os.environ: 

60 return os.environ["EIGEN_INCLUDE"] 

61 if eigen_path is not None: 

62 return os.path.join(os.environ["EIGEN_DIR"], "include") 

63 else: 

64 import peigen 

65 

66 return peigen.header_path 

67 

68 

69# Find the source code -- we can combine it into a single module 

70pybind_src = sorted(glob.glob("python/lsst/scarlet/lite/*.cc")) 

71 

72ext_modules = [ 

73 Pybind11Extension("lsst.scarlet.lite.detect_pybind11", pybind_src, include_dirs=[GetEigenInclude()]), 

74 Pybind11Extension("lsst.scarlet.lite.operators_pybind11", pybind_src, include_dirs=[GetEigenInclude()]), 

75] 

76 

77setup( 

78 ext_modules=ext_modules, 

79 cmdclass={"build_ext": build_ext}, 

80)