From 15df79fe36eda22fc9b9d82560ebd38c287d13f2 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 18 Apr 2024 12:23:58 +0200 Subject: [PATCH 1/7] Add Fish shell as virtualenv Signed-off-by: Uilian Ries --- reference/tools/env/envvars.rst | 16 ++++++++++------ reference/tools/env/virtualbuildenv.rst | 14 ++++++++++---- reference/tools/env/virtualrunenv.rst | 14 ++++++++++---- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/reference/tools/env/envvars.rst b/reference/tools/env/envvars.rst index d4176f6aaca..88d77e8f95c 100644 --- a/reference/tools/env/envvars.rst +++ b/reference/tools/env/envvars.rst @@ -31,13 +31,16 @@ It will generate automatically a ``my_env_file.bat`` for Windows systems or ``my In Windows, it is possible to opt-in to generate Powershell ``.ps1`` scripts instead of ``.bat`` ones, using the conf ``tools.env.virtualenv:powershell=True``. +In Macos and Linux, it is possible to opt-in to generate Fish ``.fish`` scripts instead of ``.sh`` ones, using the +conf ``tools.env.virtualenv:fish=True``. + Also, by default, Conan will automatically append that launcher file path to a list that will be used to -create a ``conanbuild.bat|sh|ps1`` file aggregating all the launchers in order. The ``conanbuild.sh|bat|ps1`` launcher +create a ``conanbuild.bat|sh|ps1|fish`` file aggregating all the launchers in order. The ``conanbuild.sh|bat|ps1|fish`` launcher will be created after the execution of the ``generate()`` method. The ``scope`` argument (``"build"`` by default) can be used to define different scope of environment files, to aggregate them separately. For example, using a ``scope="run"``, like the ``VirtualRunEnv`` generator does, will -aggregate and create a ``conanrun.bat|sh|ps1`` script: +aggregate and create a ``conanrun.bat|sh|ps1|fish`` script: .. code:: python @@ -45,17 +48,17 @@ aggregate and create a ``conanrun.bat|sh|ps1`` script: env1 = Environment() env1.define("foo", "var") envvars = env1.vars(self, scope="run") - # Will append "my_env_file" to "conanrun.bat|sh|ps1" + # Will append "my_env_file" to "conanrun.bat|sh|ps1|fish" envvars.save_script("my_env_file") -You can also use ``scope=None`` argument to avoid appending the script to the aggregated ``conanbuild.bat|sh|ps1``: +You can also use ``scope=None`` argument to avoid appending the script to the aggregated ``conanbuild.bat|sh|ps1|fish``: .. code:: python env1 = Environment() env1.define("foo", "var") - # Will not append "my_env_file" to "conanbuild.bat|sh|ps1" + # Will not append "my_env_file" to "conanbuild.bat|sh|ps1|fish" envvars = env1.vars(self, scope=None) envvars.save_script("my_env_file") @@ -63,7 +66,7 @@ You can also use ``scope=None`` argument to avoid appending the script to the ag Running with environment files ++++++++++++++++++++++++++++++ -The ``conanbuild.bat|sh|ps1`` launcher will be executed by default before calling every ``self.run()`` command. This +The ``conanbuild.bat|sh|ps1|fish`` launcher will be executed by default before calling every ``self.run()`` command. This would be typically done in the ``build()`` method. You can change the default launcher with the ``env`` argument of ``self.run()``: @@ -74,6 +77,7 @@ You can change the default launcher with the ``env`` argument of ``self.run()``: def build(self): # This will automatically wrap the "foo" command with the correct environment: # source my_env_file.sh && foo + # source my_env_file.fish and foo # my_env_file.bat && foo # powershell my_env_file.ps1 ; cmd c/ foo self.run("foo", env=["my_env_file"]) diff --git a/reference/tools/env/virtualbuildenv.rst b/reference/tools/env/virtualbuildenv.rst index 75f9c3ab73b..b606651e4b5 100644 --- a/reference/tools/env/virtualbuildenv.rst +++ b/reference/tools/env/virtualbuildenv.rst @@ -3,7 +3,7 @@ VirtualBuildEnv =============== -VirtualBuildEnv is a generator that produces a *conanbuildenv* .bat, .ps1 or .sh script containing the environment variables +VirtualBuildEnv is a generator that produces a *conanbuildenv* .bat, .ps1, fish or .sh script containing the environment variables of the build time context: - From the ``self.buildenv_info`` of the direct ``tool_requires`` in "build" context. @@ -49,17 +49,17 @@ Generated files This generator (for example the invocation of ``conan install --tool-require=cmake/3.20.0@ -g VirtualBuildEnv``) will create the following files: -- conanbuildenv-release-x86_64.(bat|ps1|sh): This file contains the actual definition of environment variables +- conanbuildenv-release-x86_64.(bat|ps1|sh|fish): This file contains the actual definition of environment variables like PATH, LD_LIBRARY_PATH, etc, and any other variable defined in the dependencies ``buildenv_info`` corresponding to the ``build`` context, and to the current installed configuration. If a repeated call is done with other settings, a different file will be created. After the execution or sourcing of this file, a new deactivation script will be generated, capturing the current environment, so the environment can be restored when desired. The file will be named also following the current active configuration, like ``deactivate_conanbuildenv-release-x86_64.bat``. -- conanbuild.(bat|ps1|sh): Accumulates the calls to one or more other scripts, in case there are multiple tools +- conanbuild.(bat|ps1|sh|fish): Accumulates the calls to one or more other scripts, in case there are multiple tools in the generate process that create files, to give one single convenient file for all. This only calls the latest specific configuration one, that is, if ``conan install`` is called first for Release build type, - and then for Debug, ``conanbuild.(bat|ps1|sh)`` script will call the Debug one. + and then for Debug, ``conanbuild.(bat|ps1|sh|fish)`` script will call the Debug one. - deactivate_conanbuild.(bat|ps1|sh): Accumulates the deactivation calls defined in the above ``conanbuild.(bat|ps1|sh)``. This file should only be called after the accumulated activate has been called first. @@ -67,6 +67,12 @@ will create the following files: To create ``.ps1`` files required for Powershell it is necessary to set to True the following conf: ``tools.env.virtualenv:powershell``. +.. note:: + + To create ``.fish`` files required for Fish shell it is necessary to set to True the following conf: ``tools.env.virtualenv:fish``. + + When using fish shell, ``deactivate`` files are not generated, instead a function is exported in the environment. + Reference --------- diff --git a/reference/tools/env/virtualrunenv.rst b/reference/tools/env/virtualrunenv.rst index 17882ccc6e7..ad301385ce6 100644 --- a/reference/tools/env/virtualrunenv.rst +++ b/reference/tools/env/virtualrunenv.rst @@ -3,7 +3,7 @@ VirtualRunEnv ============= -``VirtualRunEnv`` is a generator that produces a launcher *conanrunenv* .bat, .ps1 or .sh script containing environment variables +``VirtualRunEnv`` is a generator that produces a launcher *conanrunenv* .bat, .ps1, fish or .sh script containing environment variables of the run time environment. The launcher contains the runtime environment information, anything that is necessary in the environment to actually run @@ -49,12 +49,12 @@ And it can also be fully instantiated in the conanfile ``generate()`` method: Generated files --------------- -- conanrunenv-release-x86_64.(bat|ps1|sh): This file contains the actual definition of environment variables +- conanrunenv-release-x86_64.(bat|ps1|sh|fish): This file contains the actual definition of environment variables like PATH, LD_LIBRARY_PATH, etc, and ``runenv_info`` of dependencies corresponding to the ``host`` context, and to the current installed configuration. If a repeated call is done with other settings, a different file will be created. -- conanrun.(bat|ps1|sh): Accumulates the calls to one or more other scripts to give one single convenient file +- conanrun.(bat|ps1|sh|fish): Accumulates the calls to one or more other scripts to give one single convenient file for all. This only calls the latest specific configuration one, that is, if ``conan install`` is called first for Release build type, - and then for Debug, ``conanrun.(bat|ps1|sh)`` script will call the Debug one. + and then for Debug, ``conanrun.(bat|ps1|sh|fish)`` script will call the Debug one. After the execution of one of those files, a new deactivation script will be generated, capturing the current environment, so the environment can be restored when desired. The file will be named also following the @@ -64,6 +64,12 @@ current active configuration, like ``deactivate_conanrunenv-release-x86_64.bat`` To create ``.ps1`` files required for Powershell it is necessary to set to True the following conf: ``tools.env.virtualenv:powershell``. +.. note:: + + To create ``.fish`` files required for Fish shell it is necessary to set to True the following conf: ``tools.env.virtualenv:fish``. + + When using fish shell, ``deactivate`` files are not generated, instead a function is exported in the environment. + Reference --------- From 1c30b6410f3a4dea47466d384c688656ba3abc9d Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 18 Apr 2024 12:31:08 +0200 Subject: [PATCH 2/7] use explict function name Signed-off-by: Uilian Ries --- reference/tools/env/virtualbuildenv.rst | 2 +- reference/tools/env/virtualrunenv.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/tools/env/virtualbuildenv.rst b/reference/tools/env/virtualbuildenv.rst index b606651e4b5..091eb16932b 100644 --- a/reference/tools/env/virtualbuildenv.rst +++ b/reference/tools/env/virtualbuildenv.rst @@ -71,7 +71,7 @@ will create the following files: To create ``.fish`` files required for Fish shell it is necessary to set to True the following conf: ``tools.env.virtualenv:fish``. - When using fish shell, ``deactivate`` files are not generated, instead a function is exported in the environment. + When using fish shell, ``deactivate`` files are not generated, instead the function ``deactivate_conanbuildenv`` is exported in the environment. Reference --------- diff --git a/reference/tools/env/virtualrunenv.rst b/reference/tools/env/virtualrunenv.rst index ad301385ce6..1991e09f873 100644 --- a/reference/tools/env/virtualrunenv.rst +++ b/reference/tools/env/virtualrunenv.rst @@ -68,7 +68,7 @@ current active configuration, like ``deactivate_conanrunenv-release-x86_64.bat`` To create ``.fish`` files required for Fish shell it is necessary to set to True the following conf: ``tools.env.virtualenv:fish``. - When using fish shell, ``deactivate`` files are not generated, instead a function is exported in the environment. + When using fish shell, ``deactivate`` files are not generated, instead the function ``deactivate_conanbuildenv`` is exported in the environment. Reference --------- From 51c0895670f0cd5c1d507e3311b98fef1b430829 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 20 May 2024 11:44:33 +0200 Subject: [PATCH 3/7] Fix Mac OS name for documentation. Co-authored-by: Andrey Filipenkov --- reference/tools/env/envvars.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tools/env/envvars.rst b/reference/tools/env/envvars.rst index 88d77e8f95c..36560fc3e43 100644 --- a/reference/tools/env/envvars.rst +++ b/reference/tools/env/envvars.rst @@ -31,7 +31,7 @@ It will generate automatically a ``my_env_file.bat`` for Windows systems or ``my In Windows, it is possible to opt-in to generate Powershell ``.ps1`` scripts instead of ``.bat`` ones, using the conf ``tools.env.virtualenv:powershell=True``. -In Macos and Linux, it is possible to opt-in to generate Fish ``.fish`` scripts instead of ``.sh`` ones, using the +In macOS and Linux, it is possible to opt-in to generate Fish ``.fish`` scripts instead of ``.sh`` ones, using the conf ``tools.env.virtualenv:fish=True``. Also, by default, Conan will automatically append that launcher file path to a list that will be used to From 039a8d8061fc3a16493f272bbb0c7843e9780459 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 4 Jun 2024 14:11:10 +0200 Subject: [PATCH 4/7] Update reference/tools/env/virtualbuildenv.rst Co-authored-by: Daniel --- reference/tools/env/virtualbuildenv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tools/env/virtualbuildenv.rst b/reference/tools/env/virtualbuildenv.rst index 091eb16932b..5233907518d 100644 --- a/reference/tools/env/virtualbuildenv.rst +++ b/reference/tools/env/virtualbuildenv.rst @@ -3,7 +3,7 @@ VirtualBuildEnv =============== -VirtualBuildEnv is a generator that produces a *conanbuildenv* .bat, .ps1, fish or .sh script containing the environment variables +VirtualBuildEnv is a generator that produces a *conanbuildenv* .bat, .ps1, .fish or .sh script containing the environment variables of the build time context: - From the ``self.buildenv_info`` of the direct ``tool_requires`` in "build" context. From 7ad8cbb0d34e397efe4d454c35f2f96679ebbb07 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 4 Jun 2024 14:11:18 +0200 Subject: [PATCH 5/7] Update reference/tools/env/virtualbuildenv.rst Co-authored-by: Daniel --- reference/tools/env/virtualbuildenv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tools/env/virtualbuildenv.rst b/reference/tools/env/virtualbuildenv.rst index 5233907518d..6097fa517d5 100644 --- a/reference/tools/env/virtualbuildenv.rst +++ b/reference/tools/env/virtualbuildenv.rst @@ -69,7 +69,7 @@ will create the following files: .. note:: - To create ``.fish`` files required for Fish shell it is necessary to set to True the following conf: ``tools.env.virtualenv:fish``. + To create ``.fish`` files required for Fish shell it is necessary to activate the following conf: ``tools.env.virtualenv:fish=True``. When using fish shell, ``deactivate`` files are not generated, instead the function ``deactivate_conanbuildenv`` is exported in the environment. From 697fa8443aea16fab011e699646ffa08af931f68 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 4 Jun 2024 14:11:24 +0200 Subject: [PATCH 6/7] Update reference/tools/env/virtualrunenv.rst Co-authored-by: Daniel --- reference/tools/env/virtualrunenv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tools/env/virtualrunenv.rst b/reference/tools/env/virtualrunenv.rst index 1991e09f873..75a689840d3 100644 --- a/reference/tools/env/virtualrunenv.rst +++ b/reference/tools/env/virtualrunenv.rst @@ -66,7 +66,7 @@ current active configuration, like ``deactivate_conanrunenv-release-x86_64.bat`` .. note:: - To create ``.fish`` files required for Fish shell it is necessary to set to True the following conf: ``tools.env.virtualenv:fish``. + To create ``.fish`` files required for Fish shell it is necessary to activate the following conf: ``tools.env.virtualenv:fish=True``. When using fish shell, ``deactivate`` files are not generated, instead the function ``deactivate_conanbuildenv`` is exported in the environment. From cfb416250474843e0f668416edc15b07e072f86d Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 4 Jun 2024 14:11:30 +0200 Subject: [PATCH 7/7] Update reference/tools/env/virtualrunenv.rst Co-authored-by: Daniel --- reference/tools/env/virtualrunenv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tools/env/virtualrunenv.rst b/reference/tools/env/virtualrunenv.rst index 75a689840d3..6fd00cf6fb0 100644 --- a/reference/tools/env/virtualrunenv.rst +++ b/reference/tools/env/virtualrunenv.rst @@ -3,7 +3,7 @@ VirtualRunEnv ============= -``VirtualRunEnv`` is a generator that produces a launcher *conanrunenv* .bat, .ps1, fish or .sh script containing environment variables +``VirtualRunEnv`` is a generator that produces a launcher *conanrunenv* .bat, .ps1, .fish or .sh script containing environment variables of the run time environment. The launcher contains the runtime environment information, anything that is necessary in the environment to actually run