Skip to content

Commit 7fbae19

Browse files
committed
Add set_license API, alias, and docs
Introduce a new set_license API for configuring licenses and add documentation for license handling. Changes include: - Documentation: add a comprehensive "License Configuration" section to installation.rst describing automatic detection (license_RadarSimPy_*.lic), manual configuration (radarsimpy.set_license), status checks, examples, and free-tier behavior. - Python package API: update src/radarsimpy/__init__.py to import and call set_license() at import time, expose set_license in __all__, and keep initialize_license as a backwards-compatible alias. - Cython bindings: update src/radarsimpy/includes/radarsimc.pxd to declare LicenseManager::SetLicense variants (string and vector[string]) replacing Initialize. - Implementation: replace initialize_license with set_license in src/radarsimpy/license.pyx, call the C++ SetLicense method, handle automatic discovery and explicit paths, and add initialize_license = set_license as compatibility alias. - Submodule: bump src/radarsimcpp submodule reference to the new commit. These changes allow setting or updating the license at runtime, support multiple license files, and preserve backwards compatibility with code using initialize_license.
1 parent 38dfad7 commit 7fbae19

File tree

5 files changed

+113
-15
lines changed

5 files changed

+113
-15
lines changed

gen_docs/user_guide/installation.rst

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,98 @@ You should see output similar to:
8989
9090
RadarSimPy version: 14.x.x
9191
92+
License Configuration
93+
---------------------
94+
95+
RadarSimPy supports both free tier and licensed operation modes. License files enable access to advanced features and remove free tier limitations.
96+
97+
License File Placement
98+
^^^^^^^^^^^^^^^^^^^^^^
99+
100+
**Automatic Detection**
101+
102+
The simplest way to activate your license is to place the license file in the ``radarsimpy/`` package directory:
103+
104+
.. code-block:: none
105+
106+
your_project/
107+
├── your_script.py
108+
└── radarsimpy/
109+
├── __init__.py
110+
├── license_RadarSimPy_customer.lic # Your license file
111+
├── radar.py
112+
└── ...
113+
114+
License files must follow the naming pattern: ``license_RadarSimPy_*.lic``
115+
116+
.. note::
117+
RadarSimPy automatically searches for and validates all ``license_RadarSimPy_*.lic`` files in the package directory. As long as one valid license is found, full functionality is enabled.
118+
119+
**Multiple License Files**
120+
121+
You can place multiple license files in the directory. The system will try each one until a valid license is found:
122+
123+
.. code-block:: none
124+
125+
radarsimpy/
126+
├── license_RadarSimPy_company.lic
127+
├── license_RadarSimPy_backup.lic
128+
└── license_RadarSimPy_trial.lic
129+
130+
Manual License Configuration
131+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132+
133+
If you need to specify a license file from a custom location, or update the license at runtime:
134+
135+
.. code-block:: python
136+
137+
import radarsimpy
138+
139+
# Set license with a specific license file
140+
radarsimpy.set_license("/path/to/your/license_RadarSimPy_customer.lic")
141+
142+
# Check if license is active
143+
if radarsimpy.is_licensed():
144+
print("Full license active")
145+
print(radarsimpy.get_license_info())
146+
else:
147+
print("Running in free tier mode")
148+
149+
Checking License Status
150+
^^^^^^^^^^^^^^^^^^^^^^^^
151+
152+
You can verify your license status at any time:
153+
154+
.. code-block:: python
155+
156+
import radarsimpy
157+
158+
# Check license status
159+
if radarsimpy.is_licensed():
160+
# Get license information
161+
info = radarsimpy.get_license_info()
162+
print(f"License info: {info}")
163+
else:
164+
print("Running in free tier mode with limitations")
165+
166+
**Example Output**
167+
168+
.. code-block:: none
169+
170+
License info: Licensed to: Company Name (365 days remaining)
171+
172+
Free Tier Mode
173+
^^^^^^^^^^^^^^
174+
175+
If no valid license file is found, RadarSimPy automatically operates in free tier mode with certain limitations:
176+
177+
- Limited target complexity
178+
- Reduced simulation fidelity options
179+
- Other feature restrictions as documented
180+
181+
.. tip::
182+
To obtain a license file, visit `radarsimx.com <https://radarsimx.com/product/radarsimpy/>`_ or contact info@radarsimx.com.
183+
92184
Building from Source
93185
---------------------
94186

src/radarsimcpp

