[arvados] updated: 2.6.0-18-gbce5560c0
git repository hosting
git at public.arvados.org
Fri Apr 14 18:11:50 UTC 2023
Summary of changes:
sdk/python/discovery2pydoc.py | 13 +++++++++--
sdk/python/setup.py | 54 +++++++++++++++++++++----------------------
2 files changed, 37 insertions(+), 30 deletions(-)
via bce5560c00bc5cb6301da0ddd82f3af8a4b24778 (commit)
via e0287beae4381ac82334a6c3859884bcbadfb285 (commit)
via aa369aa06f977a6a3c114e11e472a0ddeb2a07c9 (commit)
via 571e94931049a757bed2971084f7d6bf7cf6cb6e (commit)
from 7afaea0c59c4a2da152de652870f9b0e457f74cc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit bce5560c00bc5cb6301da0ddd82f3af8a4b24778
Author: Brett Smith <brett.smith at curii.com>
Date: Fri Apr 14 14:03:45 2023 -0400
18799: Make the PySDK's build subcommand extend build_py
See the added comments for rationale.
Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
index 910757817..1214d9ffa 100644
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -4,14 +4,13 @@
# SPDX-License-Identifier: Apache-2.0
from __future__ import absolute_import
-import distutils.command.build
import os
-import setuptools
import sys
import re
from pathlib import Path
from setuptools import setup, find_packages
+from setuptools.command import build_py
SETUP_DIR = os.path.dirname(__file__) or '.'
README = os.path.join(SETUP_DIR, 'README.rst')
@@ -24,8 +23,8 @@ if '--short-tests-only' in sys.argv:
short_tests_only = True
sys.argv.remove('--short-tests-only')
-class BuildDiscoveryPydoc(setuptools.Command):
- """Run discovery2pydoc as part of the build process
+class BuildPython(build_py.build_py):
+ """Extend setuptools `build_py` to generate API documentation
This class implements a setuptools subcommand, so it follows
[the SubCommand protocol][1]. Most of these methods are required by that
@@ -34,16 +33,18 @@ class BuildDiscoveryPydoc(setuptools.Command):
[1]: https://setuptools.pypa.io/en/latest/userguide/extension.html#setuptools.command.build.SubCommand
"""
- NAME = 'discovery2pydoc'
- description = "build skeleton Python from the Arvados discovery document"
- editable_mode = False
- user_options = [
+ # This is implemented as functionality on top of `build_py`, rather than a
+ # dedicated subcommand, because that's the only way I can find to run this
+ # code during both `build` and `install`. setuptools' `install` command
+ # normally calls specific `build` subcommands directly, rather than calling
+ # the entire command, so it skips custom subcommands.
+ user_options = build_py.build_py.user_options + [
('discovery-json=', 'J', 'JSON discovery document used to build pydoc'),
('discovery-output=', 'O', 'relative path to write discovery document pydoc'),
]
def initialize_options(self):
- self.build_lib = None
+ super().initialize_options()
self.discovery_json = 'arvados-v1-discovery.json'
self.discovery_output = str(Path('arvados', 'api_resources.py'))
@@ -55,8 +56,7 @@ class BuildDiscoveryPydoc(setuptools.Command):
return retval
def finalize_options(self):
- # Set self.build_lib to match whatever the build_py subcommand uses.
- self.set_undefined_options('build_py', ('build_lib', 'build_lib'))
+ super().finalize_options()
self.json_path = self._relative_path(self.discovery_json, 'discovery-json')
self.out_path = Path(
self.build_lib,
@@ -64,30 +64,28 @@ class BuildDiscoveryPydoc(setuptools.Command):
)
def run(self):
+ super().run()
import discovery2pydoc
- self.mkpath(str(self.out_path.parent))
arglist = ['--output-file', str(self.out_path), str(self.json_path)]
returncode = discovery2pydoc.main(arglist)
if returncode != 0:
raise Exception(f"discovery2pydoc exited {returncode}")
- def should_run(self):
- return True
-
def get_outputs(self):
- return [str(self.out_path)]
+ retval = super().get_outputs()
+ retval.append(str(self.out_path))
+ return retval
def get_source_files(self):
- return [str(self.json_path)]
+ retval = super().get_source_files()
+ retval.append(str(self.json_path))
+ return retval
def get_output_mapping(self):
- return {
- str(self.json_path): str(self.out_path),
- }
-# Run discovery2pydoc as the first subcommand of build.
-distutils.command.build.build.sub_commands.insert(
- 0, (BuildDiscoveryPydoc.NAME, BuildDiscoveryPydoc.should_run),
-)
+ retval = super().get_output_mapping()
+ retval[str(self.json_path)] = str(self.out_path)
+ return retval
+
setup(name='arvados-python-client',
version=version,
@@ -99,7 +97,7 @@ setup(name='arvados-python-client',
download_url="https://github.com/arvados/arvados.git",
license='Apache 2.0',
cmdclass={
- BuildDiscoveryPydoc.NAME: BuildDiscoveryPydoc,
+ 'build_py': BuildPython,
},
packages=find_packages(),
scripts=[
commit e0287beae4381ac82334a6c3859884bcbadfb285
Author: Brett Smith <brett.smith at curii.com>
Date: Fri Apr 14 13:55:54 2023 -0400
18799: Add Python 3.7 compatibility for TypedDict
Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>
diff --git a/sdk/python/discovery2pydoc.py b/sdk/python/discovery2pydoc.py
index ad7606145..29502ace1 100755
--- a/sdk/python/discovery2pydoc.py
+++ b/sdk/python/discovery2pydoc.py
@@ -93,6 +93,15 @@ Refer to the API documentation for details about how to retrieve specific keys
if you need them.
'''
+_MODULE_PRELUDE = '''
+import sys
+if sys.version_info < (3, 8):
+ from typing import Any
+ from typing_extensions import TypedDict
+else:
+ from typing import Any, TypedDict
+'''
+
_TYPE_MAP = {
# Map the API's JavaScript-based type names to Python annotations.
# Some of these may disappear after Arvados issue #19795 is fixed.
@@ -327,8 +336,8 @@ def main(arglist: Optional[Sequence[str]]=None) -> int:
discovery_document = json.load(discovery_file)
print(
to_docstring(_MODULE_PYDOC, indent=0),
- '''from typing import Any, TypedDict''',
- sep='\n\n', end='\n\n', file=args.out_file,
+ _MODULE_PRELUDE,
+ sep='\n', file=args.out_file,
)
schemas = sorted(discovery_document['schemas'].items())
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
index f6d6a43c7..910757817 100644
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -126,6 +126,7 @@ setup(name='arvados-python-client',
'pycurl >=7.19.5.1, <7.45.0',
'ruamel.yaml >=0.15.54, <0.17.22',
'setuptools>=40.3.0',
+ 'typing_extensions; python_version<"3.8"',
'ws4py >=0.4.2',
'protobuf<4.0.0dev',
'pyparsing<3',
commit aa369aa06f977a6a3c114e11e472a0ddeb2a07c9
Author: Brett Smith <brett.smith at curii.com>
Date: Fri Apr 14 13:54:52 2023 -0400
18799: Clean up redundant setuptools requirement listing
Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
index ae8831d62..f6d6a43c7 100644
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -125,11 +125,10 @@ setup(name='arvados-python-client',
'httplib2 >=0.9.2, <0.20.2',
'pycurl >=7.19.5.1, <7.45.0',
'ruamel.yaml >=0.15.54, <0.17.22',
- 'setuptools',
+ 'setuptools>=40.3.0',
'ws4py >=0.4.2',
'protobuf<4.0.0dev',
'pyparsing<3',
- 'setuptools>=40.3.0',
],
classifiers=[
'Programming Language :: Python :: 3',
commit 571e94931049a757bed2971084f7d6bf7cf6cb6e
Author: Brett Smith <brett.smith at curii.com>
Date: Fri Apr 14 13:53:32 2023 -0400
18799: Add missing f-string prefix
Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
index 66f1be730..ae8831d62 100644
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -50,7 +50,7 @@ class BuildDiscoveryPydoc(setuptools.Command):
def _relative_path(self, src, optname):
retval = Path(src)
if retval.is_absolute():
- raise Exception("--{optname} should be a relative path")
+ raise Exception(f"--{optname} should be a relative path")
else:
return retval
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list