Upload setup.py
Browse files
setup.py
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
|
3 |
+
from setuptools import find_packages, setup
|
4 |
+
|
5 |
+
import os
|
6 |
+
import subprocess
|
7 |
+
import time
|
8 |
+
|
9 |
+
version_file = 'realesrgan/version.py'
|
10 |
+
|
11 |
+
|
12 |
+
def readme():
|
13 |
+
with open('README.md', encoding='utf-8') as f:
|
14 |
+
content = f.read()
|
15 |
+
return content
|
16 |
+
|
17 |
+
|
18 |
+
def get_git_hash():
|
19 |
+
|
20 |
+
def _minimal_ext_cmd(cmd):
|
21 |
+
# construct minimal environment
|
22 |
+
env = {}
|
23 |
+
for k in ['SYSTEMROOT', 'PATH', 'HOME']:
|
24 |
+
v = os.environ.get(k)
|
25 |
+
if v is not None:
|
26 |
+
env[k] = v
|
27 |
+
# LANGUAGE is used on win32
|
28 |
+
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 out
|
33 |
+
|
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 sha
|
41 |
+
|
42 |
+
|
43 |
+
def get_hash():
|
44 |
+
if os.path.exists('.git'):
|
45 |
+
sha = get_git_hash()[:7]
|
46 |
+
else:
|
47 |
+
sha = 'unknown'
|
48 |
+
|
49 |
+
return sha
|
50 |
+
|
51 |
+
|
52 |
+
def write_version_py():
|
53 |
+
content = """# GENERATED VERSION FILE
|
54 |
+
# TIME: {}
|
55 |
+
__version__ = '{}'
|
56 |
+
__gitsha__ = '{}'
|
57 |
+
version_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 |
+
|
69 |
+
def get_version():
|
70 |
+
with open(version_file, 'r') as f:
|
71 |
+
exec(compile(f.read(), version_file, 'exec'))
|
72 |
+
return locals()['__version__']
|
73 |
+
|
74 |
+
|
75 |
+
def 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 requires
|
80 |
+
|
81 |
+
|
82 |
+
if __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)
|