Skip to content

Commit 6386fd9

Browse files
committed
Support multiple license files and submodule update
Update license initialization to support multiple license files and bump radarsimcpp submodule. - Bump src/radarsimcpp submodule commit. - Simplify package import: __init__.py now always calls initialize_license() (file detection moved into license module). - Add libcpp.vector overload in radarsimc.pxd: Initialize(const vector[string]& license_file_paths) so C++ can accept multiple license paths. - Implement multi-file search in license.pyx: when no path is provided, search for license_RadarSimPy_*.lic in the module dir and pass all found files to the C++ Initialize; if none found, pass empty string to enable free-tier mode. Imports for libcpp.vector, os, and glob were added and paths are encoded as UTF-8 before calling into C++. These changes centralize auto-detection in the Cython layer and allow supplying multiple license files to the native license manager.
1 parent d77cc24 commit 6386fd9

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

src/radarsimcpp

src/radarsimpy/__init__.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,7 @@
5252

5353
_simulation_available = True
5454

55-
# Automatically initialize license on module import
56-
# Searches for license_RadarSimPy_*.lic in module directory
57-
import os
58-
import glob
59-
60-
_module_dir = os.path.dirname(os.path.abspath(__file__))
61-
_license_pattern = os.path.join(_module_dir, "license_RadarSimPy_*.lic")
62-
_license_files = glob.glob(_license_pattern)
63-
64-
if _license_files:
65-
# Use the first found license file
66-
initialize_license(_license_files[0])
67-
else:
68-
# No license file found, initialize without path (free tier mode)
69-
initialize_license()
55+
initialize_license()
7056
# except ImportError:
7157
# _simulation_available = False
7258

src/radarsimpy/includes/radarsimc.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ cdef extern from "libs/license_manager.hpp":
102102
@staticmethod
103103
LicenseManager& GetInstance()
104104
void Initialize(const string& license_file_path)
105+
void Initialize(const vector[string]& license_file_paths)
105106
bint IsLicensed() const
106107
bint IsFreeTier() const
107108
string GetLicenseInfo() const

src/radarsimpy/license.pyx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ It allows checking license status and accessing license information.
2424
"""
2525

2626
from libcpp.string cimport string
27+
from libcpp.vector cimport vector
2728
from radarsimpy.includes.radarsimc cimport LicenseManager
29+
import os
30+
import glob
2831

2932

3033
def initialize_license(license_file_path=None):
3134
"""
3235
Initialize the license manager with a license file.
3336
3437
Args:
35-
license_file_path (str, optional): Path to license file. If None, runs in free tier mode.
38+
license_file_path (str, optional): Path to license file. If None, automatically
39+
searches for all license_RadarSimPy_*.lic files in the module directory.
3640
3741
Example:
3842
>>> import radarsimpy
@@ -45,15 +49,27 @@ def initialize_license(license_file_path=None):
4549
Typically called automatically by the package during import with auto-detected license path.
4650
"""
4751
cdef string cpp_license_path
52+
cdef vector[string] cpp_license_paths
4853

4954
if license_file_path is None:
50-
# No license file provided, pass empty string (free tier mode)
51-
cpp_license_path = b""
55+
# No license file provided, search for all license_RadarSimPy_*.lic files
56+
_module_dir = os.path.dirname(os.path.abspath(__file__))
57+
license_pattern = os.path.join(_module_dir, "license_RadarSimPy_*.lic")
58+
license_files = glob.glob(license_pattern)
59+
60+
if license_files:
61+
# Pass all found license files to C++
62+
for lic_file in license_files:
63+
cpp_license_paths.push_back(lic_file.encode('utf-8'))
64+
LicenseManager.GetInstance().Initialize(cpp_license_paths)
65+
else:
66+
# No license files found, use empty string (free tier mode)
67+
cpp_license_path = b""
68+
LicenseManager.GetInstance().Initialize(cpp_license_path)
5269
else:
5370
# Use provided path
5471
cpp_license_path = license_file_path.encode('utf-8')
55-
56-
LicenseManager.GetInstance().Initialize(cpp_license_path)
72+
LicenseManager.GetInstance().Initialize(cpp_license_path)
5773

5874

5975
def is_licensed():

0 commit comments

Comments
 (0)