As someone who loves experimenting with Python libraries and APIs, starting new projects quickly is important. Setting up these projects can sometimes be time-consuming, and a bit annoying to be honest.
Wrote this shell script to automate the process and start coding quickly. Here's what it does -
- Prompts the user to provide a project name as a command-line argument, and throws an error message and usage instructions if the project name argument is missing.
- Creates a new project directory with the specified name.
- Sets up a virtual environment within the project directory.
- Installs required Python dependencies using pip or a preferred package manager.
- Creates sub-directories for source code, tests, and documentation.
- Generates essential files like main.py, requirements.txt, and README.md.
- Initializes a Git repository for version control.
- Opens the main.py file in Visual Studio Code in a new window.
Setting up the script
Make the Script Executable
Run the Script
[Optional] Create an alias
Open your shell's configuration file (e.g., .bashrc
, .bash_profile
) using a text editor,
Add the following line at the end of the file, replacing /path/to/start_python_project.sh
with the actual path to your shell script:
Using the script to create a new project
In the terminal, you can now start a new Python project by running the following command, replacing my_project
with your desired project name:
Fin!
Subscribe to our email newsletter and unlock access to members-only content and exclusive updates.
Comments