From e498119e0de3d1bc7694a85352048c07855da3a6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Jul 2022 18:18:26 +0300 Subject: [PATCH] Improved project dependency resolving when using the `pio project init --ide` command --- HISTORY.rst | 5 ++++ platformio/project/commands/init.py | 45 ++++++++++++++++------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 33bf355d..be4ff36a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,6 +13,11 @@ PlatformIO Core 6 **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** +6.1.4 (2022-??-??) +~~~~~~~~~~~~~~~~~~ + +* Improved project dependency resolving when using the `pio project init --ide `__ command + 6.1.3 (2022-07-18) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/project/commands/init.py b/platformio/project/commands/init.py index baae29ec..ca57de34 100644 --- a/platformio/project/commands/init.py +++ b/platformio/project/commands/init.py @@ -79,27 +79,32 @@ def project_init_cmd( elif board: update_board_envs(project_dir, board, project_option, env_prefix) - # resolve project dependencies - if not no_install_dependencies and (environment or board): - install_project_dependencies( - options=dict( - project_dir=project_dir, - environments=[environment] if environment else [], - silent=silent, - ) - ) - - if ide: - if not silent: - click.echo( - "Updating metadata for the %s IDE..." % click.style(ide, fg="cyan") - ) - with fs.cd(project_dir): - config = ProjectConfig.get_instance( - os.path.join(project_dir, "platformio.ini") - ) + with fs.cd(project_dir): + generator = None + config = ProjectConfig.get_instance(os.path.join(project_dir, "platformio.ini")) + if ide: config.validate() - ProjectGenerator(config, environment, ide, board).generate() + # init generator and pick the best env if user didn't specify + generator = ProjectGenerator(config, environment, ide, board) + if not environment: + environment = generator.env_name + + # resolve project dependencies + if not no_install_dependencies and (environment or board): + install_project_dependencies( + options=dict( + project_dir=project_dir, + environments=[environment] if environment else [], + silent=silent, + ) + ) + + if generator: + if not silent: + click.echo( + "Updating metadata for the %s IDE..." % click.style(ide, fg="cyan") + ) + generator.generate() if is_new_project: init_cvs_ignore(project_dir)