From 35fd44d0bd59f4b4c291a8b14782c99bcca1043e Mon Sep 17 00:00:00 2001 From: danielg55 Date: Tue, 2 Mar 2021 18:03:47 +0200 Subject: [PATCH] Add ws_data_dir to wheel --- Dockerfile | 6 ++++-- marine/marine.py | 7 ++++++- setup.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8354ec..2fa14b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,10 @@ COPY marine ./marine ENV PY="/opt/python/cp38-cp38/bin/python" -RUN mkdir marine/.wslibs && \ - cp /build/run/libmarine.so /build/run/lib*so.0 marine/.wslibs/ && \ +RUN mkdir -p marine/.ws/data && \ + rsync -L --exclude idl2wrs --exclude 'lib*.so*' --exclude 'plugins*' --exclude 'marine_*' --exclude tshark --exclude '*.html' --exclude 'lib*.a' /build/run/* marine/.ws/data/ && \ + mkdir marine/.ws/libs && \ + rsync -L /build/run/libmarine.so /build/run/lib*so.0 marine/.ws/libs/ && \ $PY setup.py bdist_wheel --dist-dir /tmp WORKDIR /dist diff --git a/marine/marine.py b/marine/marine.py index f508c51..236fec0 100644 --- a/marine/marine.py +++ b/marine/marine.py @@ -1,6 +1,7 @@ from ctypes import * from pathlib import Path from typing import Optional, List, Dict, Tuple, NamedTuple +import os from .exceptions import ( BadBPFException, @@ -17,7 +18,9 @@ class MarineResult(Structure): MARINE_RESULT_POINTER = POINTER(MarineResult) -MARINE_NAME = Path(__file__).parent / ".wslibs" / "libmarine.so" +MARINE_BASE_DIR = Path(__file__).parent / ".ws" +MARINE_NAME = MARINE_BASE_DIR / "libs" / "libmarine.so" +MARINE_DATA_DIR = MARINE_BASE_DIR / "data" class MarineFieldsValidationResult(NamedTuple): @@ -46,6 +49,8 @@ class Marine: WIFI_RADIO_PROTOCOLS = frozenset(["radiotap", "wlan", "wlan_radio"]) def __init__(self, epan_auto_reset_count: Optional[int] = None): + if not os.getenv("WIRESHARK_DATA_DIR"): + os.putenv("WIRESHARK_DATA_DIR", str(MARINE_DATA_DIR)) try: cdll.LoadLibrary(MARINE_NAME) except Exception: diff --git a/setup.py b/setup.py index aac4ec1..a94c58a 100644 --- a/setup.py +++ b/setup.py @@ -10,6 +10,6 @@ packages=["marine"], include_package_data=True, package_data={ - "marine": [".wslibs/*.so*"], + "marine": [".ws/libs/*.so*", ".ws/data/*"], }, )