Skip to content

Commit a0c17b6

Browse files
committed
update config logic
1 parent 6a06578 commit a0c17b6

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

Makefile

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
export ENV ?= stage
12
VENV_NAME ?= venv
23
PIP ?= pip
34
PYTHON ?= python3.11
4-
ENV ?= stage
55

66
venv: $(VENV_NAME)/bin/activate
77

@@ -13,19 +13,7 @@ $(VENV_NAME)/bin/activate: pyproject.toml
1313
test: venv
1414
$(VENV_NAME)/bin/python -m unittest discover tests
1515

16-
build: set-config venv
16+
build: venv
1717
cp LICENSE LICENSE.bak
1818
$(VENV_NAME)/bin/python -m build
1919
rm LICENSE.bak
20-
21-
set-config:
22-
ifeq ($(ENV), stage)
23-
@cp extend/config/config_stage.py extend/config/config.py
24-
@echo "Using STAGING configuration"
25-
else ifeq ($(ENV), prod)
26-
@cp extend/config/config_prod.py extend/config/config.py
27-
@echo "Using PRODUCTION configuration"
28-
else
29-
@echo "Invalid ENV value. Use 'stage' or 'prod'."
30-
@exit 1
31-
endif

extend/config/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
from .config import API_HOST, API_VERSION
1+
import os
2+
3+
from dotenv import load_dotenv
4+
5+
load_dotenv()
6+
7+
env = os.getenv("ENV", "dev")
8+
9+
if env == "stage":
10+
from .config_stage import API_HOST, API_VERSION
11+
elif env == "prod":
12+
from .config_prod import API_HOST, API_VERSION
13+
else:
14+
from .config_stage import API_HOST, API_VERSION
215

316
__all__ = [
417
"API_HOST",

0 commit comments

Comments
 (0)