Skip to content

Commit d8b7371

Browse files
using python-dotenv for local running
1 parent 3cc1886 commit d8b7371

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pyaction/cli.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import click
55
from copier import run_copy
6+
from dotenv import load_dotenv
67

78
from pyaction import __version__
89
from pyaction.consts import PROJECT_NAME, TEMPLATE_PATH
@@ -26,12 +27,13 @@ def init() -> None:
2627

2728
@cli.command(
2829
"run",
29-
help="Runs the action locally based on the .env file",
30+
help="Runs the action locally",
3031
)
3132
def run() -> None:
3233
if not os.path.isfile(".env"):
3334
raise FileNotFoundError(
34-
"Make sure you have the `.env` file inside the root path of your action directory."
35+
"Make sure you have the `.env` file in the root path of your action directory."
3536
)
3637

37-
subprocess.check_call("env $(cat .env | xargs) python main.py", shell=True)
38+
load_dotenv(".env")
39+
subprocess.call(["python", "main.py"])

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
"Environment :: Console",
2020
"Intended Audience :: Developers",
2121
"License :: OSI Approved :: MIT License",
22-
"Operating System :: OS Independent",
22+
"Operating System :: POSIX",
2323
"Programming Language :: Python",
2424
"Programming Language :: Python :: 3.8",
2525
"Programming Language :: Python :: 3.9",
@@ -39,6 +39,7 @@ cli = [
3939
"copier >= 9.2",
4040
"click >= 8.1",
4141
"rich >= 13.7.1",
42+
"python-dotenv >= 1.0.1",
4243
]
4344

4445
[project.urls]

0 commit comments

Comments
 (0)