From: Martin Skorupski Date: Fri, 5 Apr 2024 13:13:24 +0000 (+0200) Subject: Create python environment for oam X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=964f36e41f3f75a5593ba8e855010d9602954a01;p=oam.git Create python environment for oam - folder ".oam" should be used Issue-ID: OAM-405 Change-Id: Id92bf053f804a4d6c847a6799533c769f5a48956 Signed-off-by: Martin Skorupski --- diff --git a/code/network-generator/.gitignore b/code/network-generator/.gitignore index 403392b..64369ef 100644 --- a/code/network-generator/.gitignore +++ b/code/network-generator/.gitignore @@ -130,6 +130,7 @@ celerybeat.pid # Environments .env .venv +.oam env/ venv/ ENV/ diff --git a/code/network-generator/CONTRIBUTING.md b/code/network-generator/CONTRIBUTING.md index 478386a..7a22c5d 100644 --- a/code/network-generator/CONTRIBUTING.md +++ b/code/network-generator/CONTRIBUTING.md @@ -22,7 +22,7 @@ sudo apt install python3.10-venv ## Setting up your own virtual environment -Run `make virtualenv` to create a virtual environment. +Run `make virtual_env_4_oam` to create a virtual environment. then activate it with `source .venv/bin/activate`. ## Install the project in develop mode @@ -85,18 +85,18 @@ This project comes with a `Makefile` that contains a number of useful utility. Usage: make Targets: -help: ## Show the help. -install: ## Install the project in dev mode. -fmt: ## Format code using black & isort. -lint: ## Run pep8, black, mypy linters. -test: lint ## Run tests and generate coverage report. -watch: ## Run tests on every change. -clean: ## Clean unused files. -virtualenv: ## Create a virtual environment. -release: ## Create a new tag for release. -docs: ## Build the documentation. -switch-to-poetry: ## Switch to poetry package manager. -init: ## Initialize the project based on an application template. +help: ## Show the help. +install: ## Install the project in dev mode. +fmt: ## Format code using black & isort. +lint: ## Run pep8, black, mypy linters. +test: lint ## Run tests and generate coverage report. +watch: ## Run tests on every change. +clean: ## Clean unused files. +virtual_env_4_oam: ## Create a virtual environment. +release: ## Create a new tag for release. +docs: ## Build the documentation. +switch-to-poetry: ## Switch to poetry package manager. +init: ## Initialize the project based on an application template. ``` ## Making a new release diff --git a/code/network-generator/Makefile b/code/network-generator/Makefile index ab2b357..d396d83 100644 --- a/code/network-generator/Makefile +++ b/code/network-generator/Makefile @@ -1,5 +1,5 @@ .ONESHELL: -ENV_PREFIX=$(shell python -c "if __import__('pathlib').Path('.venv/bin/pip').exists(): print('.venv/bin/')") +ENV_PREFIX=$(shell python -c "if __import__('pathlib').Path('.oam/bin/pip').exists(): print('.oam/bin/')") USING_POETRY=$(shell grep "tool.poetry" pyproject.toml && echo "yes") .PHONY: help @@ -21,7 +21,7 @@ show: ## Show the current environment. .PHONY: install install: ## Install the project in dev mode. @if [ "$(USING_POETRY)" ]; then poetry install && exit; fi - @echo "Don't forget to run 'make virtualenv' if you got errors." + @echo "Don't forget to run 'make virtual_env_4_oam' if you got errors." $(ENV_PREFIX)pip install -e .[test] .PHONY: format @@ -64,16 +64,19 @@ clean: ## Clean unused files. @rm -rf .tox/ @rm -rf docs/_build -.PHONY: virtualenv -virtualenv: ## Create a virtual environment. +.PHONY: virtual_env_4_oam +virtual_env_4_oam: ## Create a virtual environment for O-RAN-SC OAM project. @if [ "$(USING_POETRY)" ]; then poetry install && exit; fi - @echo "creating virtualenv ..." - @rm -rf .venv - @python3 -m venv .venv - @./.venv/bin/pip install -U pip - @./.venv/bin/pip install -e .[test] + @echo "Creating a virtual environment for O-RAN-SC OAM project ..." + @rm -rf .oam + @python3 -m venv .oam + @./.oam/bin/pip install -U pip + @./.oam/bin/pip install -e .[test] + @./.oam/bin/pip install -r requirements.txt + @./.oam/bin/pip install -r requirements-test.txt + @echo - @echo "!!! Please run 'source .venv/bin/activate' to enable the environment !!!" + @echo "!!! Please run 'source .oam/bin/activate' to enable the OAM environment !!!" .PHONY: release release: ## Create a new tag for release. @@ -98,7 +101,7 @@ docs: ## Build the documentation. switch-to-poetry: ## Switch to poetry package manager. @echo "Switching to poetry ..." @if ! poetry --version > /dev/null; then echo 'poetry is required, install from https://python-poetry.org/'; exit 1; fi - @rm -rf .venv + @rm -rf .oam @poetry init --no-interaction --name=a_flask_test --author=rochacbruno @echo "" >> pyproject.toml @echo "[tool.poetry.scripts]" >> pyproject.toml diff --git a/code/network-generator/README.md b/code/network-generator/README.md index 0f91dfb..66a6326 100644 --- a/code/network-generator/README.md +++ b/code/network-generator/README.md @@ -28,6 +28,8 @@ Please follow the libyang [installation instructions](https://github.com/CESNET/ ## Usage ``` +make virtual_env_4_oam +source .oam/bin/activate python3 -m network_generation config.json ```