Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary_c-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Izzard, Robert Dr (Maths & Physics)
binary_c-python
Commits
99b476b4
Commit
99b476b4
authored
2 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
making fix for file xtension
parent
a010cef2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
binarycpython/utils/custom_logging_functions.py
+30
-4
30 additions, 4 deletions
binarycpython/utils/custom_logging_functions.py
with
30 additions
and
4 deletions
binarycpython/utils/custom_logging_functions.py
+
30
−
4
View file @
99b476b4
...
...
@@ -7,6 +7,7 @@ import os
import
uuid
import
ctypes
import
socket
import
platform
import
textwrap
import
subprocess
...
...
@@ -14,6 +15,28 @@ from typing import Tuple, Optional
from
binarycpython.utils.functions
import
temp_dir
,
remove_file
,
verbose_print
def
get_dynamic_library_file_extension
():
"""
Function to find the correct file extension
It will return .so except for exceptions based on platform.platform()
"""
current_platform
=
platform
.
platform
()
# Set up exception list
exception_dict
=
{
'
macOS-12.4
'
:
'
dylib
'
}
# Check in the exception dict, to see if the current platform starts with any of the keys in there.
for
exception_platform_key
in
exception_dict
.
keys
():
if
current_platform
.
startswith
(
exception_platform_key
):
return
exception_dict
[
exception_platform_key
]
# Otherwise return .so
return
'
so
'
def
autogen_C_logging_code
(
logging_dict
:
dict
,
verbosity
:
int
=
0
)
->
Optional
[
str
]:
"""
...
...
@@ -410,9 +433,12 @@ def create_and_load_logging_function(
# Create the sub dir for the custom_logging code
os
.
makedirs
(
custom_logging_dir
,
exist_ok
=
True
)
# Get the correct filename extension (can depend per system)
extension
=
get_dynamic_library_file_extension
()
#
library_name
=
os
.
path
.
join
(
custom_logging_dir
,
"
libcustom_logging_{}.
so
"
.
format
(
uuid
.
uuid4
().
hex
)
custom_logging_dir
,
"
libcustom_logging_{}.
{}
"
.
format
(
uuid
.
uuid4
().
hex
,
extension
)
)
compile_shared_lib
(
...
...
@@ -429,9 +455,9 @@ def create_and_load_logging_function(
)
# Loading library
_
=
ctypes
.
CDLL
(
"
libgslcblas.
so
"
,
mode
=
ctypes
.
RTLD_GLOBAL
)
_
=
ctypes
.
CDLL
(
"
libgsl.
so
"
,
mode
=
ctypes
.
RTLD_GLOBAL
)
_
=
ctypes
.
CDLL
(
"
libbinary_c.
so
"
,
mode
=
ctypes
.
RTLD_GLOBAL
)
_
=
ctypes
.
CDLL
(
"
libgslcblas.
{}
"
.
format
(
extension
)
,
mode
=
ctypes
.
RTLD_GLOBAL
)
_
=
ctypes
.
CDLL
(
"
libgsl.
{}
"
.
format
(
extension
)
,
mode
=
ctypes
.
RTLD_GLOBAL
)
_
=
ctypes
.
CDLL
(
"
libbinary_c.
{}
"
.
format
(
extension
)
,
mode
=
ctypes
.
RTLD_GLOBAL
)
libcustom_logging
=
ctypes
.
CDLL
(
library_name
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment