Skip to content

Commit 3aa6c05

Browse files
author
Brian Obot
committed
Ensure that installed packages for a project are done in an active virtual environemtn and not the global python installtion
1 parent b266581 commit 3aa6c05

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/fastapi_gen8/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def get_project_detail(
9393

9494
if "_" in attr:
9595
attr = attr.lower()
96+
97+
if attr == "slug_name":
98+
default = slugify(str(project_detail["name"]))
9699

97100
# Tuples Attrs means the detail have options, so process them differently
98101
if not isinstance(default, tuple):
@@ -213,8 +216,8 @@ def generate_project_scaffold(project_detail: dict[str, str]):
213216

214217
# create and activate virtual environment
215218
subprocess.Popen(["python3", "-m", "venv", "venv"]).wait()
216-
subprocess.Popen(["bash", "-c", "source", "venv/bin/activate"]).wait()
217-
subprocess.Popen(["pip", "install", "-r", "requirements.txt"]).wait()
219+
subprocess.Popen(["bash", "-c", "source venv/bin/activate && pip install -r requirements.txt"]).wait()
220+
# subprocess.Popen(["pip", "install", "-r", "requirements.txt"]).wait()
218221

219222

220223
print("____________________________________________")
@@ -244,7 +247,6 @@ def main():
244247

245248
start_time = time.time() # this is an internal metric to track the duration for each project generation
246249
for attr, default_value in project_details.items():
247-
print(f"Attr: {attr}, Default = {default_value}")
248250
detail = get_project_detail(attr.title(), default_value, project_details)
249251
project_details[attr] = detail # update the default project detail with the provided one
250252
success_print(f"Project {attr.title()} = {detail}")
@@ -256,11 +258,9 @@ def main():
256258
print("----------------------------------------------")
257259

258260
# Generate Projects with the Details Provided by the User
259-
# generate_project_scaffold(cast(dict[str, str], project_details))
260-
261-
from icecream import ic
262-
ic(project_details)
261+
generate_project_scaffold(cast(dict[str, str], project_details))
263262

264263

264+
265265
if __name__ == "__main__":
266266
main()

src/fastapi_gen8/tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_generate_default_project_details():
2525
"attr,default_value,project_detail",
2626
[
2727
("name", "My Awesome FastAPI Project Test", main.generate_default_project_details()),
28-
("slug_name", "my_awesome_fastapi_project_test", main.generate_default_project_details()),
28+
("slug_name", "my_awesome_fastapi_project", main.generate_default_project_details()),
2929
("description", "FastAPI Project Description", main.generate_default_project_details()),
3030
("author(s)", "John Doe", main.generate_default_project_details()),
3131
("virtual_env_folder_name", "venv", main.generate_default_project_details()),

0 commit comments

Comments
 (0)