-
Notifications
You must be signed in to change notification settings - Fork 22
/
setup.py
77 lines (70 loc) · 4.14 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
####################################################################################
# Integron_Finder - Integron Finder aims at detecting integrons in DNA sequences #
# by finding particular features of the integron: #
# - the attC sites #
# - the integrase #
# - and when possible attI site and promoters. #
# #
# Authors: Jean Cury, Bertrand Neron, Eduardo PC Rocha #
# Copyright (c) 2015 - 2024 Institut Pasteur, Paris and CNRS. #
# See the COPYRIGHT file for details #
# #
# integron_finder is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# integron_finder is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program (COPYING file). #
# If not, see <http://www.gnu.org/licenses/>. #
####################################################################################
import os.path
import setuptools
def expand_data(data_to_expand):
"""
From data structure like setup.py data_files (see http://)
[(directory/where/to/copy/the/file, [path/to/file/in/archive/file1, ...]), ...]
but instead of the original struct this one accept to specify a directory in elements to copy.
This function will generate one entry for all *content* of the directory and subdirectory
recursively, to in fine copy the tree in archive in dest on the host
the first level of directory itself is not include (which allow to rename it)
:param data_to_expand:
:type data_to_expand: list of tuple
:return: list of tuple
"""
def remove_prefix(prefix, path):
prefix = os.path.normpath(prefix)
path = os.path.normpath(path)
to_remove = len([i for i in prefix.split(os.path.sep) if i])
truncated = [i for i in path.split(os.path.sep) if i][to_remove:]
truncated = os.path.sep.join(truncated)
return truncated
data_struct = []
for base_dest_dir, src in data_to_expand:
base_dest_dir = os.path.normpath(base_dest_dir)
for one_src in src:
if os.path.isdir(one_src):
for path, _, files in os.walk(one_src):
if not files:
continue
path_2_create = remove_prefix(one_src, path)
data_struct.append((os.path.join(base_dest_dir, path_2_create), [os.path.join(path, f) for f in files]))
if os.path.isfile(one_src):
data_struct.append((base_dest_dir, [one_src]))
return data_struct
if __name__ == "__main__":
setuptools.setup(
package_data={
"integron_finder": ["data/Models/*",
"data/Functional_annotation/*"]
},
data_files=expand_data([('share/integron_finder/doc/html', ['doc/build/html']),
('share/integron_finder/doc/pdf', ['doc/build/latex/IntegronFinder.pdf'])
]),
test_suite='tests.run_tests.discover',
)