Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated load_module by exec_module #741

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions mujoco_py/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from distutils.core import Extension
from distutils.dist import Distribution
from distutils.sysconfig import customize_compiler
from importlib.machinery import ExtensionFileLoader
from importlib.util import module_from_spec, spec_from_file_location
from os.path import abspath, dirname, exists, join, getmtime
from random import choice
from shutil import move
Expand Down Expand Up @@ -126,8 +126,11 @@ def _ensure_set_env_var(var_name, lib_path):

def load_dynamic_ext(name, path):
""" Load compiled shared object and return as python module. """
loader = ExtensionFileLoader(name, path)
return loader.load_module()
spec = spec_from_file_location(name, path)
module = module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
return module


class custom_build_ext(build_ext):
Expand Down