Skip to content

Commit

Permalink
Viewer uploads inside script
Browse files Browse the repository at this point in the history
  • Loading branch information
MaticTonin committed Dec 6, 2024
1 parent 3760265 commit f78d8db
Show file tree
Hide file tree
Showing 43 changed files with 113 additions and 177 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ jobs:
# This call to version_util.py will assert version from Cargo.toml matches git tagged version vX.Y.Z
run: |
${{ matrix.python }} scripts/version_util.py --check_version
- name: Prepare Files for Wheel
run: |
${{ matrix.python }} .\rerun_py\packages\installer.py
- name: Build Wheel
if: matrix.platform != 'aarch64'
Expand Down
27 changes: 0 additions & 27 deletions rerun_py/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,4 @@ fn main() {
pyo3_build_config::add_extension_module_link_args();

re_build_build_info::export_env_vars();
let script_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("rerun_py/packages/installer.py");
if !script_path.exists() {
panic!("Pre-build script not found: {:?}", script_path);
}

println!("Running pre-build script...");

// Try `python` first
let python_result = Command::new("python3")
.arg(&script_path)
.status();

// If `python` fails, fall back to `python3`
let status = match python_result {
Ok(status) if status.success() => status,
_ => Command::new("python")
.arg(&script_path)
.status()
.expect("Failed to execute pre-build script with both `python` and `python3`"),
};

if !status.success() {
panic!("Pre-build script failed with status: {:?}", status);
}

println!("Pre-build script completed successfully.");
println!("cargo:rerun-if-changed=select_package.py");
}
52 changes: 51 additions & 1 deletion rerun_py/depthai_viewer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import os
import sys

