Skip to content

Commit

Permalink
fix: usr: 'topology' executable was broken and could not be called. R…
Browse files Browse the repository at this point in the history
…eleasing 1.18.2.
  • Loading branch information
carlos-jenkins committed Jun 15, 2023
1 parent b716f5a commit d74087b
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 19 deletions.
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ License

.. code-block:: text
Copyright (C) 2015-2022 Hewlett Packard Enterprise Development LP
Copyright (C) 2015-2023 Hewlett Packard Enterprise Development LP
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -38,6 +38,13 @@ License
Changelog
=========

1.18.2 (2023-06-15)
-------------------

Fixes
~~~~~
- 'topology' executable was broken and could not be called. Fixed.


1.18.1 (2022-10-31)
-------------------
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en_US'

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down Expand Up @@ -128,7 +128,7 @@

# Add style overrides
def setup(app):
app.add_stylesheet('styles/custom.css')
app.add_css_file('styles/custom.css')


# autoapi configuration
Expand Down
4 changes: 2 additions & 2 deletions lib/topology/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2022 Hewlett Packard Enterprise Development LP
# Copyright (C) 2015-2023 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,4 +21,4 @@

__author__ = 'Hewlett Packard Enterprise Development LP'
__email__ = '[email protected]'
__version__ = '1.18.1'
__version__ = '1.18.2'
14 changes: 10 additions & 4 deletions lib/topology/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main(args):
:return: Exit code.
:rtype: int
"""
print('Starting Network Topology Framework v{}'.format(__version__))
print('Starting Topology Framework v{}'.format(__version__))

# Setup framework logging
logmanager.logging_context = None
Expand All @@ -61,7 +61,10 @@ def main(args):
if args.inject is not None:
injection_spec = parse_attribute_injection(
args.inject,
search_paths=[Path(args.topology).parent])
search_paths=[
Path(args.topology).parent,
]
)
injected_attr = injection_spec.get(args.topology, None)

# Create manager
Expand Down Expand Up @@ -120,8 +123,7 @@ def unbuild():
return 0


if __name__ == '__main__':

def __main__(): # noqa: N807
# Parse arguments
try:
args = parse_args()
Expand All @@ -133,6 +135,10 @@ def unbuild():
exit(main(args))


if __name__ == '__main__':
__main__()


__all__ = [
'main',
]
2 changes: 1 addition & 1 deletion lib/topology/graph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def add_port(self, port: Port):
"""
Adds a port to the node.
:param Port port: The port to add.
:param topology.graph.Port port: The port to add.
"""
if port.node_id != self.identifier:
raise Inconsistent(
Expand Down
15 changes: 10 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2022 Hewlett Packard Enterprise Development LP
# Copyright (C) 2015-2023 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -105,15 +105,17 @@ def find_requirements(filename):
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],

# Entry points
entry_points={
'console_scripts': [
'topology=topology.__main__:main',
'topology=topology.__main__:__main__',
],
'pytest11': [
'topology = topology.pytest.plugin',
Expand All @@ -124,5 +126,8 @@ def find_requirements(filename):
'topology_library_10': [
'common = topology.libraries.common',
]
}
},

# Minimal Python version
python_requires='>=3.6',
)
81 changes: 81 additions & 0 deletions test/test_executable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2023 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

"""
Test suite for the topology executable.
"""

from re import compile
from shutil import which
from sys import executable
from subprocess import run

from topology import __version__


VERSION_REGEX = compile(
r'.+ v(?P<mayor>\d+)\.(?P<minor>\d+).(?P<rev>\d+)'
)
MAYOR, MINOR, REV = map(int, __version__.split('.'))


def assert_version(stdout):
match = VERSION_REGEX.match(stdout)
assert match, (
f'topology executable stdout {stdout!r} did not match '
f'expected regex {VERSION_REGEX.pattern!r}'
)

groups = match.groupdict()
mayor, minor, rev = map(int, (
groups[key] for key in ['mayor', 'minor', 'rev']
))

assert all((
MAYOR == mayor,
MINOR == minor,
REV == rev,
)), (
'Version mismatch for the topology executable: '
f'{MAYOR} != {mayor}?, '
f'{MINOR} != {minor}?, '
f'{REV} != {rev}?'
)


def test_executable():

# Test first supported call: topology --version
topology = which('topology')
assert topology, 'Executable not found'

completed = run(
[topology, '--version'],
encoding='utf-8',
capture_output=True,
)
assert completed.returncode == 0, 'topology executable failed'
assert_version(completed.stdout)

# Test second supported call: python3 -m topology --version
completed = run(
[executable, '-m', 'topology', '--version'],
encoding='utf-8',
capture_output=True,
)
assert completed.returncode == 0, 'topology module executable failed'
assert_version(completed.stdout)
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ envlist = test, doc
[testenv]
basepython = python3
changedir = {envtmpdir}
passenv = https_proxy http_proxy no_proxy
passenv = https_proxy, http_proxy, no_proxy


[testenv:build]
Expand Down Expand Up @@ -38,7 +38,7 @@ commands =
[testenv:doc]
deps =
-rdoc/requirements.txt
whitelist_externals =
allowlist_externals =
dot
commands =
sphinx-build -W -b html -d doctrees {toxinidir}/doc/ html
Expand All @@ -50,7 +50,7 @@ skip_install = True
deps =
wheel
twine
whitelist_externals =
allowlist_externals =
ls
commands =
{envpython} {toxinidir}/setup.py sdist
Expand All @@ -65,4 +65,4 @@ commands =


[flake8]
exclude = .git,.tox,.cache,__pycache__,*.egg-info
exclude = .git,.tox,.cache,__pycache__,*.egg-info,build

0 comments on commit d74087b

Please sign in to comment.