Skip to main content

A command line app to create a Python project skeleton.

Project description

Py-Maker

Codacy Badge

This is a command line tool to help you create new Python projects. It will create a new directory for your project, initialise a git repository, create a virtual environment, and install some basic dependencies.

More functionality will be added very shortly and the code will be refactored and cleaned up.

Installation

It is probably better to install this package globally, rather than in a virtual environment, as it is intended to be used to create new projects.

Currently the package is NOT on pypi so you need to install directly from this repository:

Install the package globally using pip:

$ pip install git+https://github.com/seapagan/py-maker.git

If you cannot install globally due to permissions, you can install it to your user install directory:

$ pip install --user git+https://github.com/seapagan/py-maker.git

or use pipx

$ pipx install git+https://github.com/seapagan/py-maker.git

Usage

To create a new project, run the following command:

$ pymaker new <project-folder>

This will create a new directory with the name you provide, and run the steps needed to get you started quickly:

  1. Copy the template files into the new directory
  2. Initialise a git repository
  3. Commit the boilerplate to Git

You will be asked a series of questions to customise the new project.

When it asks "Package Name?" you can choose two variants :

  1. If you wish for a standard Python package that can optionally be uploaded to http://pypi.org, enter a package name here. Note that underscores ("_") must be used as opposed to dashes ("-") to comply with Python package naming rules.
  2. Enter '-' to instruct the tool that you are not creating any package, just a standalone app, and then the main.py will just be placed in the project root.

You should now change into the new directory, install dependencies and activate the virtual environment:

$ cd <project-folder>
$ poetry install
$ poetry shell

Now, you can start developing :)

Task Runner

The task-runner Poe the Poet is installed as a development dependency which allows us to run simple tasks (similar to npm scripts).

These are run (from within the virtual environment) using the poe command and then the script name, for example:

$ poe pre

You can define your own, but there are 5 specific ones provided with the script.

  • pre : Run pre-commit run --all-files

  • pylint: Run Pylint on all Python files in the project.

  • mypy = Run MyPy type-checker on all Python files in the project.

  • flake8 = Run Flake8 linter on all Python files in the project.

  • black = Run Black code formatter on all Python files in the project.

  • try = Run Tryceratops linter on all Python files in the project.

  • lint = Runs pylint, mypy, flake8 and black in sequence

These are defined in the pyproject.toml file in the [tool.poe.tasks] section. Take a look at this file if you want to add or remove tasks.

Customise

The pyproject.toml file is set up to use app as the main source directory, which is the default for this template, you can change this to whatever you require, just remember to update the pyproject.toml file to match.

Linting

The generated project includes flake8 (with several plugins) for linting and Black for formatting. Mypy is installed for type checking. isort,Pylint and tyrceratops are also installed as standard.

Pre-commit

The generated project uses pre-commit to run some checks on the code before it is committed. This is a great tool to help keep your code clean.

To install pre-commit, run the following command from inside your venv:

$ pre-commit install
pre-commit installed at .git/hooks/pre-commit

License

This project is licensed under the terms of the MIT license.

MIT License

Copyright (c) 2023 Grant Ramsay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyproject_maker-0.2.0.tar.gz (49.5 kB view details)

Uploaded Source

Built Distribution

pyproject_maker-0.2.0-py3-none-any.whl (59.8 kB view details)

Uploaded Python 3

File details

Details for the file pyproject_maker-0.2.0.tar.gz.

File metadata

  • Download URL: pyproject_maker-0.2.0.tar.gz
  • Upload date:
  • Size: 49.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.19.0-50-generic

File hashes

Hashes for pyproject_maker-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2e6d0e3b20462a00713d3974e8c0599f864c24f163eac7263129639a0ef410bb
MD5 cd6c355e413ea5d5c1a0b29d839168e9
BLAKE2b-256 073ae571d9ca95da2f07bde7915a6910d841a1a6f52cc08d2f99bd6da415858f

See more details on using hashes here.

Provenance

File details

Details for the file pyproject_maker-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyproject_maker-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 59.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.19.0-50-generic

File hashes

Hashes for pyproject_maker-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9d8413488f3e90c014966a42029d69676ebfb64e80be727dae53ff974e2b5c8
MD5 74bd5a4c4b845903b6ab9891756beb0f
BLAKE2b-256 f75cfb78afc53a8286937642c9df4b11799ae0a28b898b5a68780f9a160d5a89

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page