1 | """ |
---|
2 | ndg.dx.server setup script. |
---|
3 | |
---|
4 | @author: Stephen Pascoe |
---|
5 | """ |
---|
6 | |
---|
7 | import ez_setup; ez_setup.use_setuptools() |
---|
8 | |
---|
9 | from setuptools import setup, find_packages |
---|
10 | |
---|
11 | from setuptools.command.test import test |
---|
12 | class ndgTest(test): |
---|
13 | description = "create a temporary NDG environment before testing" |
---|
14 | |
---|
15 | user_options = [ |
---|
16 | ('test-home', 'h', "directory to create the NDG environment"), |
---|
17 | ('test-conf', 'c', "configuration file to base NDG_HOME/ndg.conf on" |
---|
18 | " (default: egg:ndg.dx.server.test.server.conf)"), |
---|
19 | ] + test.user_options |
---|
20 | |
---|
21 | def initialize_options(self): |
---|
22 | test.initialize_options(self) |
---|
23 | self.test_home = None |
---|
24 | self.test_conf = None |
---|
25 | |
---|
26 | def finalize_options(self): |
---|
27 | test.finalize_options(self) |
---|
28 | if not self.test_home: |
---|
29 | self.test_home = './test_ndg_home' |
---|
30 | |
---|
31 | def run(self): |
---|
32 | import os, pkg_resources, shutil, ConfigParser |
---|
33 | |
---|
34 | # Wipe clean self.test_home |
---|
35 | if os.path.exists(self.test_home): |
---|
36 | shutil.rmtree(self.test_home) |
---|
37 | os.mkdir(self.test_home) |
---|
38 | # Set NDG_HOME to be picked up by ndg.utils.config |
---|
39 | os.environ['NDG_HOME'] = self.test_home |
---|
40 | |
---|
41 | # At this point it is safe to import the configuration. |
---|
42 | # get global configuration (this will read /etc/ndg.conf) |
---|
43 | from ndg.utils.config import config |
---|
44 | from ndg.dx.server.MakeConfig import makeConfig |
---|
45 | |
---|
46 | # parse selected test_conf |
---|
47 | if self.test_conf: |
---|
48 | config.read(self.test_conf) |
---|
49 | else: |
---|
50 | fp = pkg_resources.resource_stream('ndg.dx.server.test', 'server.conf') |
---|
51 | config.readfp(fp) |
---|
52 | |
---|
53 | # Set BASEDIR and create the dxs directory |
---|
54 | config.set('ndg.dx.server', 'basedir', os.path.join(self.test_home, 'dxs')) |
---|
55 | makeConfig() |
---|
56 | |
---|
57 | # Run the tests |
---|
58 | return test.run(self) |
---|
59 | |
---|
60 | |
---|
61 | setup( |
---|
62 | name = 'ndg_dx_server', |
---|
63 | version = '0.3.5a1', |
---|
64 | description = 'Python Data Extractor Server', |
---|
65 | author = 'Ag Stephens', |
---|
66 | author_email = 'a.stephens@rl.ac.uk', |
---|
67 | url = 'http://ndg.nerc.ac.uk/DataExtractor', |
---|
68 | license = """Copyright (C) 2004 CCLRC & NERC( Natural Environment Research Council ). |
---|
69 | This software may be distributed under the terms of the |
---|
70 | Q Public License, version 1.0 or later. http://ndg.nerc.ac.uk/public_docs/QP""", |
---|
71 | |
---|
72 | packages = find_packages(), |
---|
73 | namespace_packages = ['ndg', 'ndg.dx'], |
---|
74 | |
---|
75 | install_requires = ['ZSI==2.0rc3', 'cdat_lite', |
---|
76 | 'ndg_utils'], |
---|
77 | entry_points = ''' |
---|
78 | [console_scripts] |
---|
79 | addDatasetGroup = ndg.dx.server.scripts.addDatasetGroup:main |
---|
80 | addDataset = ndg.dx.server.scripts.addDataset:main |
---|
81 | addWholeCatalogue = ndg.dx.server.scripts.addWholeCatalogue:main |
---|
82 | cleanOutDatasetXMLFile = ndg.dx.server.scripts.cleanOutDatasetXMLFile:main |
---|
83 | DXWSInterface = ndg.dx.server.scripts.DXWSInterface:main |
---|
84 | fixSession = ndg.dx.server.scripts.fixSession:main |
---|
85 | removeDataset = ndg.dx.server.scripts.removeDataset:main |
---|
86 | showSession = ndg.dx.server.scripts.showSession:main |
---|
87 | ''', |
---|
88 | |
---|
89 | include_package_data = True, |
---|
90 | |
---|
91 | test_suite = 'ndg.dx.server.test.test_suite', |
---|
92 | cmdclass = {'test': ndgTest}, |
---|
93 | ) |
---|
94 | |
---|