This repository was archived by the owner on Mar 3, 2023. It is now read-only.
forked from ismrmrd/ismrmrd-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
85 lines (74 loc) · 2.74 KB
/
setup.py
File metadata and controls
85 lines (74 loc) · 2.74 KB
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
import os
from setuptools import setup
from distutils.command.build import build
from distutils.command.build_py import build_py
import pyxb.binding.generate
import logging
logging.basicConfig()
log_ = logging.getLogger(__name__)
schema_file = os.path.join('schema','ismrmrd.xsd')
class my_build(build):
def run(self):
self.run_command("build_py")
build.run(self)
class my_build_py(build_py):
def run(self):
# honor the --dry-run flag
if not self.dry_run:
outloc = self.get_package_dir('ismrmrd')
modname = 'xsd'
modfile = os.path.join(outloc, '%s.py' % modname)
generate_schema(schema_file, modname, outloc)
with open(modfile, 'a') as f:
f.write('\nimport pyxb.utils.domutils\n' +
'pyxb.utils.domutils.BindingDOMSupport.SetDefaultNamespace(Namespace)\n')
# distutils uses old-style classes, so no super()
build_py.run(self)
def generate_schema(schema_filename, module_name, output_directory):
""" Extracted from the `pyxbgen` tool provided by
PyXB (http://pyxb.sourceforge.net/) """
generator = pyxb.binding.generate.Generator()
parser = generator.optionParser()
(options, args) = parser.parse_args(args=[
'-u', '%s' % schema_filename,
'-m', module_name,
'--binding-root=%s' % output_directory
])
generator.applyOptionValues(options, args)
generator.resolveExternalSchema()
if 0 == len(generator.namespaces()):
raise RuntimeError("error creating PyXB generator")
# Save binding source first, so name-in-binding is stored in the
# parsed schema file
try:
tns = generator.namespaces().pop()
modules = generator.bindingModules()
top_module = None
path_dirs = set()
for m in modules:
m.writeToModuleFile()
generator.writeNamespaceArchive()
except Exception as e:
raise RuntimeError("error generating bindings (%s)" % e)
setup(
name='ismrmrd',
version='1.6.5',
author='ISMRMRD Developers',
author_email='[email protected]',
description='Python implementation of the ISMRMRD',
license='Public Domain',
keywords='ismrmrd',
url='https://ismrmrd.github.io',
packages=['ismrmrd'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'License :: Public Domain',
'Operating System :: OS Independent',
'Topic :: Scientific/Engineering :: Medical Science Apps.'
],
install_requires=['PyXB', 'numpy', 'h5py>=2.3'],
setup_requires=['nose>=1.0', 'pyxb'],
test_suite='nose.collector',
cmdclass={'build_py':my_build_py,'build':my_build}
)