From: JinWang An Date: Mon, 28 Dec 2020 04:45:27 +0000 (+0900) Subject: Imported Upstream version 3.1.0 X-Git-Tag: upstream/3.1.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a978025a8b4cc13bbba87b37c739c685a4e1475a;p=platform%2Fupstream%2Fpython3-pbr.git Imported Upstream version 3.1.0 --- diff --git a/AUTHORS b/AUTHORS index bbe67ad..faa64ef 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ +A40351 Akihiro Motoki Alex Gaynor Alexander Makarov @@ -67,6 +68,7 @@ Mark Sienkiewicz Maru Newby Masaki Matsushita Matt Riedemann +Matthew Montgomery Matthew Treinish Michael Basnight Michael Still diff --git a/ChangeLog b/ChangeLog index 4bc0144..c34e8b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,15 @@ CHANGES ======= +3.1.0 +----- + +* allow user to override the output location of api docs +* fix tests based on API change in Sphinx +* Updated from global requirements +* Add binding option for WSGI server +* Ignore index URL lines in requirements.txt files + 3.0.1 ----- diff --git a/PKG-INFO b/PKG-INFO index 3e4471a..71b69fd 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pbr -Version: 3.0.1 +Version: 3.1.0 Summary: Python Build Reasonableness Home-page: http://docs.openstack.org/developer/pbr/ Author: OpenStack diff --git a/doc/source/index.rst b/doc/source/index.rst index 764edf1..4ff2d7a 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -321,6 +321,12 @@ The ``pbr`` section controls `pbr` specific options and behaviours. A list of modules to exclude when building module documentation using `pbr`. `fnmatch` style pattern (e.g. `myapp.tests.*`) can be used. +``api_doc_dir`` + + A subdirectory inside the ``build_sphinx.source_dir`` where + auto-generated API documentation should be written, if + ``autodoc_index_modules`` is set to True. Defaults to ``"api"``. + .. note:: When using ``autodoc_tree_excludes`` or ``autodoc_index_modules`` you may @@ -374,6 +380,11 @@ option. build-dir = doc/build all-files = 1 +``source_dir`` + + The path to the source directory where the Sphinx documentation tree + is. + For information on the remaining options, refer to the `Sphinx documentation`__. In addition, the ``autodoc_index_modules``, ``autodoc_tree_index_modules``, ``autodoc_exclude_modules`` and diff --git a/pbr.egg-info/PKG-INFO b/pbr.egg-info/PKG-INFO index 3e4471a..71b69fd 100644 --- a/pbr.egg-info/PKG-INFO +++ b/pbr.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pbr -Version: 3.0.1 +Version: 3.1.0 Summary: Python Build Reasonableness Home-page: http://docs.openstack.org/developer/pbr/ Author: OpenStack diff --git a/pbr/builddoc.py b/pbr/builddoc.py index 1d31502..c1a2e6f 100644 --- a/pbr/builddoc.py +++ b/pbr/builddoc.py @@ -69,10 +69,13 @@ class LocalBuildDoc(setup_command.BuildDoc): def _get_source_dir(self): option_dict = self.distribution.get_option_dict('build_sphinx') + pbr_option_dict = self.distribution.get_option_dict('pbr') + _, api_doc_dir = pbr_option_dict.get('api_doc_dir', (None, 'api')) if 'source_dir' in option_dict: - source_dir = os.path.join(option_dict['source_dir'][1], 'api') + source_dir = os.path.join(option_dict['source_dir'][1], + api_doc_dir) else: - source_dir = 'doc/source/api' + source_dir = 'doc/source/' + api_doc_dir if not os.path.exists(source_dir): os.makedirs(source_dir) return source_dir diff --git a/pbr/packaging.py b/pbr/packaging.py index a3527c9..913e7a3 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -102,6 +102,10 @@ def parse_requirements(requirements_files=None, strip_markers=False): if (not line.strip()) or line.startswith('#'): continue + # Ignore index URL lines + if re.match(r'^\s*(-i|--index-url|--extra-index-url).*', line): + continue + # Handle nested requirements files such as: # -r other-requirements.txt if line.startswith('-r'): @@ -282,12 +286,15 @@ if __name__ == "__main__": import wsgiref.simple_server as wss my_ip = socket.gethostbyname(socket.gethostname()) + parser = argparse.ArgumentParser( description=%(import_target)s.__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter, - usage='%%(prog)s [-h] [--port PORT] -- [passed options]') + usage='%%(prog)s [-h] [--port PORT] [--host IP] -- [passed options]') parser.add_argument('--port', '-p', type=int, default=8000, help='TCP port to listen on') + parser.add_argument('--host', '-b', default=my_ip, + help='IP to bind the server to') parser.add_argument('args', nargs=argparse.REMAINDER, metavar='-- [passed options]', @@ -301,11 +308,11 @@ if __name__ == "__main__": else: parser.error("unrecognized arguments: %%s" %% ' '.join(args.args)) sys.argv[1:] = args.args - server = wss.make_server('', args.port, %(invoke_target)s()) + server = wss.make_server(args.host, args.port, %(invoke_target)s()) print("*" * 80) print("STARTING test server %(module_name)s.%(invoke_target)s") - url = "http://%%s:%%d/" %% (my_ip, server.server_port) + url = "http://%%s:%%d/" %% (server.server_name, server.server_port) print("Available at %%s" %% url) print("DANGER! For testing only, do not use in production") print("*" * 80) diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index 69a8f79..9efcbd7 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -486,6 +486,19 @@ class TestPresenceOfGit(base.BaseTestCase): self.assertEqual(False, git._git_is_installed()) +class TestIndexInRequirements(base.BaseTestCase): + + def test_index_in_requirement(self): + tempdir = tempfile.mkdtemp() + requirements = os.path.join(tempdir, 'requirements.txt') + with open(requirements, 'w') as f: + f.write('-i https://myindex.local') + f.write(' --index-url https://myindex.local') + f.write(' --extra-index-url https://myindex.local') + result = packaging.parse_requirements([requirements]) + self.assertEqual([], result) + + class TestNestedRequirements(base.BaseTestCase): def test_nested_requirement(self): diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py index 7aa74f6..0b9c81b 100644 --- a/pbr/tests/test_setup.py +++ b/pbr/tests/test_setup.py @@ -233,6 +233,14 @@ class BaseSphinxTest(base.BaseTestCase): def setUp(self): super(BaseSphinxTest, self).setUp() + # setup_command requires the Sphinx instance to have some + # attributes that aren't set normally with the way we use the + # class (because we replace the constructor). Add default + # values directly to the class definition. + import sphinx.application + sphinx.application.Sphinx.messagelog = [] + sphinx.application.Sphinx.statuscode = 0 + self.useFixture(fixtures.MonkeyPatch( "sphinx.application.Sphinx.__init__", lambda *a, **kw: None)) self.useFixture(fixtures.MonkeyPatch( @@ -368,6 +376,78 @@ class BuildSphinxTest(BaseSphinxTest): self.assertEqual(["builder1", "builder2"], build_doc.builders) +class APIAutoDocTest(base.BaseTestCase): + + def setUp(self): + super(APIAutoDocTest, self).setUp() + + # setup_command requires the Sphinx instance to have some + # attributes that aren't set normally with the way we use the + # class (because we replace the constructor). Add default + # values directly to the class definition. + import sphinx.application + sphinx.application.Sphinx.messagelog = [] + sphinx.application.Sphinx.statuscode = 0 + + self.useFixture(fixtures.MonkeyPatch( + "sphinx.application.Sphinx.__init__", lambda *a, **kw: None)) + self.useFixture(fixtures.MonkeyPatch( + "sphinx.application.Sphinx.build", lambda *a, **kw: None)) + self.useFixture(fixtures.MonkeyPatch( + "sphinx.application.Sphinx.config", _SphinxConfig)) + self.useFixture(fixtures.MonkeyPatch( + "sphinx.config.Config.init_values", lambda *a: None)) + self.useFixture(fixtures.MonkeyPatch( + "sphinx.config.Config.__init__", lambda *a: None)) + from distutils import dist + self.distr = dist.Distribution() + self.distr.packages = ("fake_package",) + self.distr.command_options["build_sphinx"] = { + "source_dir": ["a", "."]} + self.sphinx_options = self.distr.command_options["build_sphinx"] + pkg_fixture = fixtures.PythonPackage( + "fake_package", [("fake_module.py", b""), + ("another_fake_module_for_testing.py", b""), + ("fake_private_module.py", b"")]) + self.useFixture(pkg_fixture) + self.useFixture(base.DiveDir(pkg_fixture.base)) + self.pbr_options = self.distr.command_options.setdefault('pbr', {}) + self.pbr_options["autodoc_index_modules"] = ('setup.cfg', 'True') + + def test_default_api_build_dir(self): + build_doc = packaging.LocalBuildDoc(self.distr) + build_doc.run() + + print('PBR OPTIONS:', self.pbr_options) + print('DISTR OPTIONS:', self.distr.command_options) + + self.assertTrue(os.path.exists("api/autoindex.rst")) + self.assertTrue(os.path.exists("api/fake_package.fake_module.rst")) + self.assertTrue( + os.path.exists( + "api/fake_package.fake_private_module.rst")) + self.assertTrue( + os.path.exists( + "api/fake_package.another_fake_module_for_testing.rst")) + + def test_different_api_build_dir(self): + # Options have to come out of the settings dict as a tuple + # showing the source and the value. + self.pbr_options['api_doc_dir'] = (None, 'contributor/api') + build_doc = packaging.LocalBuildDoc(self.distr) + build_doc.run() + + print('PBR OPTIONS:', self.pbr_options) + print('DISTR OPTIONS:', self.distr.command_options) + + self.assertTrue(os.path.exists("contributor/api/autoindex.rst")) + self.assertTrue( + os.path.exists("contributor/api/fake_package.fake_module.rst")) + self.assertTrue( + os.path.exists( + "contributor/api/fake_package.fake_private_module.rst")) + + class ParseRequirementsTestScenarios(base.BaseTestCase): versioned_scenarios = [ diff --git a/test-requirements.txt b/test-requirements.txt index c40f6e5..9df6553 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,7 +6,7 @@ fixtures>=3.0.0 # Apache-2.0/BSD hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 mock>=2.0 # BSD python-subunit>=0.0.18 # Apache-2.0/BSD -sphinx>=1.5.1 # BSD +sphinx!=1.6.1,>=1.5.1 # BSD oslosphinx>=4.7.0 # Apache-2.0 six>=1.9.0 # MIT testrepository>=0.0.18 # Apache-2.0/BSD