Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use single unified version #11

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bindings/python/quokka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.5.1"
__quokka_version__ = "0.5.1"
from quokka.version import __version__

import quokka.analysis
import quokka.backends
Expand Down
15 changes: 12 additions & 3 deletions bindings/python/quokka/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,21 @@ def __init__(
# Export mode
self.mode: ExporterMode = ExporterMode.from_proto(self.proto.exporter_meta.mode)

# Check if it matches the version
if self.proto.exporter_meta.version != quokka.__quokka_version__:
# Version checking
# A change in the major version might break backward compatibility
proto_version = parse_version(self.proto.exporter_meta.version)
current_version = parse_version(quokka.__version__)
if proto_version[0] != current_version[0]:
self.logger.warning(
"The exported file has been generated by a different version of Quokka."
f" The file has been generated by Quokka {self.proto.exporter_meta.version}"
f" while python-quokka uses {quokka.__quokka_version__}"
f" while you are using {quokka.__version__}"
)
elif self.proto.exporter_meta.version != quokka.__version__:
self.logger.debug(
"Version mismatch detected but still compatible with the exported file."
f" The file has been generated by Quokka {self.proto.exporter_meta.version}"
f" while you are using {quokka.__version__}"
)

# Check if the hashes matches between the export file and the exec
Expand Down
12 changes: 12 additions & 0 deletions bindings/python/quokka/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,15 @@ def get_arch(
arch = ArchARMThumb

return arch


def parse_version(version: str) -> tuple[int, int, int]:
"""Parse the version returning a tuple with the major, minor and patch"""

parsed = tuple(map(int, version.split(".")))
if len(parsed) != 3:
raise ValueError(
f"Version {version} doesn't respect the format MAJOR.MINOR.PATCH"
)

return parsed
15 changes: 15 additions & 0 deletions bindings/python/quokka/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 Quarkslab
#
# 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
#
# https://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.

__version__ = "0.5.1"
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
# limitations under the License.

from setuptools import setup
from os.path import normpath

with open("README.md", "r") as fd:
readme = fd.read()

main_ns = {}
ver_path = normpath('bindings/python/quokka/version.py')
with open(ver_path) as ver_file:
exec(ver_file.read(), main_ns)

setup(
name="quokka-project",
version="0.5.1",
version=main_ns['__version__'],
author="Alexis <dm> Challande",
author_email="achallande@quarkslab.com",
url="https://github.com/quarkslab/quokka",
Expand Down