2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: Apache-2.0
6 from __future__ import absolute_import
11 from pathlib import Path
12 from setuptools import setup, find_packages
13 from setuptools.command import build_py
15 SETUP_DIR = os.path.dirname(__file__) or '.'
16 README = os.path.join(SETUP_DIR, 'README.rst')
18 import arvados_version
19 version = arvados_version.get_version(SETUP_DIR, "arvados")
21 short_tests_only = False
22 if '--short-tests-only' in sys.argv:
23 short_tests_only = True
24 sys.argv.remove('--short-tests-only')
26 class BuildPython(build_py.build_py):
27 """Extend setuptools `build_py` to generate API documentation
29 This class implements a setuptools subcommand, so it follows
30 [the SubCommand protocol][1]. Most of these methods are required by that
31 protocol, except `should_run`, which we register as the subcommand
34 [1]: https://setuptools.pypa.io/en/latest/userguide/extension.html#setuptools.command.build.SubCommand
36 # This is implemented as functionality on top of `build_py`, rather than a
37 # dedicated subcommand, because that's the only way I can find to run this
38 # code during both `build` and `install`. setuptools' `install` command
39 # normally calls specific `build` subcommands directly, rather than calling
40 # the entire command, so it skips custom subcommands.
41 user_options = build_py.build_py.user_options + [
42 ('discovery-json=', 'J', 'JSON discovery document used to build pydoc'),
43 ('discovery-output=', 'O', 'relative path to write discovery document pydoc'),
46 def initialize_options(self):
47 super().initialize_options()
48 self.discovery_json = 'arvados-v1-discovery.json'
49 self.discovery_output = str(Path('arvados', 'api_resources.py'))
51 def _relative_path(self, src, optname):
53 if retval.is_absolute():
54 raise Exception(f"--{optname} should be a relative path")
58 def finalize_options(self):
59 super().finalize_options()
60 self.json_path = self._relative_path(self.discovery_json, 'discovery-json')
63 self._relative_path(self.discovery_output, 'discovery-output'),
68 import discovery2pydoc
69 arglist = ['--output-file', str(self.out_path), str(self.json_path)]
70 returncode = discovery2pydoc.main(arglist)
72 raise Exception(f"discovery2pydoc exited {returncode}")
74 def get_outputs(self):
75 retval = super().get_outputs()
76 retval.append(str(self.out_path))
79 def get_source_files(self):
80 retval = super().get_source_files()
81 retval.append(str(self.json_path))
84 def get_output_mapping(self):
85 retval = super().get_output_mapping()
86 retval[str(self.json_path)] = str(self.out_path)
90 setup(name='arvados-python-client',
92 description='Arvados client library',
93 long_description=open(README).read(),
95 author_email='info@arvados.org',
96 url="https://arvados.org",
97 download_url="https://github.com/arvados/arvados.git",
100 'build_py': BuildPython,
102 packages=find_packages(),
106 'bin/arv-keepdocker',
108 'bin/arv-migrate-docker19',
109 'bin/arv-federation-migrate',
115 ('share/doc/arvados-python-client', ['LICENSE-2.0.txt', 'README.rst']),
120 'google-api-core <2.11.0', # 2.11.0rc1 is incompatible with google-auth<2
121 'google-api-python-client >=2.1.0',
123 'httplib2 >=0.9.2, <0.20.2',
124 'pycurl >=7.19.5.1, <7.45.0',
125 'ruamel.yaml >=0.15.54, <0.17.22',
126 'setuptools >=40.3.0',
127 # As of 4.8.0rc1, typing_extensions does not parse in Python 3.7
128 'typing_extensions >=3.7.4, <4.8; python_version<"3.8"',
130 'protobuf <4.0.0dev',
132 'setuptools >=40.3.0',
133 'dataclasses; python_version<"3.7"',
136 'Programming Language :: Python :: 3',
139 tests_require=['pbr<1.7.0', 'mock>=1.0,<4', 'PyYAML', 'parameterized'],