from setuptools import setup, Distribution, Extension

import sys

if sys.version_info[0] < 3:
    import os
    this_directory = os.path.dirname(os.path.abspath(__file__))
    with open(os.path.join(this_directory, "README.md"), 'r') as f:
        long_description = f.read()
else:
    from pathlib import Path
    this_directory = Path(__file__).parent
    long_description = (this_directory / "README.md").read_text()

# Suggested at https://stackoverflow.com/questions/24071491/how-can-i-make-a-python-wheel-from-an-existing-native-library
class BinaryDistribution(Distribution):
    def is_pure(foo):
        return False
    def has_ext_modules(foo):
        return True

# Suggested at https://stackoverflow.com/questions/51522248/overriding-python-setuptools-default-include-dirs-and-library-dirs
from setuptools.command.build_ext import build_ext as build_ext_orig
class build_ext(build_ext_orig):
    def run(self):
      pass


setup(name='robotraconteur',
      version='@ROBOTRACONTEUR_VERSION_PY@',
      description='Robot Raconteur Python Library',
      author='John Wason',
      author_email='wason@wasontech.com',
      url='http://robotraconteur.com/',
      packages=['RobotRaconteur'],
      @ROBOTRACONTEUR_PYTHON3_SETUPPY_EXTRA@
      package_data={'RobotRaconteur': ['_RobotRaconteurPython.pyd', '_RobotRaconteurPython.so']},
	  distclass=BinaryDistribution,
	  license='Apache-2.0',
	  install_requires=['numpy'],
      cmdclass={'build_ext': build_ext},
      ext_modules=[
        Extension(
          name='RobotRaconteur._RobotRaconteurPython',
          sources=[]
        )
      ],
      long_description=long_description,
      long_description_content_type='text/markdown'
    )
