diff --git a/.github/requirements-ci.txt b/.github/requirements-ci.txt index 847d93385a1..9f5ac3b2eae 100644 --- a/.github/requirements-ci.txt +++ b/.github/requirements-ci.txt @@ -1,7 +1,3 @@ # Installing PyAVD from source. # The package path below is relative to the repo root and will only work if the pip install is executed from there. -./python-avd -# The -r path is relative to this file. --r ../ansible_collections/arista/avd/requirements.txt -# Needed for molecule -jsonschema-rs>=0.24 +./python-avd[ansible-collection] diff --git a/.github/workflows/new-cvp-integration.yml b/.github/workflows/new-cvp-integration.yml index 733f90afc47..d8a18eab32e 100644 --- a/.github/workflows/new-cvp-integration.yml +++ b/.github/workflows/new-cvp-integration.yml @@ -6,6 +6,13 @@ on: workflow_dispatch concurrency: group: ${{ github.workflow }}-${{ github.head_ref }} + +env: + # Set -vvv is ACTIONS_STEP_DEBUG is set + # Apparently it is set in secrets when running with debug + ANSIBLE_VERBOSITY: ${{ secrets.ACTIONS_STEP_DEBUG && 3 || 0 }} + AVD_NEVER_RUN_FROM_SOURCE: 1 + jobs: # ----------------------------------------------- # # CV INTEGRATION MOLECULE TEST FOR CV_WORKFLOW # diff --git a/.github/workflows/pull-request-management.yml b/.github/workflows/pull-request-management.yml index 7738c5a8468..ca0cba4f09a 100644 --- a/.github/workflows/pull-request-management.yml +++ b/.github/workflows/pull-request-management.yml @@ -11,6 +11,7 @@ env: # Set -vvv is ACTIONS_STEP_DEBUG is set # Apparently it is set in secrets when running with debug ANSIBLE_VERBOSITY: ${{ secrets.ACTIONS_STEP_DEBUG && 3 || 0 }} + AVD_NEVER_RUN_FROM_SOURCE: 1 jobs: file-changes: @@ -111,7 +112,7 @@ jobs: python-version: ${{ matrix.python_version }} - name: 'Install Python requirements' run: | - pip install -r ansible_collections/arista/avd/requirements-dev.txt -r ansible_collections/arista/avd/requirements.txt --upgrade + pip install -r .github/requirements-ci.txt -r ansible_collections/arista/avd/requirements-dev.txt --upgrade # ----------------------------------- # # EOS CLI CONFIG GEN MOLECULE @@ -432,7 +433,7 @@ jobs: 3.13 - name: 'Install Python & Ansible requirements' run: | - pip install -r ansible_collections/arista/avd/requirements-dev.txt -r ansible_collections/arista/avd/requirements.txt --upgrade + pip install -r .github/requirements-ci.txt -r ansible_collections/arista/avd/requirements-dev.txt --upgrade ansible-galaxy collection install -r ansible_collections/arista/avd/collections.yml - name: 'Run ansible-test integration test cases' run: | diff --git a/ansible_collections/arista/avd/docs/contribution/development-tooling.md b/ansible_collections/arista/avd/docs/contribution/development-tooling.md index 7c0d7d0d641..59389bca301 100644 --- a/ansible_collections/arista/avd/docs/contribution/development-tooling.md +++ b/ansible_collections/arista/avd/docs/contribution/development-tooling.md @@ -56,7 +56,7 @@ Developing with your local Python environment requires you to configure and inst Recommended steps with Python virtual environment: 1. Create and activate a Python virtual environment. -2. Install Python requirements located in the AVD repository: [requirements-dev.txt](https://github.com/aristanetworks/avd/blob/devel/ansible_collections/arista/avd/requirements-dev.txt) and [requirements.txt](https://github.com/aristanetworks/avd/blob/devel/ansible_collections/arista/avd/requirements.txt). +2. Install Python requirements located in the AVD repository: [requirements-dev.txt](https://github.com/aristanetworks/avd/blob/devel/ansible_collections/arista/avd/requirements-dev.txt). !!! note Ensure the virtual environment is located outside of the AVD project directory. @@ -72,7 +72,7 @@ source avd-venv/bin/activate # The installation _must_ be performed from the root of the cloned avd repository. cd avd # Requirements files are located in `ansible_collections/arista/avd` of the avd repository. -pip3 install -r ansible_collections/arista/avd/requirements-dev.txt -r ansible_collections/arista/avd/requirements.txt --upgrade +pip3 install -r ansible_collections/arista/avd/requirements-dev.txt --upgrade ``` !!! note diff --git a/ansible_collections/arista/avd/plugins/__init__.py b/ansible_collections/arista/avd/plugins/__init__.py index 1a93e0335b6..473eccb2bd4 100644 --- a/ansible_collections/arista/avd/plugins/__init__.py +++ b/ansible_collections/arista/avd/plugins/__init__.py @@ -4,11 +4,12 @@ from __future__ import annotations from contextlib import suppress +from os import environ from pathlib import Path PYTHON_AVD_PATH = Path(__file__).parents[4] / "python-avd" RUNNING_FROM_SOURCE_PATH = PYTHON_AVD_PATH / "pyavd/running_from_src.txt" -RUNNING_FROM_SOURCE = RUNNING_FROM_SOURCE_PATH.exists() +RUNNING_FROM_SOURCE = RUNNING_FROM_SOURCE_PATH.exists() and not environ.get("AVD_NEVER_RUN_FROM_SOURCE") if RUNNING_FROM_SOURCE: import sys diff --git a/containers/dev/.devcontainer/entrypoint.sh b/containers/dev/.devcontainer/entrypoint.sh index 5bae915c88e..66dafa7c6a5 100644 --- a/containers/dev/.devcontainer/entrypoint.sh +++ b/containers/dev/.devcontainer/entrypoint.sh @@ -14,9 +14,10 @@ if [ -z "$(command -v ansible)" ]; then pip install "pyavd[ansible] @ ${PYAVD_INSTALL_LOCATION}" ansible-galaxy collection install --force ${AVD_INSTALL_PATH} # otherwise install requirements and collection from container workspace - elif [ -f ${CONTAINER_WSF_AVD_PATH}/requirements.txt ] && [ -f ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt ] ; then - # use editable install for requirements - pip install -r ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt -r ${CONTAINER_WSF_AVD_PATH}/requirements.txt + elif [ -f ${CONTAINER_WORKSPACE}/python-avd/pyproject.toml ] && [ -f ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt ] ; then + # Install pyavd from source and dev requirements from file + pip install ${CONTAINER_WORKSPACE}/python-avd[ansible-collection] -r ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt + # Install arista.avd collection from source ansible-galaxy collection install --force ${CONTAINER_WSF_AVD_PATH} fi diff --git a/python-avd/pyavd/constants.py b/python-avd/pyavd/constants.py index dbd65ccea82..19ad221be1f 100644 --- a/python-avd/pyavd/constants.py +++ b/python-avd/pyavd/constants.py @@ -1,9 +1,10 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. +from os import environ from pathlib import Path -RUNNING_FROM_SRC = Path(__file__).parent.joinpath("running_from_src.txt").exists() +RUNNING_FROM_SRC = Path(__file__).parent.joinpath("running_from_src.txt").exists() and not environ.get("AVD_NEVER_RUN_FROM_SOURCE") EOS_CLI_CONFIG_GEN_SCHEMA_ID = "eos_cli_config_gen" EOS_DESIGNS_SCHEMA_ID = "eos_designs" EOS_CLI_CONFIG_GEN_JINJA2_CONFIG_TEMPLATE = "eos-intended-config.j2"