setup.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/usr/bin/env python
  2. """
  3. setup.py for installing F2PY
  4. Usage:
  5. python setup.py install
  6. Copyright 2001-2005 Pearu Peterson all rights reserved,
  7. Pearu Peterson <pearu@cens.ioc.ee>
  8. Permission to use, modify, and distribute this software is given under the
  9. terms of the NumPy License.
  10. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
  11. $Revision: 1.32 $
  12. $Date: 2005/01/30 17:22:14 $
  13. Pearu Peterson
  14. """
  15. from __future__ import division, print_function
  16. __version__ = "$Id: setup.py,v 1.32 2005/01/30 17:22:14 pearu Exp $"
  17. import os
  18. import sys
  19. from distutils.dep_util import newer
  20. from numpy.distutils import log
  21. from numpy.distutils.core import setup
  22. from numpy.distutils.misc_util import Configuration
  23. from __version__ import version
  24. def _get_f2py_shebang():
  25. """ Return shebang line for f2py script
  26. If we are building a binary distribution format, then the shebang line
  27. should be ``#!python`` rather than ``#!`` followed by the contents of
  28. ``sys.executable``.
  29. """
  30. #if set(('bdist_wheel', 'bdist_egg', 'bdist_wininst',
  31. # 'bdist_rpm')).intersection(sys.argv):
  32. # return '#!python'
  33. #return '#!' + sys.executable
  34. # On OE, we need to avoid using the HOSTs python-native, we return env python instead
  35. return '#!/usr/bin/env python'
  36. def configuration(parent_package='', top_path=None):
  37. config = Configuration('f2py', parent_package, top_path)
  38. config.add_data_dir('tests')
  39. config.add_data_files('src/fortranobject.c',
  40. 'src/fortranobject.h',
  41. )
  42. config.make_svn_version_py()
  43. def generate_f2py_py(build_dir):
  44. f2py_exe = 'f2py' + os.path.basename(sys.executable)[6:]
  45. if f2py_exe[-4:] == '.exe':
  46. f2py_exe = f2py_exe[:-4] + '.py'
  47. if 'bdist_wininst' in sys.argv and f2py_exe[-3:] != '.py':
  48. f2py_exe = f2py_exe + '.py'
  49. target = os.path.join(build_dir, f2py_exe)
  50. if newer(__file__, target):
  51. log.info('Creating %s', target)
  52. f = open(target, 'w')
  53. f.write(_get_f2py_shebang() + '\n')
  54. mainloc = os.path.join(os.path.dirname(__file__), "__main__.py")
  55. with open(mainloc) as mf:
  56. f.write(mf.read())
  57. f.close()
  58. return target
  59. config.add_scripts(generate_f2py_py)
  60. log.info('F2PY Version %s', config.get_version())
  61. return config
  62. if __name__ == "__main__":
  63. config = configuration(top_path='')
  64. print('F2PY Version', version)
  65. config = config.todict()
  66. config['download_url'] = "http://cens.ioc.ee/projects/f2py2e/2.x"\
  67. "/F2PY-2-latest.tar.gz"
  68. config['classifiers'] = [
  69. 'Development Status :: 5 - Production/Stable',
  70. 'Intended Audience :: Developers',
  71. 'Intended Audience :: Science/Research',
  72. 'License :: OSI Approved :: NumPy License',
  73. 'Natural Language :: English',
  74. 'Operating System :: OS Independent',
  75. 'Programming Language :: C',
  76. 'Programming Language :: Fortran',
  77. 'Programming Language :: Python',
  78. 'Topic :: Scientific/Engineering',
  79. 'Topic :: Software Development :: Code Generators',
  80. ]
  81. setup(version=version,
  82. description="F2PY - Fortran to Python Interface Generaton",
  83. author="Pearu Peterson",
  84. author_email="pearu@cens.ioc.ee",
  85. maintainer="Pearu Peterson",
  86. maintainer_email="pearu@cens.ioc.ee",
  87. license="BSD",
  88. platforms="Unix, Windows (mingw|cygwin), Mac OSX",
  89. long_description="""\
  90. The Fortran to Python Interface Generator, or F2PY for short, is a
  91. command line tool (f2py) for generating Python C/API modules for
  92. wrapping Fortran 77/90/95 subroutines, accessing common blocks from
  93. Python, and calling Python functions from Fortran (call-backs).
  94. Interfacing subroutines/data from Fortran 90/95 modules is supported.""",
  95. url="http://cens.ioc.ee/projects/f2py2e/",
  96. keywords=['Fortran', 'f2py'],
  97. **config)