Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
carmelgafa committed Feb 11, 2024
1 parent c990b9c commit ad7d9df
Showing 1 changed file with 1 addition and 65 deletions.
66 changes: 1 addition & 65 deletions environment_creator.py
Original file line number Diff line number Diff line change
@@ -1,65 +1 @@
'''
script to create project folder structure, virtual
environment and loads required libraries
'''
import os

def create_environment(project_name:str, requirements:list)->None:
'''
creates a new virtual environment with project folder structure
'''

# create file setup.py
with open(file="setup.py", mode="w", encoding="utf-8") as f:
f.write("from setuptools import setup, find_packages\n")
f.write("setup(name='"+project_name+"', version='1.0', packages=find_packages())")

# create project folder
os.mkdir(project_name)
os.mkdir(project_name+"/.build")
os.mkdir(project_name+"/.config")
os.mkdir(project_name+"/dep")
os.mkdir(project_name+"/doc")
os.mkdir(project_name+"/res")
os.mkdir(project_name+"/samples")
os.mkdir(project_name+"/src")
os.mkdir(project_name+"/test")
os.mkdir(project_name+"/tools")

# create __init__.py in project folder
with open(file=project_name+"/__init__.py", mode="w", encoding="utf-8") as f:
f.write("")

# create requirements.txt
with open("requirements.txt", mode="w", encoding="utf-8") as f:
for req in requirements:
f.write(req+"\n")

# create README.md
with open("README.md", mode="w", encoding="utf-8") as f:
f.write(f"# {project_name}\n")

# create virtual environment
os.system("python -m venv venv")

# create activate.bat
with open("activate.bat", mode="w", encoding="utf-8") as f:
f.write("venv\\Scripts\\activate.bat\n")

# create deactivate.bat
with open("deactivate.bat", mode="w", encoding="utf-8") as f:
f.write("venv\\Scripts\\deactivate.bat\n")

# run activate.bat
os.system('''
activate.bat & pip install -r requirements.txt & pip install -e .
''')

# create gitignore file and add venv folder
with open(".gitignore", mode="w", encoding="utf-8") as f:
f.write("venv\n")


if __name__ == '__main__':
create_environment('ml_algorithms', ['numpy', 'pandas', 'matplotlib'])


0 comments on commit ad7d9df

Please sign in to comment.