Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

setup.py 3.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  1. #!/usr/bin/env python
  2. from setuptools import find_packages, setup
  3. import os
  4. import subprocess
  5. import time
  6. version_file = 'drct/version.py'
  7. def readme():
  8. with open('README.md', encoding='utf-8') as f:
  9. content = f.read()
  10. return content
  11. def get_git_hash():
  12. def _minimal_ext_cmd(cmd):
  13. # construct minimal environment
  14. env = {}
  15. for k in ['SYSTEMROOT', 'PATH', 'HOME']:
  16. v = os.environ.get(k)
  17. if v is not None:
  18. env[k] = v
  19. # LANGUAGE is used on win32
  20. env['LANGUAGE'] = 'C'
  21. env['LANG'] = 'C'
  22. env['LC_ALL'] = 'C'
  23. out = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
  24. return out
  25. try:
  26. out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
  27. sha = out.strip().decode('ascii')
  28. except OSError:
  29. sha = 'unknown'
  30. return sha
  31. def get_hash():
  32. if os.path.exists('.git'):
  33. sha = get_git_hash()[:7]
  34. else:
  35. sha = 'unknown'
  36. return sha
  37. def write_version_py():
  38. content = """# GENERATED VERSION FILE
  39. # TIME: {}
  40. __version__ = '{}'
  41. __gitsha__ = '{}'
  42. version_info = ({})
  43. """
  44. sha = get_hash()
  45. with open('VERSION', 'r') as f:
  46. SHORT_VERSION = f.read().strip()
  47. VERSION_INFO = ', '.join([x if x.isdigit() else f'"{x}"' for x in SHORT_VERSION.split('.')])
  48. version_file_str = content.format(time.asctime(), SHORT_VERSION, sha, VERSION_INFO)
  49. with open(version_file, 'w') as f:
  50. f.write(version_file_str)
  51. def get_version():
  52. with open(version_file, 'r') as f:
  53. exec(compile(f.read(), version_file, 'exec'))
  54. return locals()['__version__']
  55. def get_requirements(filename='requirements.txt'):
  56. here = os.path.dirname(os.path.realpath(__file__))
  57. with open(os.path.join(here, filename), 'r') as f:
  58. requires = [line.replace('\n', '') for line in f.readlines()]
  59. return requires
  60. if __name__ == '__main__':
  61. write_version_py()
  62. setup(
  63. name='drct',
  64. version=get_version(),
  65. description='DRCT',
  66. long_description=readme(),
  67. long_description_content_type='text/markdown',
  68. author='Chia-Ming Lee',
  69. author_email='zuw408421476@gmail.com',
  70. keywords='computer vision, pytorch, basicsr, image restoration, super-resolution',
  71. url='https://github.com/ming053l/DRCT',
  72. include_package_data=True,
  73. packages=find_packages(exclude=('options', 'datasets', 'experiments', 'results', 'tb_logger', 'wandb')),
  74. classifiers=[
  75. 'Development Status :: 4 - Beta',
  76. 'License :: OSI Approved :: Apache Software License',
  77. 'Operating System :: OS Independent',
  78. 'Programming Language :: Python :: 3',
  79. 'Programming Language :: Python :: 3.7',
  80. 'Programming Language :: Python :: 3.8',
  81. ],
  82. license='MIT License',
  83. setup_requires=['cython', 'numpy'],
  84. install_requires=get_requirements(),
  85. zip_safe=False)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...