From c10fb89ca2910e21a6d953dc8e8d137bc6bb617c Mon Sep 17 00:00:00 2001 From: "j.spijker@ultimaker.com" Date: Thu, 7 Jul 2022 19:32:54 +0200 Subject: [PATCH] Fix source install If the package not in local cache then the user_info isn't defined yet Contributes to CURA-9365 --- generators/VirtualPythonEnv.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/generators/VirtualPythonEnv.py b/generators/VirtualPythonEnv.py index 7a2aaa3..1dd8925 100644 --- a/generators/VirtualPythonEnv.py +++ b/generators/VirtualPythonEnv.py @@ -128,24 +128,18 @@ class VirtualPythonEnv(Generator): conanfile.output.warn( f"Dependency {dep_name} specifies pip_requirements_build in user_info but {req_txt} can't be found!") - if not conanfile.in_local_cache: + if not conanfile.in_local_cache and hasattr(conanfile, "requirements_txts"): # Install the Python requirements of the current conanfile requirements*.txt - pip_req_base_path = Path(conanfile.cpp_info.rootpath, conanfile.cpp_info.resdirs[-1]) - # Add the dev reqs needed for pyinstaller - conanfile.run( - f"{python_venv_interpreter} -m pip install -r {pip_req_base_path.joinpath(conanfile.user_info.pip_requirements_build)} --force-reinstall", - run_environment = True, env = "conanrun") - - # Install the requirements.text for cura - conanfile.run( - f"{python_venv_interpreter} -m pip install -r {pip_req_base_path.joinpath(conanfile.user_info.pip_requirements_git)} --force-reinstall", - run_environment = True, env = "conanrun") - # Do the final requirements last such that these dependencies takes precedence over possible previous installed Python modules. - # Since these are actually shipped with Cura and therefore require hashes and pinned version numbers in the requirements.txt - self.run( - f"{python_venv_interpreter} -m pip install -r {pip_req_base_path.joinpath(conanfile.user_info.pip_requirements)} --force-reinstall", - run_environment = True, - env = "conanrun") + pip_req_base_path = Path(conanfile.source_folder) + + for req_path in sorted(conanfile.requirements_txts, reverse = True): + req_txt = pip_req_base_path.joinpath(req_path) + if req_txt.exists(): + conanfile.run(f"{python_venv_interpreter} -m pip install -r {req_txt} --force-reinstall", run_environment = True, + env = "conanrun") + conanfile.output.success(f"Requirements file {req_txt} installed!") + else: + conanfile.output.warn(f"Requirements file {req_txt} can't be found!") # Add all dlls/dylibs/so found in site-packages to the PATH, DYLD_LIBRARY_PATH and LD_LIBRARY_PATH dll_paths = list({ dll.parent for dll in Path(pythonpath).glob("**/*.dll") })