-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
138 lines (109 loc) · 4.47 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# -*- coding: utf-8 -*-
__revision__ = "$Id: $"
import sys
import os
from setuptools import setup, find_packages
# from __future__ import print_function
# The metainfo files must contains 'metainfo.ini'
# version, release, project, name, namespace, pkg_name,
# description, long_description,
# authors, authors_email, url and license
# * version is 0.8.0 and release 0.8
# * project must be in [openalea, vplants, alinea]
# * name is the full name (e.g., VPlants.RhizoScan) whereas pkg_name is only
# 'rhizoscan'
# name will determine the name of the egg, as well as the name of
# the pakage directory under Python/lib/site-packages). It is also
# the one to use in setup script of other packages to declare
# a dependency to this package).
# (The version number is used by deploy to detect UPDATES)
import ConfigParser
conf = ConfigParser.RawConfigParser()
conf.read('metainfo.ini')
metadata = dict([(key, conf.get('metainfo', key))
for key in conf.options('metainfo')])
# from openalea.deploy.metainfo import read_metainfo
#
# metadata = read_metainfo('metainfo.ini', verbose=True)
# for key,value in zip(metadata.keys(), metadata.values()):
# exec("%s = '%s'" % (key, value))
print('*** Installing the following package: ***')
for key, value in metadata.items():
key = str(key)
print '\t', key + ':\t', value
# Packages list, namespace and root directory of packages
#namespace = metadata['namespace']
pkg_root_dir = 'src'
packages = [pkg for pkg in find_packages(pkg_root_dir)]
top_pkgs = [pkg for pkg in packages if len(pkg.split('.')) < 2]
package_dir = dict([('', 'src')])
# setup dependencies stuff
setup_requires = ['openalea.deploy']
install_requires = []
dependency_links = ['http://openalea.gforge.inria.fr/pi']
# generate openalea wrapper and entry points
# ------------------------------------------
src_abs_path = os.path.abspath('src')
sys.path.insert(0, src_abs_path)
entry_points = {'gui_scripts':
['rhizoscaneditor = rhizoscan.root.editor:main']
}
entry_points['console_scripts'] = ['rhizodata = rhizodata.rhizodata:main']
try:
import rhizoscan
from rhizoscan.workflow.openalea import wrap_package, clean_wralea_directory
# clear previously generated wralea folder
clean_wralea_directory(os.path.join(src_abs_path,'rhizoscan_wralea'))
# generate wralea packages
entry = wrap_package(rhizoscan, entry_name='rhizoscan', verbose=0)
print('\n wralea entry found:\n' + '\n'.join(entry) + '\n')
if entry:
entry_points['wralea'] = entry
except ImportError as e:
import sys, traceback
exc_type, exc_value, exc_traceback = sys.exc_info()
print("********************************************************")
print(" WARNING:")
print("The wralea generation has failed due to an import error:")
traceback.print_exception(exc_type, exc_value, exc_traceback)
print("********************************************************")
# add OpenAleaLab RootEditor widget
entry_points['oalab.applet'] = [
'RootEditorApp = rhizoscan.root.editor.plugins:RootEditorWidgetPlugin',
],
# 'SeedMapEditor = rhizoscan.root.editor.plugins:SeedMapWidgetPlugin'],
entry_points['oalab.lab'] = [
'RhizoScanLab = rhizoscan.root.editor.plugins:RhizoScanLab',
]
# call setup
# ----------
setup(
name = metadata['name'],
version = metadata['version'],
description = metadata['description'],
long_description= metadata['long_description'],
author = metadata['authors'],
author_email = metadata['authors_email'],
url = metadata['url'],
license = metadata['license'],
keywords = metadata.get('keywords',''),
# package installation
packages=packages,
package_dir=package_dir,
create_namespaces=False,
zip_safe=False,
# Dependencies
setup_requires=setup_requires,
install_requires=install_requires,
dependency_links=dependency_links,
# Eventually include data in your package
# (flowing is to include all versioned files other than .py)
include_package_data=True,
# (you can provide an exclusion dictionary named exclude_package_data to remove parasites).
# alternatively to global inclusion, list the file to include
package_data={'': ['*.png', '*.jpg', '*.data', '*.ini'], },
share_dirs={'test': 'test'},
# postinstall_scripts = ['',],
# Declare scripts and wralea as entry_points (extensions) of your package
entry_points = entry_points,
)