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")
20 short_tests_only = arvados_version.short_tests_only()
22 class BuildPython(build_py.build_py):
23 """Extend setuptools `build_py` to generate API documentation
25 This class implements a setuptools subcommand, so it follows
26 [the SubCommand protocol][1]. Most of these methods are required by that
27 protocol, except `should_run`, which we register as the subcommand
30 [1]: https://setuptools.pypa.io/en/latest/userguide/extension.html#setuptools.command.build.SubCommand
32 # This is implemented as functionality on top of `build_py`, rather than a
33 # dedicated subcommand, because that's the only way I can find to run this
34 # code during both `build` and `install`. setuptools' `install` command
35 # normally calls specific `build` subcommands directly, rather than calling
36 # the entire command, so it skips custom subcommands.
37 user_options = build_py.build_py.user_options + [
38 ('discovery-json=', 'J', 'JSON discovery document used to build pydoc'),
39 ('discovery-output=', 'O', 'relative path to write discovery document pydoc'),
42 def initialize_options(self):
43 super().initialize_options()
44 self.discovery_json = 'arvados-v1-discovery.json'
45 self.discovery_output = str(Path('arvados', 'api_resources.py'))
47 def _relative_path(self, src, optname):
49 if retval.is_absolute():
50 raise Exception(f"--{optname} should be a relative path")
54 def finalize_options(self):
55 super().finalize_options()
56 self.json_path = self._relative_path(self.discovery_json, 'discovery-json')
59 self._relative_path(self.discovery_output, 'discovery-output'),
64 import discovery2pydoc
65 arglist = ['--output-file', str(self.out_path), str(self.json_path)]
66 returncode = discovery2pydoc.main(arglist)
68 raise Exception(f"discovery2pydoc exited {returncode}")
70 def get_outputs(self):
71 retval = super().get_outputs()
72 retval.append(str(self.out_path))
75 def get_source_files(self):
76 retval = super().get_source_files()
77 retval.append(str(self.json_path))
80 def get_output_mapping(self):
81 retval = super().get_output_mapping()
82 retval[str(self.json_path)] = str(self.out_path)
86 setup(name='arvados-python-client',
88 description='Arvados client library',
89 long_description=open(README).read(),
91 author_email='info@arvados.org',
92 url="https://arvados.org",
93 download_url="https://github.com/arvados/arvados.git",
96 'build_py': BuildPython,
98 packages=find_packages(),
102 'bin/arv-keepdocker',
104 'bin/arv-migrate-docker19',
105 'bin/arv-federation-migrate',
111 ('share/doc/arvados-python-client', ['LICENSE-2.0.txt', 'README.rst']),
116 'google-api-core <2.11.0', # 2.11.0rc1 is incompatible with google-auth<2
117 'google-api-python-client >=2.1.0',
119 'httplib2 >=0.9.2, <0.20.2',
120 'protobuf <4.0.0dev',
121 'pycurl >=7.19.5.1, <7.45.0',
123 'ruamel.yaml >=0.15.54, <0.17.22',
124 'setuptools >=40.3.0',
127 python_requires="~=3.8",
129 'Programming Language :: Python :: 3',
132 tests_require=['pbr<1.7.0', 'mock>=1.0,<4', 'PyYAML', 'parameterized'],