Reevee/ohayo_face_style
0
1#!/usr/bin/env python2 3from setuptools import find_packages, setup4 5import os6import subprocess7import time8 9version_file = 'realesrgan/version.py'10 11 12def readme():13 with open('README.md', encoding='utf-8') as f:14 content = f.read()15 return content16 17 18def get_git_hash():19 20 def _minimal_ext_cmd(cmd):21 # construct minimal environment22 env = {}23 for k in ['SYSTEMROOT', 'PATH', 'HOME']:24 v = os.environ.get(k)25 if v is not None:26 env[k] = v27 # LANGUAGE is used on win3228 env['LANGUAGE'] = 'C'29 env['LANG'] = 'C'30 env['LC_ALL'] = 'C'31 out = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env).communicate()[0]32 return out33 34 try:35 out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])36 sha = out.strip().decode('ascii')37 except OSError:38 sha = 'unknown'39 40 return sha41 42 43def get_hash():44 if os.path.exists('.git'):45 sha = get_git_hash()[:7]46 else:47 sha = 'unknown'48 49 return sha50 51 52def write_version_py():53 content = """# GENERATED VERSION FILE54# TIME: {}55__version__ = '{}'56__gitsha__ = '{}'57version_info = ({})58"""59 sha = get_hash()60 with open('VERSION', 'r') as f:61 SHORT_VERSION = f.read().strip()62 VERSION_INFO = ', '.join([x if x.isdigit() else f'"{x}"' for x in SHORT_VERSION.split('.')])63 64 version_file_str = content.format(time.asctime(), SHORT_VERSION, sha, VERSION_INFO)65 with open(version_file, 'w') as f:66 f.write(version_file_str)67 68 69def get_version():70 with open(version_file, 'r') as f:71 exec(compile(f.read(), version_file, 'exec'))72 return locals()['__version__']73 74 75def get_requirements(filename='requirements.txt'):76 here = os.path.dirname(os.path.realpath(__file__))77 with open(os.path.join(here, filename), 'r') as f:78 requires = [line.replace('\n', '') for line in f.readlines()]79 return requires80 81 82if __name__ == '__main__':83 write_version_py()84 setup(85 name='realesrgan',86 version=get_version(),87 description='Real-ESRGAN aims at developing Practical Algorithms for General Image Restoration',88 long_description=readme(),89 long_description_content_type='text/markdown',90 author='Xintao Wang',91 author_email='xintao.wang@outlook.com',92 keywords='computer vision, pytorch, image restoration, super-resolution, esrgan, real-esrgan',93 url='https://github.com/xinntao/Real-ESRGAN',94 include_package_data=True,95 packages=find_packages(exclude=('options', 'datasets', 'experiments', 'results', 'tb_logger', 'wandb')),96 classifiers=[97 'Development Status :: 4 - Beta',98 'License :: OSI Approved :: Apache Software License',99 'Operating System :: OS Independent',100 'Programming Language :: Python :: 3',101 'Programming Language :: Python :: 3.7',102 'Programming Language :: Python :: 3.8',103 ],104 license='BSD-3-Clause License',105 setup_requires=['cython', 'numpy'],106 install_requires=get_requirements(),107 zip_safe=False)108 