Files
insightface/python-package/setup.py

95 lines
2.9 KiB
Python
Raw Normal View History

2019-08-29 23:23:35 +08:00
#!/usr/bin/env python
import os
import io
2021-06-15 22:00:11 +08:00
import glob
import numpy
2019-08-29 23:23:35 +08:00
import re
import shutil
import sys
from setuptools import setup, find_packages
2021-06-15 22:00:11 +08:00
from distutils.core import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
2020-11-06 13:59:21 +08:00
2019-08-29 23:23:35 +08:00
def read(*names, **kwargs):
2020-11-06 13:59:21 +08:00
with io.open(os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8")) as fp:
2019-08-29 23:23:35 +08:00
return fp.read()
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
2021-08-23 19:33:51 +08:00
pypandoc_enabled = True
2021-07-08 13:15:30 +08:00
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except (IOError, ImportError, ModuleNotFoundError):
2021-07-08 13:15:30 +08:00
long_description = open('README.md').read()
2021-08-23 19:33:51 +08:00
pypandoc_enabled = False
2019-08-29 23:23:35 +08:00
2021-07-08 13:15:30 +08:00
#import pypandoc
#long_description = pypandoc.convert('README.md', 'rst')
2019-08-29 23:23:35 +08:00
VERSION = find_version('insightface', '__init__.py')
requirements = [
'numpy',
2021-05-16 09:53:01 +08:00
'onnx',
2019-08-29 23:23:35 +08:00
'tqdm',
'requests',
'matplotlib',
'Pillow',
'scipy',
2021-06-16 22:43:11 +08:00
#'opencv-python',
2019-08-29 23:23:35 +08:00
'scikit-learn',
'scikit-image',
'easydict',
'cython',
2021-06-16 22:43:11 +08:00
'albumentations',
2021-06-15 22:00:11 +08:00
'prettytable',
2019-08-29 23:23:35 +08:00
]
2021-06-15 22:00:11 +08:00
extensions = [
2021-06-16 22:43:11 +08:00
Extension("insightface.thirdparty.face3d.mesh.cython.mesh_core_cython",
["insightface/thirdparty/face3d/mesh/cython/mesh_core_cython.pyx", "insightface/thirdparty/face3d/mesh/cython/mesh_core.cpp"], language='c++'),
2021-06-15 22:00:11 +08:00
]
2021-06-19 23:53:04 +08:00
data_images = list(glob.glob('insightface/data/images/*.jpg'))
data_images += list(glob.glob('insightface/data/images/*.png'))
2021-06-15 22:00:11 +08:00
data_mesh = list(glob.glob('insightface/thirdparty/face3d/mesh/cython/*.h'))
data_mesh += list(glob.glob('insightface/thirdparty/face3d/mesh/cython/*.c'))
data_mesh += list(glob.glob('insightface/thirdparty/face3d/mesh/cython/*.py*'))
2021-06-19 23:53:04 +08:00
data_files = [ ('insightface/data/images', data_images) ]
data_files += [ ('insightface/thirdparty/face3d/mesh/cython', data_mesh) ]
2021-06-15 22:00:11 +08:00
ext_modules=cythonize(extensions)
2019-08-29 23:23:35 +08:00
setup(
# Metadata
name='insightface',
version=VERSION,
author='InsightFace Contributors',
2021-05-16 09:53:01 +08:00
author_email='contact@insightface.ai',
2019-08-29 23:23:35 +08:00
url='https://github.com/deepinsight/insightface',
description='InsightFace Python Library',
2019-08-29 23:23:35 +08:00
long_description=long_description,
2021-07-07 23:58:56 +08:00
license='MIT',
2019-08-29 23:23:35 +08:00
# Package info
packages=find_packages(exclude=('docs', 'tests', 'scripts')),
2021-06-15 22:00:11 +08:00
data_files=data_files,
2019-08-29 23:23:35 +08:00
zip_safe=True,
include_package_data=True,
2021-06-15 22:00:11 +08:00
entry_points={"console_scripts": ["insightface-cli=insightface.commands.insightface_cli:main"]},
2019-08-29 23:23:35 +08:00
install_requires=requirements,
2021-06-16 22:43:11 +08:00
headers=['insightface/thirdparty/face3d/mesh/cython/mesh_core.h'],
2021-06-15 22:00:11 +08:00
ext_modules=ext_modules,
include_dirs=numpy.get_include(),
2019-08-29 23:23:35 +08:00
)
2021-05-16 09:53:01 +08:00
2021-08-23 19:33:51 +08:00
print('pypandoc enabled:', pypandoc_enabled)