diff --git a/CuraVersion.py.jinja b/CuraVersion.py.jinja index 515293b8af0..2f0de1872cf 100644 --- a/CuraVersion.py.jinja +++ b/CuraVersion.py.jinja @@ -1,6 +1,8 @@ # Copyright (c) 2023 UltiMaker # Cura is released under the terms of the LGPLv3 or higher. +import importlib.metadata + CuraAppName = "{{ cura_app_name }}" CuraAppDisplayName = "{{ cura_app_display_name }}" CuraVersion = "{{ cura_version }}" @@ -14,4 +16,3 @@ CuraDigitalFactoryURL = "{{ cura_digital_factory_url }}" CuraLatestURL = "{{ cura_latest_url }}" ConanInstalls = {{ conan_installs }} -PythonInstalls = {{ python_installs }} diff --git a/conanfile.py b/conanfile.py index 47ca471e2b8..a4b6dd3d10a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -140,26 +140,6 @@ def _conan_installs(self): } return conan_installs - def _python_installs(self): - self.output.info("Collecting python installs") - python_installs = {} - - outer = '"' if self.settings.os == "Windows" else "'" - inner = "'" if self.settings.os == "Windows" else '"' - buffer = StringIO() - env_path = str(self._root_dir.joinpath("conanrun")) - self.run(f"""python -c {outer}import importlib.metadata; print({inner};{inner}.join([(package.metadata[{inner}Name{inner}]+{inner},{inner}+ package.metadata[{inner}Version{inner}]) for package in importlib.metadata.distributions()])){outer}""", - env = env_path, - stdout = buffer) - - packages = str(buffer.getvalue()).strip('\r\n').split(";") - for package in packages: - name, version = package.split(",") - python_installs[name] = {"version": version} - - print(python_installs) - return python_installs - def _generate_cura_version(self, location): with open(os.path.join(self.recipe_folder, "CuraVersion.py.jinja"), "r") as f: cura_version_py = Template(f.read()) @@ -188,7 +168,6 @@ def _generate_cura_version(self, location): cura_digital_factory_url = self.conan_data["urls"][self._urls]["digital_factory_url"], cura_latest_url=self.conan_data["urls"][self._urls]["cura_latest_url"], conan_installs=self._conan_installs(), - python_installs=self._python_installs(), )) def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file, cura_source_folder): diff --git a/cura/__init__.py b/cura/__init__.py index e69de29bb2d..d4ff0f2a6d6 100644 --- a/cura/__init__.py +++ b/cura/__init__.py @@ -0,0 +1,4 @@ +import importlib.metadata +from . import CuraVersion + +CuraVersion.PythonInstalls = {package.metadata['Name']: {'version': package.metadata['Version']} for package in importlib.metadata.distributions()}