Repository: OpenBB-finance/OpenBBTerminal
File: openbb_platform/dev_install.py (Python)

Code before:
openbb-technical = { path = "./extensions/technical", optional = true, develop = true }
"""

pyproject_toml = toml.load(PYPROJECT)
pyproject_toml["tool"]["poetry"]["dependencies"] = toml.loads(LOCAL_DEPS)["tool"][
    "poetry"
]["dependencies"]

TEMP_PYPROJECT = toml.dumps(pyproject_toml)


def install_local(_extras: bool = False):
    """Install the Platform locally for development purposes.

    Installs the Platform in editable mode, instead of copying the source code to
    the site-packages directory. This makes any changes immediately available
    to the interpreter.

    Parameters
    ----------
    _extras : bool, optional
        Whether to install the Platform with the extra dependencies, by default False
    """
    original_lock = LOCK.read_text()
    original_pyproject = PYPROJECT.read_text()
    extras_args = ["-E", "all", "--with", "dev"] if _extras else []

    try:
        # we create a temporary pyproject.toml
        with open(PYPROJECT, "w", encoding="utf-8", newline="\n") as f:
            f.write(TEMP_PYPROJECT)

        CMD = [sys.executable, "-m", "poetry"]

        subprocess.run(  # noqa: PLW1510
            CMD + ["lock", "--no-update"], cwd=PLATFORM_PATH, check=True  # noqa: S603
        )
        subprocess.run(  # noqa: PLW1510
            CMD + ["install"] + extras_args, cwd=PLATFORM_PATH, check=True  # noqa: S603
        )

    except (Exception, KeyboardInterrupt) as e:
        print(e)  # noqa: T201
        print("Restoring pyproject.toml and poetry.lock")  # noqa: T201

    # we restore the original pyproject.toml
    with open(PYPROJECT, "w", encoding="utf-8", newline="\n") as f:
        f.write(original_pyproject)

    # we restore the original poetry.lock
    with open(LOCK, "w", encoding="utf-8", newline="\n") as f:

Review comment (suggestion):
I think this is not required. IIRC this was needed before poetry 1.4 and we're on latest (1.7ish). Can you check please

Code after:
openbb-quantitative = { path = "./extensions/quantitative", optional = true, develop = true }
openbb-technical = { path = "./extensions/technical", optional = true, develop = true }
"""

pyproject_toml = toml.load(PYPROJECT)
pyproject_toml["tool"]["poetry"]["dependencies"] = toml.loads(LOCAL_DEPS)["tool"][
    "poetry"
]["dependencies"]

TEMP_PYPROJECT = toml.dumps(pyproject_toml)


def install_local(_extras: bool = False):
    """Install the Platform locally for development purposes.

    Installs the Platform in editable mode, instead of copying the source code to
    the site-packages directory. This makes any changes immediately available
    to the interpreter.

    Parameters
    ----------
    _extras : bool, optional
        Whether to install the Platform with the extra dependencies, by default False
    """
    original_lock = LOCK.read_text()
    original_pyproject = PYPROJECT.read_text()
    extras_args = ["-E", "all"] if _extras else []

    try:
        # we create a temporary pyproject.toml
        with open(PYPROJECT, "w", encoding="utf-8", newline="\n") as f:
            f.write(TEMP_PYPROJECT)

        CMD = [sys.executable, "-m", "poetry"]

        subprocess.run(  # noqa: PLW1510
            CMD + ["lock", "--no-update"], cwd=PLATFORM_PATH, check=True  # noqa: S603
        )
        subprocess.run(  # noqa: PLW1510
            CMD + ["install"] + extras_args, cwd=PLATFORM_PATH, check=True  # noqa: S603
        )

    except (Exception, KeyboardInterrupt) as e:
        print(e)  # noqa: T201
        print("Restoring pyproject.toml and poetry.lock")  # noqa: T201

    # we restore the original pyproject.toml
    with open(PYPROJECT, "w", encoding="utf-8", newline="\n") as f:
        f.write(original_pyproject)

    # we restore the original poetry.lock