diff --git a/Makefile b/Makefile index 2a1f6abd7d..0198759817 100644 --- a/Makefile +++ b/Makefile @@ -24,12 +24,26 @@ define install_poetry fi endef +define deactivate_virtualenv + if [ -n "$$VIRTUAL_ENV" ]; then \ + unset VIRTUAL_ENV; \ + unset PYTHONHOME; \ + unset -f pydoc >/dev/null 2>&1; \ + OLD_PATH="$$PATH"; \ + PATH=$$(echo -n "$$PATH" | awk -v RS=: -v ORS=: '/\/virtualenv\/bin$$/ {next} {print}'); \ + export PATH; \ + hash -r; \ + echo "Deactivated the virtual environment."; \ + fi +endef + .SILENT: install install/all lint lint/integrations lint/all build run new test clean # Install dependencies install: - $(call install_poetry) + $(call deactivate_virtualenv) && \ + $(call install_poetry) && \ poetry install --with dev --all-extras diff --git a/port_ocean/cli/commands.py b/port_ocean/cli/commands.py index 44fdff6f5e..1fb294f121 100644 --- a/port_ocean/cli/commands.py +++ b/port_ocean/cli/commands.py @@ -5,11 +5,10 @@ import click from cookiecutter.main import cookiecutter # type: ignore -from rich import print -from rich.console import Console - from port_ocean.cli.download_git_folder import download_folder from port_ocean.cli.list_integrations import list_git_folders +from rich import print +from rich.console import Console def print_logo() -> None: @@ -67,7 +66,7 @@ def new(path: str) -> None: console.print("Here are your next steps: \n", style="bold") console.print( "⚓️ Install necessary packages: Run [bold][blue]make install[/blue][/bold] to install all required packages for your project.\n" - f"▶️ [bold][blue]cd {path}/{name} && make install && . venv/bin/activate[/blue][/bold]\n" + f"▶️ [bold][blue]cd {path}/{name} && make install && . .venv/bin/activate[/blue][/bold]\n" ) console.print( "⚓️ Set sail with [blue]Ocean[/blue]: Run [bold][blue]ocean sail[/blue] [/bold] to run the project using Ocean.\n" diff --git a/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Makefile b/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Makefile index cf9015989e..e6cf60edd2 100644 --- a/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Makefile +++ b/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Makefile @@ -24,6 +24,19 @@ define install_poetry fi endef +define deactivate_virtualenv + if [ -n "$$VIRTUAL_ENV" ]; then \ + unset VIRTUAL_ENV; \ + unset PYTHONHOME; \ + unset -f pydoc >/dev/null 2>&1; \ + OLD_PATH="$$PATH"; \ + PATH=$$(echo -n "$$PATH" | awk -v RS=: -v ORS=: '/\/virtualenv\/bin$$/ {next} {print}'); \ + export PATH; \ + hash -r; \ + echo "Deactivated the virtual environment."; \ + fi +endef + .SILENT: generate_config install lint run test clean generate_config: @@ -32,6 +45,7 @@ generate_config: fi install: generate_config + $(call deactivate_virtualenv) && \ $(call install_poetry) && \ poetry install --with dev @@ -40,7 +54,7 @@ lint: $(call run_lint,.) run: - $(ACTIVATE) && poetry run main.py + $(ACTIVATE) && ocean sail test: lint $(ACTIVATE) && poetry run pytest diff --git a/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml b/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml index 39fd6a0ab0..99e8577495 100644 --- a/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml +++ b/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml @@ -6,7 +6,7 @@ authors = ["{{cookiecutter.full_name}} <{{cookiecutter.email}}>"] [tool.poetry.dependencies] python = "^3.11" -port_ocean = "^0.1.0" +port_ocean = { version = "^0.1.0.dev2", extras = ["cli"] } [tool.poetry.group.dev.dependencies] pytest = "^7.2" diff --git a/port_ocean/port_ocean.py b/port_ocean/port_ocean.py index 2cb1e3a993..c6693e1770 100644 --- a/port_ocean/port_ocean.py +++ b/port_ocean/port_ocean.py @@ -7,7 +7,6 @@ import uvicorn from fastapi import FastAPI, APIRouter from loguru import logger -from starlette.types import Scope, Receive, Send from port_ocean.clients.port.client import PortClient from port_ocean.config.integration import IntegrationConfiguration @@ -17,9 +16,9 @@ initialize_port_ocean_context, ) from port_ocean.core.integrations.base import BaseIntegration -from pydantic import BaseSettings - from port_ocean.middlewares import request_handler +from pydantic import BaseSettings +from starlette.types import Scope, Receive, Send def _get_base_integration_class_from_module( @@ -47,10 +46,6 @@ def _load_module(file_path: str) -> ModuleType: try: spec.loader.exec_module(module) except Exception as e: - logger.error( - f"Failed to load integration with error: {e}, " - f"please validate the integration type exists" - ) raise e return module