1 | |||
2 | from setuptools import setup, find_packages, Command, Extension |
||
3 | import os |
||
4 | import io |
||
5 | import sys |
||
6 | from shutil import rmtree |
||
7 | |||
8 | |||
9 | # Package meta-data. |
||
10 | NAME = 'polarpy' |
||
11 | DESCRIPTION = 'Tools and 3ML plugin for the POLAR instrument' |
||
12 | URL = 'https://github.com/grburgess/polarpy' |
||
13 | EMAIL = '[email protected]' |
||
14 | AUTHOR = 'J. Michael Burgess' |
||
15 | REQUIRES_PYTHON = '>=2.7.0' |
||
16 | VERSION = None |
||
17 | |||
18 | REQUIRED = [ |
||
19 | 'numpy', |
||
20 | 'scipy', |
||
21 | 'ipython', |
||
22 | 'h5py', |
||
23 | 'astropy', |
||
24 | 'ipywidgets', |
||
25 | |||
26 | ] |
||
27 | |||
28 | # What packages are optional? |
||
29 | EXTRAS = { |
||
30 | } |
||
31 | |||
32 | |||
33 | here = os.path.abspath(os.path.dirname(__file__)) |
||
34 | |||
35 | try: |
||
36 | with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: |
||
37 | long_description = '\n' + f.read() |
||
38 | except FileNotFoundError: |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
39 | long_description = DESCRIPTION |
||
40 | |||
41 | # Load the package's __version__.py module as a dictionary. |
||
42 | about = {} |
||
43 | if not VERSION: |
||
44 | with open(os.path.join(here, NAME, '__version__.py')) as f: |
||
45 | exec(f.read(), about) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
46 | else: |
||
47 | about['__version__'] = VERSION |
||
48 | |||
49 | |||
50 | class UploadCommand(Command): |
||
51 | """Support setup.py upload.""" |
||
52 | |||
53 | description = 'Build and publish the package.' |
||
54 | user_options = [] |
||
55 | |||
56 | @staticmethod |
||
57 | def status(s): |
||
58 | """Prints things in bold.""" |
||
59 | print('\033[1m{0}\033[0m'.format(s)) |
||
60 | |||
61 | def initialize_options(self): |
||
62 | pass |
||
63 | |||
64 | def finalize_options(self): |
||
65 | pass |
||
66 | |||
67 | def run(self): |
||
68 | try: |
||
69 | self.status('Removing previous builds...') |
||
70 | rmtree(os.path.join(here, 'dist')) |
||
71 | except OSError: |
||
72 | pass |
||
73 | |||
74 | self.status('Building Source and Wheel (universal) distribution...') |
||
75 | os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable)) |
||
76 | |||
77 | self.status('Uploading the package to PyPI via Twine...') |
||
78 | os.system('twine upload dist/*') |
||
79 | |||
80 | self.status('Pushing git tags...') |
||
81 | os.system('git tag v{0}'.format(about['__version__'])) |
||
82 | os.system('git push --tags') |
||
83 | |||
84 | sys.exit() |
||
85 | |||
86 | |||
87 | |||
88 | |||
89 | |||
90 | # Create list of data files |
||
91 | def find_data_files(directory): |
||
92 | |||
93 | paths = [] |
||
94 | |||
95 | for (path, directories, filenames) in os.walk(directory): |
||
96 | |||
97 | for filename in filenames: |
||
98 | |||
99 | paths.append(os.path.join('..', path, filename)) |
||
100 | |||
101 | return paths |
||
102 | |||
103 | extra_files = find_data_files('polarpy/data') |
||
104 | |||
105 | |||
106 | setup( |
||
107 | |||
108 | name=NAME, |
||
109 | version=about['__version__'], |
||
110 | description=DESCRIPTION, |
||
111 | long_description=long_description, |
||
112 | long_description_content_type='text/markdown', |
||
113 | author=AUTHOR, |
||
114 | author_email=EMAIL, |
||
115 | python_requires=REQUIRES_PYTHON, |
||
116 | url=URL, |
||
117 | packages=find_packages(exclude=('tests',)), |
||
118 | install_requires=REQUIRED, |
||
119 | extras_require=EXTRAS, |
||
120 | include_package_data=True, |
||
121 | package_data={'': extra_files, }, |
||
122 | license='BSD', |
||
123 | cmdclass={ |
||
124 | 'upload': UploadCommand,}, |
||
125 | ) |
||
126 | |||
127 | |||
128 | |||
129 | # # Create list of data files |
||
130 | # def find_data_files(directory): |
||
131 | |||
132 | # paths = [] |
||
133 | |||
134 | # for (path, directories, filenames) in os.walk(directory): |
||
135 | |||
136 | # for filename in filenames: |
||
137 | |||
138 | # paths.append(os.path.join('..', path, filename)) |
||
139 | |||
140 | # return paths |
||
141 | |||
142 | # #extra_files = find_data_files('pyspi/data') |
||
143 | |||
144 | # setup( |
||
145 | |||
146 | # name="polarpy", |
||
147 | # packages=[ |
||
148 | # 'polarpy', |
||
149 | # # 'pyspi/io', |
||
150 | # # 'pyspi/utils', |
||
151 | # # 'pyspi/io' |
||
152 | |||
153 | # ], |
||
154 | # version='v1.0a', |
||
155 | # license='BSD', |
||
156 | # description='A python interface for POLAR', |
||
157 | # author='J. Michael Burgess', |
||
158 | # author_email='[email protected]', |
||
159 | # # url = 'https://github.com/grburgess/pychangcooper', |
||
160 | # # download_url='https://github.com/grburgess/pychangcooper/archive/1.1.2.tar.gz', |
||
161 | |||
162 | # # package_data={'': extra_files, }, |
||
163 | # # include_package_data=True, |
||
164 | |||
165 | # requires=[ |
||
166 | # 'numpy', |
||
167 | # 'matplotlib', |
||
168 | # 'h5py', |
||
169 | # 'pandas', |
||
170 | # 'scipy' |
||
171 | |||
172 | # ], |
||
173 | # ) |
||
174 |