Coder Social home page Coder Social logo

cookiecutter-create-python-project's Introduction

Welcome to the Python Class Cookie Cutter

A cookie cutter is a template for creating a new project. This cookie cutter will be used to create a new Python project with all of the development tools and initial code preconfigured and ready for use with Visual Studio Code.

Getting Started

To use this Cookie Cutter you will need Python and the Cookie Cutter package installed. Also, the files created with the Cookie Cutter project template are designed to work with

For Windows

  1. Download the Windows Installer for Python from python.org

  2. On the first page of the installation wizard, check the box to add Python to the path. This will make it easier to run Python from the command prompt.

  3. Complete the install as normal.

For macOS or Linux

  1. Install Homebrew from brew.sh

  2. Then, run:

brew install python

For All Systems

  1. To verify the Python installation, run the following command:
python -V

Ensure it outputs the version you just installed.

  • If the version displayed is different from the version installed the most likely you will need to adjust your system paths to resolve to the new Python path. Configuring path environment variables is outside the scope of this document.

Upgrade PIP and Install Cookie Cutter

With Python installed, let's ensure we have the latest PIP package manager.

python -m pip install --upgrade pip setuptools wheel

With PIP upgraded, now the Cookie Cutter package needs to be installed. From a terminal window, run the following command:

python -m pip install cookiecutter

Create a new Project with Cookie Cutter

  1. From a terminal window, change to the folder where you would like to store your new project.

  2. To create the new project, run the following command:

cookiecutter https://github.com/t4d-starter-projects/cookiecutter-create-python-project
  1. It will prompt you for a project name, type in a name. I recommended something with no spaces, allow lower case, and no special characters except for an underscore.

  2. A new folder is created with the project name. The contents of the cookie cutter project template are copied into the folder.

Get the Project Up and Running in Visual Studio Code

  1. First, ensure you have Visual Studio Code installed. It can be downloaded from here code.visualstudio.com.

  2. Install the Python extension for Visual Studio Code.

  3. Start Visual Studio Code, and open the project folder created by Cookie Cutter.

  4. Open a terminal window. Within the terminal session verify you are in the folder with the "requirements.txt" file.

  5. Create a new virtual environment.

python -m venv venv

Note: On systems where you have Python 2 installed along with Python 3 you may need to use the python3 command instead of the plain python command for this one step.

  1. When the environment is created Visual Studio Code should detect it and asked you if you want to make this virtual environment the Python interpreter in Visual Studio, click "Yes".

  2. Activate the environment in the terminal window.

Windows with PowerShell

.\venv\Scripts\Activate.ps1

macOS, Linux, Bash/Zsh Shell

source ./venv/bin/activate
  1. Upgrade PIP for the virtual environment.
python -m pip install --upgrade pip setuptools wheel
  1. Install the packages listed in the requirements.txt file.
python -m pip install -r requirements.txt
  1. Congrats! You are all done!

To run the project in various ways, here are the commands:

Run the Main Module

python -m {{cookiecutter.package_name}}

Run the Pylint Linter

python -m pylint --max-line-length=79 --unsafe-load-any-extension=y --ignore=.git,venv,.vscode,__pycache__ {{cookiecutter.package_name}} tests

Run the Flake8 Linter

python -m flake8 --exclude=venv,.git,__pycache__

Run the MyPy Linter

python -m mypy --ignore-missing-imports --follow-imports=silent --show-column-numbers --strict --exclude venv .

Run the Unit Tests with Code Coverage

python -m coverage run -m unittest tests.__main__

Generate Code Coverage Report

python -m coverage report --omit="venv/*,tests/*,setup.py"

Extra

  • Included is an Azure Pipeline file that will validate the source code per the linting rules and run unit tests and code coverage when committed code to Azure Repos.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.