Skip to content

Modernize python build setup, protoc dependency #783

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

Merged
merged 4 commits into from
Mar 25, 2024
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
39 changes: 30 additions & 9 deletions .github/workflows/protobuf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ jobs:
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements_develop.txt
python -m pip install build
python -m pip install -r requirements_tests.txt

- name: Check black format
run: black --check --diff .
run: |
black --check --diff .

- name: Install Doxygen
run: sudo apt-get install doxygen graphviz
Expand Down Expand Up @@ -88,10 +90,14 @@ jobs:
- name: Prepare C++ Build
run: mkdir build

# Versioning
- name: Get versioning
- name: Add Development Version Suffix
if: ${{ !startsWith(github.ref, 'refs/tags') }}
run: |
echo "VERSION_SUFFIX = .dev`date -u '+%Y%m%d%H%M%S'`" >> VERSION

- name: Get git Version
id: get_version
run: echo "VERSION=$(git describe --always)" >> $GITHUB_OUTPUT
run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_OUTPUT

- name: Prepare Documentation Build
run: |
Expand All @@ -108,7 +114,7 @@ jobs:
run: cmake --build . --config Release -j 4

- name: Build Python
run: python setup.py build && python setup.py sdist
run: python -m build

- name: Install Python
run: python -m pip install .
Expand All @@ -124,7 +130,14 @@ jobs:
path: doc/html
if-no-files-found: error

- name: deploy to gh-pages if push to master branch
- name: Upload Python Distribution
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: python-dist
path: dist/

- name: Deploy to gh-pages if push to master branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: peaceiris/actions-gh-pages@v3
with:
Expand All @@ -148,7 +161,10 @@ jobs:
python-version: '3.8'

- name: Install Python Dependencies
run: python -m pip install --upgrade pip setuptools wheel pyyaml
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m pip install -r requirements_tests.txt

- name: Cache Dependencies
id: cache-depends
Expand Down Expand Up @@ -187,6 +203,11 @@ jobs:
bash convert-to-proto3.sh
rm *.pb2

- name: Add Development Version Suffix
if: ${{ !startsWith(github.ref, 'refs/tags') }}
run: |
echo "VERSION_SUFFIX = .dev`date -u '+%Y%m%d%H%M%S'`" >> VERSION

- name: Configure C++ Build
working-directory: build
run: cmake ${{ env.PROTOBUF_VARIANT =='' && '-DCMAKE_CXX_STANDARD=17' }} ..
Expand All @@ -196,7 +217,7 @@ jobs:
run: cmake --build . --config Release -j 4

- name: Build Python
run: python setup.py build && python setup.py sdist
run: python -m build

- name: Install Python
run: python -m pip install .
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ build
cmake_install.cmake
install_manifest.txt
osi_version.proto
version.py
pyproject.toml

compile_commands.json

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include VERSION
174 changes: 0 additions & 174 deletions format/OSITrace.py

This file was deleted.

32 changes: 16 additions & 16 deletions format/osi2read.py → osi3trace/osi2read.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
python3 osi2read.py -d trace.osi -o myreadableosifile
"""

from OSITrace import OSITrace
import struct
import lzma
from osi3trace.osi_trace import OSITrace
import argparse
import os
import pathlib


def command_line_arguments():
"""Define and handle command line interface"""

dir_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

parser = argparse.ArgumentParser(
description="Convert a serialized osi trace file to a readable txth output.",
prog="osi2read converter",
prog="osi2read",
)
parser.add_argument(
"--data", "-d", help="Path to the file with serialized data.", type=str
"--data",
"-d",
help="Path to the file with serialized data.",
type=str,
required=True,
)
parser.add_argument(
"--type",
Expand All @@ -37,7 +37,6 @@ def command_line_arguments():
"--output",
"-o",
help="Output name of the file.",
default="converted.txth",
type=str,
required=False,
)
Expand All @@ -50,16 +49,17 @@ def main():
args = command_line_arguments()

# Initialize the OSI trace class
trace = OSITrace()
trace.from_file(path=args.data, type_name=args.type)
trace = OSITrace(args.data, args.type)

args.output = args.output.split(".", 1)[0] + ".txth"
if not args.output:
path = pathlib.Path(args.data).with_suffix(".txth")
args.output = str(path)

if args.output == "converted.txth":
args.output = args.data.split(".", 1)[0] + ".txth"
with open(args.output, "wt") as f:
for message in trace:
f.write(str(message))

trace.make_readable(args.output)
trace.scenario_file.close()
trace.close()


if __name__ == "__main__":
Expand Down
Loading