diff --git a/docs/requirements.md b/docs/requirements.md index a380f65c..3fb46ddb 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -9,6 +9,10 @@ MacPorts](http://sourceforge.net/projects/pycam/forums/forum/860183/topic/380009 Please document your experiences here, if you successfully used PyCAM with other operating systems. +**Note for Python 3.12+:** The deprecated `imp` module was removed in Python 3.12. +If you're running Python 3.12 or newer, make sure you have the latest version of PyCAM +with the updated plugin system that uses `importlib` instead. + Linux ----- @@ -41,6 +45,26 @@ Run the following command in a *root* terminal: yum install python3-gi python3-opengl +### Arch Linux + +Run the following command in a terminal: + + sudo pacman -S python-gobject python-opengl gtk3 + +### Using virtualenv + +If you want to run PyCAM in a Python virtualenv, you need to create the virtualenv with +access to system site packages, since GTK and its Python bindings are typically installed +at the system level: + + python -m venv --system-site-packages venv + source venv/bin/activate + pip install -r requirements.txt + python pycam/run_gui.py + +Without the `--system-site-packages` flag, the virtualenv won't be able to access the +system-installed `python3-gi` (PyGObject) package, and PyCAM will fail to start. + Windows ------- diff --git a/pycam/Plugins/__init__.py b/pycam/Plugins/__init__.py index 17b80b70..1af1faf7 100644 --- a/pycam/Plugins/__init__.py +++ b/pycam/Plugins/__init__.py @@ -17,7 +17,7 @@ along with PyCAM. If not, see . """ -import imp +import importlib.util import inspect import os import uuid @@ -268,9 +268,11 @@ def import_plugins(self, directory=None, ignore_names=None): _log.info("Skipping plugin %s (marked as 'ignore')", mod_name) continue try: - mod_file, mod_filename, mod_desc = imp.find_module(mod_name, [directory]) + mod_filename = os.path.join(directory, filename) full_mod_name = "pycam.Plugins.%s" % mod_name - mod = imp.load_module(full_mod_name, mod_file, mod_filename, mod_desc) + spec = importlib.util.spec_from_file_location(full_mod_name, mod_filename) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) except ImportError as exc: _log.info("Skipping plugin %s: %s", os.path.join(directory, filename), exc) continue