Skip to content

Commit

Permalink
Merge pull request #5 from YyuK-Liao/master
Browse files Browse the repository at this point in the history
Fix two issues, Dependencies and Installation on different OS.
  • Loading branch information
samson-wang authored Nov 7, 2022
2 parents b271871 + 9badb34 commit 17a9209
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,47 @@

from __future__ import print_function

from Cython.Build import cythonize
from Cython.Distutils import build_ext
from setuptools import Extension
from setuptools import setup

import numpy as np


# Obtain the numpy include directory. This logic works across numpy versions.
try:
numpy_include = np.get_include()
except AttributeError:
numpy_include = np.get_numpy_include()
from distutils.command.build import build as _build
import os

# ref from https://stackoverflow.com/questions/54117786/add-numpy-get-include-argument-to-setuptools-without-preinstalled-numpy
class build(_build):
def finalize_options(self):
super().finalize_options()
import builtins
builtins.__NUMPY_SETUP__ = False
import numpy as np
# Obtain the numpy include directory. This logic works across numpy versions.
extension = next(m for m in self.distribution.ext_modules if m.name=='cython_bbox')
try:
extension.include_dirs.append(np.get_include())
except AttributeError:
extension.include_dirs.append(np.get_numpy_include())

with open("README.md", "r") as fh:
long_description = fh.read()

if os.name == 'nt':
compile_args = {'gcc': ['/Qstd=c99']}
else:
compile_args = ['-Wno-cpp']

ext_modules = [
Extension(
name='cython_bbox',
sources=['src/cython_bbox.pyx'],
extra_compile_args = {'gcc': ['/Qstd=c99']},
include_dirs=[numpy_include]
extra_compile_args = compile_args,
)
]

setup(
name='cython_bbox',
ext_modules=cythonize(ext_modules),
setup_requires=["setuptools>=18.0","Cython","numpy"],
install_requires=["Cython","numpy"],
ext_modules=ext_modules,
cmdclass={'build': build},
version = '0.1.3',
description = 'Standalone cython_bbox',
long_description=long_description,
Expand Down

0 comments on commit 17a9209

Please sign in to comment.