Skip to content

Commit 635ff00

Browse files
authored
global.conf hashlib (#4338)
1 parent 957257b commit 635ff00

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

reference/config_files/global_conf.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,21 @@ Conan also injects ``detect_api`` (non-stable, read the reference) to the jinja
8989
For more information on how to use it, please check :ref:`the detect_api section
9090
<reference_config_files_profiles_detect_api>` in the profiles reference.
9191

92-
The Python packages passed to render the template are ``os`` and ``platform`` for all platforms and ``distro`` in Linux platforms.
92+
The Python packages passed to render the template are ``os``, ``platform`` and ``hashlib`` for all platforms and ``distro`` in Linux platforms.
9393
Additionally, the variables ``conan_version`` and ``conan_home_folder`` are also available.
9494

95+
The ``os``, ``platform`` and ``distro`` can be useful to perform different system checks, while the ``hashlib`` library can be convenient
96+
to compute unique hashes based on the ``conan_home_folder`` to define unique strings, for example for unique shorter paths in Windows in
97+
CI systems when sometimes the path length can be an issue, for example:
98+
99+
.. code-block:: python
100+
101+
# compute a unique hash based on the current home folder
102+
{% set h = hashlib.new("sha256", conan_home_folder.encode(),
103+
usedforsecurity=False).hexdigest() %}
104+
# and use the first 6 characters to compose a short path for package storage
105+
core.cache:storage_path=C:/conan_{{h[:6]}}
106+
95107
96108
Configuration data types
97109
------------------------

0 commit comments

Comments
 (0)