try:
	from setuptools import setup
except:
	from distutils.core import setup
import numpy as np
from distutils.extension import Extension
import os

### https://github.com/rtfd/readthedocs.org/issues/5297
from_rtd = os.environ.get('READTHEDOCS') == 'True'

if not from_rtd:
	from Cython.Distutils import build_ext
	## https://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used
	class build_ext_subclass( build_ext ):
		def build_extensions(self):
			c = self.compiler.compiler_type
			if c == 'msvc': # visual studio
				for e in self.extensions:
					e.extra_compile_args = ['/O2']
			else: # gcc and clang
				for e in self.extensions:
					e.extra_compile_args = ['-fopenmp', '-O2', '-march=native', '-std=c99']
					e.extra_link_args = ['-fopenmp']
			build_ext.build_extensions(self)

	setup(
		name = 'costsensitive',
		packages = ['costsensitive'],
		install_requires=[
		 'numpy',
		 'scipy',
		 'joblib>=0.13',
		 'cython'
		],
		python_requires = ">=3",
		version = '0.1.2.6',
		description = 'Reductions for Cost-Sensitive Multi-Class Classification',
		author = 'David Cortes',
		author_email = 'david.cortes.rivera@gmail.com',
		url = 'https://github.com/david-cortes/costsensitive',
		keywords = ['cost sensitive multi class', 'cost-sensitive multi-class classification', 'weighted all pairs', 'filter tree'],
		classifiers = [],

		cmdclass = {'build_ext': build_ext_subclass},
		ext_modules = [Extension("costsensitive._vwrapper", sources=["costsensitive/vwrapper.pyx"], include_dirs=[np.get_include()], extra_link_args=["-fopenmp"])]
	)
else:
	setup(
		name = 'costsensitive',
		packages = ['costsensitive'],
		install_requires=[
		 'numpy',
		 'scipy',
		 'joblib>=0.13',
		 'cython'
	],
		python_requires = ">=3",
		version = '0.1.2.6',
		)
