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 import arvados_version
16 version = arvados_version.get_version()
17 short_tests_only = arvados_version.short_tests_only()
18 README = os.path.join(arvados_version.SETUP_DIR, 'README.rst')
20 class BuildPython(build_py.build_py):
21 """Extend setuptools `build_py` to generate API documentation
23 This class implements a setuptools subcommand, so it follows
24 [the SubCommand protocol][1]. Most of these methods are required by that
25 protocol, except `should_run`, which we register as the subcommand
28 [1]: https://setuptools.pypa.io/en/latest/userguide/extension.html#setuptools.command.build.SubCommand
30 # This is implemented as functionality on top of `build_py`, rather than a
31 # dedicated subcommand, because that's the only way I can find to run this
32 # code during both `build` and `install`. setuptools' `install` command
33 # normally calls specific `build` subcommands directly, rather than calling
34 # the entire command, so it skips custom subcommands.
35 user_options = build_py.build_py.user_options + [
36 ('discovery-json=', 'J', 'JSON discovery document used to build pydoc'),
37 ('discovery-output=', 'O', 'relative path to write discovery document pydoc'),
40 def initialize_options(self):
41 super().initialize_options()
42 self.discovery_json = 'arvados-v1-discovery.json'
43 self.discovery_output = str(Path('arvados', 'api_resources.py'))
45 def _relative_path(self, src, optname):
47 if retval.is_absolute():
48 raise Exception(f"--{optname} should be a relative path")
52 def finalize_options(self):
53 super().finalize_options()
54 self.json_path = self._relative_path(self.discovery_json, 'discovery-json')
57 self._relative_path(self.discovery_output, 'discovery-output'),
62 import discovery2pydoc
63 arglist = ['--output-file', str(self.out_path), str(self.json_path)]
64 returncode = discovery2pydoc.main(arglist)
66 raise Exception(f"discovery2pydoc exited {returncode}")
68 def get_outputs(self):
69 retval = super().get_outputs()
70 retval.append(str(self.out_path))
73 def get_source_files(self):
74 retval = super().get_source_files()
75 retval.append(str(self.json_path))
78 def get_output_mapping(self):
79 retval = super().get_output_mapping()
80 retval[str(self.json_path)] = str(self.out_path)
84 setup(name='arvados-python-client',
86 description='Arvados client library',
87 long_description=open(README).read(),
89 author_email='info@arvados.org',
90 url="https://arvados.org",
91 download_url="https://github.com/arvados/arvados.git",
94 'build_py': BuildPython,
96 packages=find_packages(),
100 'bin/arv-keepdocker',
102 'bin/arv-migrate-docker19',
103 'bin/arv-federation-migrate',
109 ('share/doc/arvados-python-client', ['LICENSE-2.0.txt', 'README.rst']),
112 *arvados_version.iter_dependencies(version),
115 'google-api-core <2.11.0', # 2.11.0rc1 is incompatible with google-auth<2
116 'google-api-python-client >=2.1.0',
118 'httplib2 >=0.9.2, <0.20.2',
119 'protobuf <4.0.0dev',
120 'pycurl >=7.19.5.1, <7.45.0',
122 'ruamel.yaml >=0.15.54, <0.17.22',
123 'setuptools >=40.3.0',
126 python_requires="~=3.8",
128 'Programming Language :: Python :: 3',
131 tests_require=['pbr<1.7.0', 'mock>=1.0,<4', 'PyYAML', 'parameterized'],