setup.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. #
  4. # Copyright (C) 2009-2019 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
  5. # Copyright (C) 2013-2019 Konstantin Ladutenko <kostyfisik@gmail.com>
  6. #
  7. # This file is part of scattnlay
  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. # The only additional remark is that we expect that all publications
  20. # describing work using this software, or all commercial products
  21. # using it, cite at least one of the following references:
  22. # [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
  23. # a multilayered sphere," Computer Physics Communications,
  24. # vol. 180, Nov. 2009, pp. 2348-2354.
  25. # [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
  26. # calculation of electromagnetic near-field for a multilayered
  27. # sphere," Computer Physics Communications, vol. 214, May 2017,
  28. # pp. 225-230.
  29. #
  30. # You should have received a copy of the GNU General Public License
  31. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  32. __version__ = "2.3"
  33. __title__ = "Calculation of the scattering of EM radiation by a multilayered sphere"
  34. __mod__ = "python-scattnlay"
  35. __author__ = "Ovidio Peña Rodríguez"
  36. __email__ = "ovidio@bytesfall.com"
  37. __url__ = "https://github.com/ovidiopr/scattnlay"
  38. __download_url__ = (
  39. "https://github.com/ovidiopr/scattnlay/archive/v" + __version__ + ".0.tar.gz"
  40. )
  41. from setuptools import setup
  42. from setuptools.extension import Extension
  43. import numpy as np
  44. import pybind11 as pb
  45. ext_dp = Extension(
  46. "scattnlay_dp",
  47. ["src/pb11-wrapper.cc"],
  48. language="c++",
  49. include_dirs=[np.get_include(), pb.get_include()],
  50. extra_compile_args=["-std=c++11"],
  51. )
  52. # extra_compile_args=['-std=c++11', '-O3',
  53. # '-mavx2', '-mfma',
  54. # '-finline-limit=1000000', '-ffp-contract=fast']),
  55. ext_mp = Extension(
  56. "scattnlay_mp",
  57. [" src/pb11-wrapper.cc"],
  58. language="c++",
  59. include_dirs=[np.get_include(), pb.get_include()],
  60. extra_compile_args=["-std=c++11", "-DMULTI_PRECISION=100"],
  61. )
  62. # extra_compile_args=['-std=c++11', '-O3',
  63. # '-mavx2', '-mfma',
  64. # '-finline-limit=1000000', '-ffp-contract=fast',
  65. # '-DMULTI_PRECISION=100']),
  66. def run_setup(extensions):
  67. setup(
  68. name=__mod__,
  69. version=__version__,
  70. description=__title__,
  71. long_description="""The Python version of scattnlay, a computer implementation of the algorithm for the \
  72. calculation of electromagnetic radiation scattering by a multilayered sphere developed by Yang. It has been \
  73. shown that the program is effective, resulting in very accurate values of scattering efficiencies for a wide \
  74. range of size parameters, which is a considerable improvement over previous implementations of similar algorithms. \
  75. For details see: O. Pena, U. Pal, Comput. Phys. Commun. 180 (2009) 2348-2354.""",
  76. author=__author__,
  77. author_email=__email__,
  78. maintainer=__author__,
  79. maintainer_email=__email__,
  80. keywords=[
  81. "Mie scattering",
  82. "Multilayered sphere",
  83. "Efficiency factors",
  84. "Cross-sections",
  85. ],
  86. url=__url__,
  87. download_url=__download_url__,
  88. license="GPL",
  89. platforms="any",
  90. packages=["scattnlay"], # , 'scattnlay_dp', 'scattnlay_mp'],
  91. test_suite="tests",
  92. ext_modules=extensions,
  93. install_requires=["numpy"],
  94. )
  95. try:
  96. run_setup([ext_dp, ext_mp])
  97. except:
  98. print("Failed to build all extensions... Building only in double precision...")
  99. run_setup([ext_dp])