|
|
|
@ -12,7 +12,10 @@ from conan.tools.env import VirtualRunEnv |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deploy(graph, output_folder, **kwargs): |
|
|
|
def deploy(graph, output_folder, **kwargs): |
|
|
|
conanfile: ConanFile = graph.root.conanfile |
|
|
|
if graph.root.conanfile.name is None: |
|
|
|
|
|
|
|
conanfile: ConanFile = graph.nodes[1].conanfile |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
conanfile: ConanFile = graph.root.conanfile |
|
|
|
if output_folder is None: |
|
|
|
if output_folder is None: |
|
|
|
output_folder = "venv" |
|
|
|
output_folder = "venv" |
|
|
|
|
|
|
|
|
|
|
|
@ -25,10 +28,11 @@ def deploy(graph, output_folder, **kwargs): |
|
|
|
except KeyError: |
|
|
|
except KeyError: |
|
|
|
py_interp = sys.executable |
|
|
|
py_interp = sys.executable |
|
|
|
|
|
|
|
|
|
|
|
run_env = VirtualRunEnv(conanfile) |
|
|
|
vr = VirtualRunEnv(conanfile) |
|
|
|
env = run_env.environment() |
|
|
|
env = vr.environment() |
|
|
|
sys_vars = env.vars(conanfile, scope="run") |
|
|
|
sys_vars = env.vars(conanfile, scope="run") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conanfile.output.info(f"Using Python interpreter '{py_interp}' to create Virtual Environment in '{output_folder}'") |
|
|
|
with sys_vars.apply(): |
|
|
|
with sys_vars.apply(): |
|
|
|
conanfile.run(f"""{py_interp} -m venv --copies {output_folder}""", env="conanrun", scope="run") |
|
|
|
conanfile.run(f"""{py_interp} -m venv --copies {output_folder}""", env="conanrun", scope="run") |
|
|
|
|
|
|
|
|
|
|
|
@ -59,7 +63,7 @@ def deploy(graph, output_folder, **kwargs): |
|
|
|
env.prepend_path("DYLD_LIBRARY_PATH", os.path.join(output_folder, bin_venv_path)) |
|
|
|
env.prepend_path("DYLD_LIBRARY_PATH", os.path.join(output_folder, bin_venv_path)) |
|
|
|
env.prepend_path("PYTHONPATH", pythonpath) |
|
|
|
env.prepend_path("PYTHONPATH", pythonpath) |
|
|
|
env.unset("PYTHONHOME") |
|
|
|
env.unset("PYTHONHOME") |
|
|
|
venv_vars = env.vars(conanfile, scope="run") |
|
|
|
venv_vars = env.vars(graph.root.conanfile, scope="run") |
|
|
|
venv_vars.save_script("virtual_python_env") |
|
|
|
venv_vars.save_script("virtual_python_env") |
|
|
|
|
|
|
|
|
|
|
|
# Install some base_packages |
|
|
|
# Install some base_packages |
|
|
|
@ -67,12 +71,12 @@ def deploy(graph, output_folder, **kwargs): |
|
|
|
conanfile.run(f"""{py_interp_venv} -m pip install wheel setuptools""", env="conanrun") |
|
|
|
conanfile.run(f"""{py_interp_venv} -m pip install wheel setuptools""", env="conanrun") |
|
|
|
|
|
|
|
|
|
|
|
if conanfile.settings.os != "Windows": |
|
|
|
if conanfile.settings.os != "Windows": |
|
|
|
content = f"source {os.path.join(output_folder, 'conan', 'virtual_python_env.sh')}\n" + load(conanfile, |
|
|
|
content = f"source {os.path.join(output_folder, 'conan', 'virtual_python_env.sh')}\n" + load(graph.root.conanfile, |
|
|
|
os.path.join( |
|
|
|
os.path.join( |
|
|
|
output_folder, |
|
|
|
output_folder, |
|
|
|
bin_venv_path, |
|
|
|
bin_venv_path, |
|
|
|
"activate")) |
|
|
|
"activate")) |
|
|
|
save(conanfile, os.path.join(output_folder, bin_venv_path, "activate"), content) |
|
|
|
save(graph.root.conanfile, os.path.join(output_folder, bin_venv_path, "activate"), content) |
|
|
|
|
|
|
|
|
|
|
|
pip_requirements = {} |
|
|
|
pip_requirements = {} |
|
|
|
if conanfile.conan_data is not None and "pip_requirements" in conanfile.conan_data: |
|
|
|
if conanfile.conan_data is not None and "pip_requirements" in conanfile.conan_data: |
|
|
|
@ -81,7 +85,7 @@ def deploy(graph, output_folder, **kwargs): |
|
|
|
if name not in pip_requirements or Version(pip_requirements[name]["version"]) < Version(req["version"]): |
|
|
|
if name not in pip_requirements or Version(pip_requirements[name]["version"]) < Version(req["version"]): |
|
|
|
pip_requirements[name] = req |
|
|
|
pip_requirements[name] = req |
|
|
|
|
|
|
|
|
|
|
|
for name, dep in reversed(conanfile.dependencies.host.items()): |
|
|
|
for name, dep in reversed(graph.root.conanfile.dependencies.host.items()): |
|
|
|
if dep.conan_data is None: |
|
|
|
if dep.conan_data is None: |
|
|
|
continue |
|
|
|
continue |
|
|
|
if "pip_requirements" in dep.conan_data: |
|
|
|
if "pip_requirements" in dep.conan_data: |
|
|
|
@ -101,7 +105,7 @@ def deploy(graph, output_folder, **kwargs): |
|
|
|
requirements_txt += f" --hash={hash_str}" |
|
|
|
requirements_txt += f" --hash={hash_str}" |
|
|
|
requirements_txt += "\n" |
|
|
|
requirements_txt += "\n" |
|
|
|
|
|
|
|
|
|
|
|
save(conanfile, os.path.join(output_folder, 'conan', 'requirements.txt'), requirements_txt) |
|
|
|
save(graph.root.conanfile, os.path.join(output_folder, 'conan', 'requirements.txt'), requirements_txt) |
|
|
|
with venv_vars.apply(): |
|
|
|
with venv_vars.apply(): |
|
|
|
conanfile.run(f"{py_interp_venv} -m pip install -r {os.path.join(output_folder, 'conan', 'requirements.txt')}", |
|
|
|
conanfile.run(f"{py_interp_venv} -m pip install -r {os.path.join(output_folder, 'conan', 'requirements.txt')}", |
|
|
|
env="conanrun") |
|
|
|
env="conanrun") |
|
|
|
|