src/radarsimpy/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
from .simulator import sim_radar
4949
from .simulator import sim_lidar
5050
from .simulator import sim_rcs
51-
from .license import initialize_license, is_licensed, get_license_info
51+
from .license import set_license, initialize_license, is_licensed, get_license_info
5252

5353
_simulation_available = True
5454

55-
initialize_license()
55+
set_license()
5656
# except ImportError:
5757
# _simulation_available = False
5858

@@ -82,7 +82,8 @@
8282
"sim_lidar",
8383
"sim_rcs",
8484
# License Functions (if available)
85-
"initialize_license",
85+
"set_license",
86+
"initialize_license", # Backwards compatibility
8687
"is_licensed",
8788
"is_free_tier",
8889
"get_license_info",
@@ -100,7 +101,7 @@
100101
# Remove simulation and license functions from __all__ if not available
101102
if not _simulation_available:
102103
for func in ["sim_radar", "sim_lidar", "sim_rcs",
103-
"initialize_license", "is_licensed", "is_free_tier", "get_license_info"]:
104+
"set_license", "initialize_license", "is_licensed", "is_free_tier", "get_license_info"]:
104105
if func in __all__:
105106
__all__.remove(func)
106107

@@ -285,7 +286,7 @@ def hello():
285286
>>> range_doppler = rs.processing.range_doppler_fft(result['baseband'])
286287
287288
💡 License: Automatically detected from module directory (license_RadarSimPy_*.lic)
288-
Or manually specify: rs.initialize_license('/path/to/license.lic')
289+
Or manually specify: rs.set_license('/path/to/license.lic')
289290
290291
�📚 Documentation: https://radarsimx.github.io/radarsimpy/
291292
💬 Support: info@radarsimx.com

src/radarsimpy/includes/radarsimc.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ cdef extern from "libs/license_manager.hpp":
101101
cdef cppclass LicenseManager:
102102
@staticmethod
103103
LicenseManager& GetInstance()
104-
void Initialize(const string& license_file_path)
105-
void Initialize(const vector[string]& license_file_paths)
104+
void SetLicense(const string& license_file_path)
105+
void SetLicense(const vector[string]& license_file_paths)
106106
bint IsLicensed() const
107107
bint IsFreeTier() const
108108
string GetLicenseInfo() const

src/radarsimpy/license.pyx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import os
3030
import glob
3131

3232

33-
def initialize_license(license_file_path=None):
33+
def set_license(license_file_path=None):
3434
"""
35-
Initialize the license manager with a license file.
35+
Set or update the license for RadarSimPy.
3636
3737
Args:
3838
license_file_path (str, optional): Path to license file. If None, automatically
@@ -41,12 +41,13 @@ def initialize_license(license_file_path=None):
4141
Example:
4242
>>> import radarsimpy
4343
>>> # Explicit path
44-
>>> radarsimpy.initialize_license("/path/to/license_RadarSimPy_customer.lic")
44+
>>> radarsimpy.set_license("/path/to/license_RadarSimPy_customer.lic")
4545
>>> if radarsimpy.is_licensed():
4646
... print("Full license active")
4747
4848
Note:
49-
Typically called automatically by the package during import with auto-detected license path.
49+
Can be called multiple times to update or recheck license files.
50+
Typically called automatically by the package during import.
5051
"""
5152
cdef string cpp_license_path
5253
cdef vector[string] cpp_license_paths
@@ -61,15 +62,19 @@ def initialize_license(license_file_path=None):
6162
# Pass all found license files to C++
6263
for lic_file in license_files:
6364
cpp_license_paths.push_back(lic_file.encode('utf-8'))
64-
LicenseManager.GetInstance().Initialize(cpp_license_paths)
65+
LicenseManager.GetInstance().SetLicense(cpp_license_paths)
6566
else:
6667
# No license files found, use empty string (free tier mode)
6768
cpp_license_path = b""
68-
LicenseManager.GetInstance().Initialize(cpp_license_path)
69+
LicenseManager.GetInstance().SetLicense(cpp_license_path)
6970
else:
7071
# Use provided path
7172
cpp_license_path = license_file_path.encode('utf-8')
72-
LicenseManager.GetInstance().Initialize(cpp_license_path)
73+
LicenseManager.GetInstance().SetLicense(cpp_license_path)
74+
75+
76+
# Backwards compatibility alias
77+
initialize_license = set_license
7378

7479

7580
def is_licensed():

0 commit comments

Comments
 (0)