2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: Apache-2.0
6 from __future__ import absolute_import
7 import distutils.command.build
13 from pathlib import Path
14 from setuptools import setup, find_packages
16 SETUP_DIR = os.path.dirname(__file__) or '.'
17 README = os.path.join(SETUP_DIR, 'README.rst')
19 import arvados_version
20 version = arvados_version.get_version(SETUP_DIR, "arvados")
22 short_tests_only = False
23 if '--short-tests-only' in sys.argv:
24 short_tests_only = True
25 sys.argv.remove('--short-tests-only')
27 class BuildDiscoveryPydoc(setuptools.Command):
28 """Run discovery2pydoc as part of the build process
30 This class implements a setuptools subcommand, so it follows
31 [the SubCommand protocol][1]. Most of these methods are required by that
32 protocol, except `should_run`, which we register as the subcommand
35 [1]: https://setuptools.pypa.io/en/latest/userguide/extension.html#setuptools.command.build.SubCommand
37 NAME = 'discovery2pydoc'
38 description = "build skeleton Python from the Arvados discovery document"
41 ('discovery-json=', 'J', 'JSON discovery document used to build pydoc'),
42 ('discovery-output=', 'O', 'relative path to write discovery document pydoc'),
45 def initialize_options(self):
47 self.discovery_json = 'arvados-v1-discovery.json'
48 self.discovery_output = str(Path('arvados', 'api_resources.py'))
50 def _relative_path(self, src, optname):
52 if retval.is_absolute():
53 raise Exception(f"--{optname} should be a relative path")
57 def finalize_options(self):
58 # Set self.build_lib to match whatever the build_py subcommand uses.
59 self.set_undefined_options('build_py', ('build_lib', 'build_lib'))
60 self.json_path = self._relative_path(self.discovery_json, 'discovery-json')
63 self._relative_path(self.discovery_output, 'discovery-output'),
67 import discovery2pydoc
68 self.mkpath(str(self.out_path.parent))
69 arglist = ['--output-file', str(self.out_path), str(self.json_path)]
70 returncode = discovery2pydoc.main(arglist)
72 raise Exception(f"discovery2pydoc exited {returncode}")
77 def get_outputs(self):
78 return [str(self.out_path)]
80 def get_source_files(self):
81 return [str(self.json_path)]
83 def get_output_mapping(self):
85 str(self.json_path): str(self.out_path),
87 # Run discovery2pydoc as the first subcommand of build.
88 distutils.command.build.build.sub_commands.insert(
89 0, (BuildDiscoveryPydoc.NAME, BuildDiscoveryPydoc.should_run),
92 setup(name='arvados-python-client',
94 description='Arvados client library',
95 long_description=open(README).read(),
97 author_email='info@arvados.org',
98 url="https://arvados.org",
99 download_url="https://github.com/arvados/arvados.git",
100 license='Apache 2.0',
102 BuildDiscoveryPydoc.NAME: BuildDiscoveryPydoc,
104 packages=find_packages(),
108 'bin/arv-keepdocker',
110 'bin/arv-migrate-docker19',
111 'bin/arv-federation-migrate',
117 ('share/doc/arvados-python-client', ['LICENSE-2.0.txt', 'README.rst']),
122 'google-api-core <2.11.0', # 2.11.0rc1 is incompatible with google-auth<2
123 'google-api-python-client >=2.1.0',
125 'httplib2 >=0.9.2, <0.20.2',
126 'pycurl >=7.19.5.1, <7.45.0',
127 'ruamel.yaml >=0.15.54, <0.17.22',
128 'setuptools>=40.3.0',
134 'Programming Language :: Python :: 3',
137 tests_require=['pbr<1.7.0', 'mock>=1.0,<4', 'PyYAML', 'parameterized'],