Przeglądaj źródła

Merge branch 'fix/export_without_constraint_download' into 'master'

Tools: The Python dependency checker should not update the constraint file

Closes IDF-6010

See merge request espressif/esp-idf!20460
Roland Dobai 3 lat temu
rodzic
commit
e2d275a382
2 zmienionych plików z 11 dodań i 3 usunięć
  1. 1 1
      docs/en/api-guides/tools/idf-tools.rst
  2. 10 2
      tools/idf_tools.py

+ 1 - 1
docs/en/api-guides/tools/idf-tools.rst

@@ -111,7 +111,7 @@ Any mirror server can be used provided the URL matches the ``github.com`` downlo
 
 * ``install-python-env``: Create a Python virtual environment in the ``${IDF_TOOLS_PATH}/python_env`` directory and install there the required Python packages. An optional ``--features`` argument allows one to specify a comma-separated list of features to be added or removed. Feature that begins with ``-`` will be removed and features with ``+`` or without any sign will be added. Example syntax for removing feature ``XY`` is ``--features=-XY`` and for adding ``--features=+XY`` or ``--features=XY``. If both removing and adding options are provided with the same feature, no operation is performed. For each feature a requirements file must exist. For example, feature ``XY`` is a valid feature if ``${IDF_PATH}/tools/requirements/requirements.XY.txt`` is an existing file with a list of Python packages to be installed. There is one mandatory ``core`` feature ensuring core functionality of ESP-IDF (build, flash, monitor, debug in console). There can be an arbitrary number of optional features. The selected list of features is stored in ``idf-env.json``. The requirement files contain a list of the desired Python packages to be installed and ``espidf.constraints.*.txt`` downloaded from https://dl.espressif.com and stored in ``${IDF_TOOLS_PATH}`` the package version requirements for a given ESP-IDF version. Althought it is not recommended, the download and use of constraint files can be disabled with the ``--no-constraints`` argument or setting the ``IDF_PYTHON_CHECK_CONSTRAINTS`` environment variable to ``no``.
 
-* ``check-python-dependencies``: Checks if all required Python packages are installed. Packages from ``${IDF_PATH}/tools/requirements/requirements.*.txt`` files selected by the feature list of ``idf-env.json`` are checked with the package versions specified in the ``espidf.constraints.*.txt`` file. The constraint file will be downloaded from https://dl.espressif.com if this step hasn't been done already in the last day. The use of constraints files can be disabled similarly to the ``install-python-env`` command.
+* ``check-python-dependencies``: Checks if all required Python packages are installed. Packages from ``${IDF_PATH}/tools/requirements/requirements.*.txt`` files selected by the feature list of ``idf-env.json`` are checked with the package versions specified in the ``espidf.constraints.*.txt`` file. The constraint file is downloaded with ``install-python-env`` command. The use of constraints files can be disabled similarly to the ``install-python-env`` command.
 
 * ``uninstall``: Print and remove tools, that are currently not used by active ESP-IDF version.
 

+ 10 - 2
tools/idf_tools.py

@@ -1885,12 +1885,20 @@ def get_requirements(new_features):  # type: (str) -> list[str]
     return [feature_to_requirements_path(feature) for feature in features]
 
 
-def get_constraints(idf_version):  # type: (str) -> str
+def get_constraints(idf_version, online=True):  # type: (str, bool) -> str
     constraint_file = 'espidf.constraints.v{}.txt'.format(idf_version)
     constraint_path = os.path.join(global_idf_tools_path or '', constraint_file)
     constraint_url = '/'.join([IDF_DL_URL, constraint_file])
     temp_path = constraint_path + '.tmp'
 
+    if not online:
+        if os.path.isfile(constraint_path):
+            return constraint_path
+        else:
+            fatal(f'{constraint_path} doesn\'t exist. Perhaps you\'ve forgotten to run the install scripts. '
+                  f'Please check the installation guide for more information.')
+            raise SystemExit(1)
+
     mkdir_p(os.path.dirname(temp_path))
 
     try:
@@ -2066,7 +2074,7 @@ def action_check_python_dependencies(args):  # type: ignore
         raise SystemExit(1)
 
     if use_constraints:
-        constr_path = get_constraints(idf_version)
+        constr_path = get_constraints(idf_version, online=False)  # keep offline for checking
         info('Constraint file: {}'.format(constr_path))
 
     info('Requirement files:')