-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
60 lines (52 loc) · 1.88 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
#!/usr/bin/env python3
from distutils import log
from distutils.core import setup
from setuptools.command.install import install
import os
import sys
from setuptools.command.install_scripts import install_scripts
class OverrideInstall(install):
"""
Adapted from:
https://stackoverflow.com/questions/5932804/set-file-permissions-in-setup-py-file/25761434
"""
def run(self):
uid, gid = 0, 0 # root user
#mode = 0o755
set_data_dir = False
install.run(self) # run parent class method
for filepath in self.get_outputs():
path = os.path.dirname(filepath)
#log.info('*** {}'.format(filepath))
if path.endswith('ref_genomes'):
mode = 0o644
log.info('Changing permissions of {0} to {1:o}'.format(filepath, mode))
os.chmod(filepath, mode)
elif '/bin/' in path:
mode = 0o755
log.info('Changing permissions of {0} to {1:o}'.format(filepath, mode))
os.chmod(filepath, mode)
data_files = ['ref_genomes/K03455.fasta', 'ref_genomes/M33262.fasta',
'ref_genomes/HIV1_Mgroup.fasta']
# identify platform
if sys.platform.startswith("linux"):
mafft_dir = 'poplars/bin/mafft-linux64/'
elif sys.platform.startswith("win"):
mafft_dir = 'poplars/bin/mafft-win/'
elif sys.platform == "darwin":
mafft_dir = 'poplars/bin/mafft-mac/'
else:
sys.stderr.write("Warning: failed to recognize platform.")
sys.exit()
# generate listing of MAFFT-associated files for user's platform
mafft_files = []
for root, dirs, files in os.walk(mafft_dir):
if len(files) > 0:
for file in files:
mafft_files.append(os.path.join(root.replace('poplars/', ''), file))
setup(
name='poplars',
packages=['poplars'],
package_data={'poplars': mafft_files + data_files},
cmdclass={'install': OverrideInstall}
)