forked from mantidproject/mslice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
105 lines (90 loc) · 4.19 KB
/
setup.py
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
"""
Mantid MSlice
=============
A PyQt-based version of the MSlice (http://mslice.isis.rl.ac.uk) program based
on Mantid (http://www.mantidproject.org).
"""
from __future__ import print_function
import fnmatch
import os
import sys
from setuptools import find_packages, setup
from mslice import __project_url__, __version__
# ==============================================================================
# Constants
# ==============================================================================
NAME = 'mslice'
THIS_DIR = os.path.dirname(__file__)
# ==============================================================================
# Package requirements helper
# ==============================================================================
def read_requirements_from_file(filepath):
'''Read a list of requirements from the given file and split into a
list of strings. It is assumed that the file is a flat
list with one requirement per line.
:param filepath: Path to the file to read
:return: A list of strings containing the requirements
'''
with open(filepath, 'rU') as req_file:
return req_file.readlines()
def get_package_data():
"""Return data_files in a platform dependent manner"""
package_data = []
package_dir = os.path.join(THIS_DIR, NAME)
for root, dirnames, filenames in os.walk(package_dir):
for filename in fnmatch.filter(filenames, '*.ui'):
package_data.append(os.path.relpath(os.path.join(root, filename), start=package_dir))
return {NAME: package_data}
def get_data_files():
"""Return data_files in a platform dependent manner"""
if sys.platform.startswith('linux'):
data_files = [('share/applications', ['scripts/mslice.desktop']),
('share/pixmaps', ['resources/images/mslice_logo.png'])]
else:
data_files = []
return data_files
# ==============================================================================
# Setup arguments
# ==============================================================================
setup_args = dict(name=NAME,
version=__version__,
description='Visualise and slice data from Mantid',
author='The Mantid Project',
author_email='[email protected]',
url=__project_url__,
keywords=['PyQt4'],
packages=find_packages(exclude=["misc"]),
package_data=get_package_data(),
data_files=get_data_files(),
# Install this as a directory
zip_safe=False,
classifiers=['Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Development Status :: 4 - Beta',
'Topic :: Scientific/Engineering'])
# ==============================================================================
# Setuptools deps
# ==============================================================================
# Running setup command requires the following dependencies
setup_args['setup_requires'] = read_requirements_from_file(os.path.join(THIS_DIR, 'setup-requirements.txt'))
# User installation requires the following dependencies
# PyQt4 cannot be installed from pip so they cannot be added here
install_requires = setup_args['install_requires'] = \
read_requirements_from_file(os.path.join(THIS_DIR, 'install-requirements.txt'))
# Testing requires
setup_args['tests_require'] = read_requirements_from_file(os.path.join(THIS_DIR, 'test-requirements.txt')) \
+ install_requires
# Startup scripts - these use the mantidpython wrappers so we cannot
# go through the entry_points mechanism
scripts = ['scripts/start_mslice.py']
if os.name == 'nt':
scripts.append('scripts/mslice.bat')
else:
scripts.append('scripts/mslice')
setup_args['scripts'] = scripts
# ==============================================================================
# Main setup
# ==============================================================================
setup(**setup_args)