Skip to content

Commit

Permalink
Merge pull request #411 from fredroy/use_importlib
Browse files Browse the repository at this point in the history
Replace deprecated imp by importlib
  • Loading branch information
bakpaul authored May 8, 2024
2 parents 8d8f510 + 8aac31e commit 180913a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bindings/Sofa/package/livecoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,25 @@
#******************************************************************************/

import traceback
import imp
import types
import gc
import os

import importlib.util
import importlib.machinery

def load_source(modname, filename):
loader = importlib.machinery.SourceFileLoader(modname, filename)
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
module = importlib.util.module_from_spec(spec)
# The module is always executed and not cached in sys.modules.
# Uncomment the following line to cache the module.
# sys.modules[module.__name__] = module
loader.exec_module(module)
return module

def mimport(modulename, filename):
f = open(filename, 'r')
return imp.load_module(modulename, f, filename, (modulename, 'r', imp.PY_SOURCE))
return load_source(modulename,filename)

def mreload(modulepath):
try:
Expand Down

0 comments on commit 180913a

Please sign in to comment.