from pathlib import Path
import shutil
import platform
from depthai_viewer import (
bindings,
unregister_shutdown,
Expand All @@ -13,11 +15,59 @@
script_path = os.path.dirname(os.path.abspath(__file__))
venv_dir = os.path.join(script_path, "venv-" + depthai_viewer_version())

def version_dynamic_recalibration(SCRIPT_DIR) -> str:
def get_python_version():
return f"{sys.version_info.major}.{sys.version_info.minor}"

def copy_folder_to_runtime(folder_path, destination_path):
try:
if destination_path.exists():
shutil.rmtree(destination_path)
shutil.copytree(folder_path, destination_path)
print(f"Copied folder from {folder_path} to {destination_path}")
except Exception as e:
print(f"Error copying folder to runtime: {e}")
raise
COMPILERS_DIR = Path(SCRIPT_DIR + "/_backend/compilers")
DESTINATION_DIR = Path(SCRIPT_DIR + "/_backend/obscured_utilities/utilities")
DESTINATION_DIR.mkdir(parents=True, exist_ok=True)

python_version = get_python_version()

system = platform.system().lower()
folder_mapping = {
"darwin": "darwin_x86_64",
"linux": "linux_x86_64",
"windows": "windows_x86_64",
}
folder_to_copy = folder_mapping.get(system)
if not folder_to_copy:
raise ValueError(f"Unsupported OS: {system}")

folder_source = COMPILERS_DIR / python_version / "pyarmor_runtime_007125" / folder_to_copy
if not folder_source.exists():
raise FileNotFoundError(f"Folder {folder_source} not found in compilers directory.")

destination = DESTINATION_DIR / "pyarmor_runtime_007125" / folder_to_copy
print(f"Copying {folder_to_copy} from {folder_source} to {destination}...")
copy_folder_to_runtime(folder_source, destination)

shutil.copy(COMPILERS_DIR / python_version / "pyarmor_runtime_007125" / "__init__.py", DESTINATION_DIR / "pyarmor_runtime_007125"/ "__init__.py")
additional_files = ["__init__.py", "calibration_handler.py", "display_handler.py"]
for file_name in additional_files:
source_file = COMPILERS_DIR / python_version / file_name
if not source_file.exists():
raise FileNotFoundError(f"{file_name} not found in {source_file}.")
shutil.copy(source_file, DESTINATION_DIR)
print(f"Copied {file_name} to {DESTINATION_DIR}")

print("Operation completed successfully.")

def main() -> None:
python_exe = sys.executable
# Call the bindings.main using the Python executable in the venv
unregister_shutdown()
version_dynamic_recalibration(script_path)
# The viewer will take care of installing the requirements if site_packages_directory is None
site_packages_directory = None
try:
Expand Down
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pyarmor 9.0.6 (pro), 007125, Dynamic-recalibration, 2024-12-06T00:30:22.575287
from .pyarmor_runtime_007125 import __pyarmor__
__pyarmor__(__name__, __file__, b'PY007125\x00\x03\n\x00o\r\r\n\x80\x00\x01\x00\x08\x00\x00\x00\x04\x00\x00\x00@\x00\x00\x00\x88\x00\x00\x00\x12\t\x06\x00\x93\x13\xa9\x9d/\t/\xf9\xaa\xb7\xab\xf6\x0e\xc0\x9c\xa3\x00\x00\x00\x00\x00\x00\x00\x00\xcc\xe5\xe3DL\x9a)\xe6w\xd9\t \xbfj\n\x0bq$\x11*\\\xe1\x1a\xb7\xf2I\xcd\x0e\xde\xbc\x9eg\xc8\xc2\x82\x152\xe0o\xd0\xaa\xd3\xe9D\xfa\xc2\xa2W\x119_l\xd6v2K\xf8\xb7\xab\x9a\xd7\x91{\xd0\x93\xb6_b+B\xd9\x14\x12k^7\xbe\x16\xb2\xe1\xdc\xd1\x92\xce$RC\xc4\xfdo\xad\xb8)q\xba\xe1gA\x90\x08\x9c\xafk\x00\x1d\xa0\xb6\xf7\x0c(\xe5v\\\xf1\x99\xbe\x0b\x10\xf7\xe53\xfd^vF\xf8\xe6\x83i\xfdS\x98#kb\xa9')

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Pyarmor 9.0.6 (pro), 007125, 2024-12-06T00:30:21.941053
def __pyarmor__():
import platform
import sys
from struct import calcsize

def format_system():
plat = platform.system().lower()
plat = ('cygwin' if plat.startswith('cygwin') else
'linux' if plat.startswith('linux') else
'freebsd' if plat.startswith(
('freebsd', 'openbsd', 'isilon onefs')) else plat)
if plat == 'linux':
if hasattr(sys, 'getandroidapilevel'):
plat = 'android'
else:
cname, cver = platform.libc_ver()
if cname == 'musl':
plat = 'alpine'
elif cname == 'libc':
plat = 'android'
return plat

def format_machine():
mach = platform.machine().lower()
arch_table = (
('x86', ('i386', 'i486', 'i586', 'i686', 'x86')),
('x86_64', ('x64', 'x86_64', 'amd64', 'intel')),
('arm', ('armv5',)),
('armv6', ('armv6l',)),
('armv7', ('armv7l',)),
('aarch32', ('aarch32',)),
('aarch64', ('aarch64', 'arm64')),
('ppc64le', ('ppc64le',)),
('mips32el', ('mipsel', 'mips32el')),
('mips64el', ('mips64el',)),
('riscv64', ('riscv64',)),
)
for alias, archlist in arch_table:
if mach in archlist:
mach = alias
break
return mach

plat, mach = format_system(), format_machine()
if plat == 'windows' and mach == 'x86_64':
bitness = calcsize('P'.encode()) * 8
if bitness == 32:
mach = 'x86'
# mach = 'universal' if plat == 'darwin' else mach
name = '.'.join(['_'.join([plat, mach]), 'pyarmor_runtime'])
return __import__(name, globals(), locals(), ['__pyarmor__'], level=1)
__pyarmor__ = __pyarmor__().__pyarmor__
Binary file not shown.
80 changes: 0 additions & 80 deletions rerun_py/packages/installer.py

This file was deleted.

4 changes: 0 additions & 4 deletions rerun_py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,3 @@ ban-relative-imports = "all"
[tool.maturin]
locked = true
python-packages = ["depthai_viewer"]

include = [
"rerun/packages/*",
]
51 changes: 0 additions & 51 deletions rerun_py/select_package.py

This file was deleted.

11 changes: 0 additions & 11 deletions rerun_py/setup.py

This file was deleted.

0 comments on commit f78d8db

Please sign in to comment.