1import os 2import sys 3from distutils.core import setup, Extension 4 5import sgp4 6description, long_description = sgp4.__doc__.split('\n', 1) 7 8# Force compilation on Travis CI + Python 3 to make sure it keeps working. 9optional = True 10if sys.version_info[0] != 2 and os.environ.get('TRAVIS') == 'true': 11 optional = False 12 13# It is hard to write C extensions that support both Python 2 and 3, so 14# we opt here to support the acceleration only for Python 3. 15ext_modules = [] 16if sys.version_info[0] == 3: 17 ext_modules.append(Extension( 18 'sgp4.vallado_cpp', 19 optional=optional, 20 sources=[ 21 'extension/SGP4.cpp', 22 'extension/wrapper.cpp', 23 ], 24 25 # TODO: can we safely figure out how to use a pair of options 26 # like these, adapted to as many platforms as possible, to use 27 # multiple processors when available? 28 # extra_compile_args=['-fopenmp'], 29 # extra_link_args=['-fopenmp'], 30 extra_compile_args=['-ffloat-store'], 31 )) 32 33# Read the package's "__version__" without importing it. 34path = 'sgp4/__init__.py' 35with open(path, 'rb') as f: 36 text = f.read().decode('utf-8') 37text = text.replace('-*- coding: utf-8 -*-', '') # for Python 2.7 38namespace = {} 39eval(compile(text, path, 'exec'), namespace) 40 41setup(name = 'sgp4', 42 version = namespace['__version__'], 43 description = description, 44 long_description = long_description, 45 license = 'MIT', 46 author = 'Brandon Rhodes', 47 author_email = 'brandon@rhodesmill.org', 48 url = 'https://github.com/brandon-rhodes/python-sgp4', 49 classifiers = [ 50 'Development Status :: 5 - Production/Stable', 51 'Intended Audience :: Science/Research', 52 'License :: OSI Approved :: MIT License', 53 'Programming Language :: Python :: 2', 54 'Programming Language :: Python :: 2.6', 55 'Programming Language :: Python :: 2.7', 56 'Programming Language :: Python :: 3', 57 'Programming Language :: Python :: 3.3', 58 'Programming Language :: Python :: 3.4', 59 'Programming Language :: Python :: 3.5', 60 'Programming Language :: Python :: 3.6', 61 'Programming Language :: Python :: 3.7', 62 'Programming Language :: Python :: 3.8', 63 'Programming Language :: Python :: 3.9', 64 'Topic :: Scientific/Engineering :: Astronomy', 65 ], 66 packages = ['sgp4'], 67 package_data = {'sgp4': ['SGP4-VER.TLE', 'sample*', 'tcppver.out']}, 68 ext_modules = ext_modules, 69) 70