Last active
December 3, 2024 19:46
-
-
Save drpafowler/9d1e11f5ca60d5e02c70bd64e6ff47d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def create_gitignore(): | |
"""Creates a basic .gitignore file if it does not exist.""" | |
if not os.path.exists(".gitignore"): | |
with open(".gitignore", "w") as f: | |
f.write("""# Python-specific ignores | |
__pycache__/ | |
*.pyc | |
*.pyo | |
*.pyd | |
.venv/ | |
data/ | |
""") | |
else: | |
print(".gitignore already exists.") | |
def create_readme(): | |
"""Creates a basic README.md file.""" | |
if os.path.exists("README.md"): | |
overwrite = input("README.md already exists. Do you want to overwrite it? (y/n): ") | |
if overwrite.lower() != 'y': | |
print("README.md not overwritten.") | |
return | |
with open("README.md", "w") as f: | |
f.write("""# Project Title | |
## My package | |
Description of your package. | |
## Overview | |
Overview of your project. | |
## Author(s) | |
List of authors. | |
## Usage | |
Instructions on how to use your project. | |
```python3 | |
>>> import mypackage | |
>>> mypackage.do_stuff() | |
``` | |
## Installation | |
Instructions on how to install your project. | |
""") | |
def create_venv(): | |
"""Creates a virtual environment.""" | |
os.system("python3 -m venv .venv") | |
def create_requirements(): | |
"""Creates a requirements.txt file.""" | |
with open("requirements.txt", "w") as f: | |
f.write("""# List of dependencies | |
ipython | |
numpy | |
pandas | |
matplotlib | |
""") | |
if __name__ == "__main__": | |
create_gitignore() | |
create_readme() | |
create_venv() | |
create_requirements() | |
print("Files created: .gitignore, README.md, requirements.txt") | |
print("Virtual environment created: .venv") | |
print("next step is: source .venv/bin/activate") | |
print("then: pip install -r requirements.txt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment