Code Monkey home page Code Monkey logo

py-maker's Introduction

Python Project Generation Tool

PyPI version Codacy Badge CodeQL PyPI - License Weekly Downloads Total Downloads

A fully customizable Python application to bootstrap Poetry-based boilerplate for you to start developing your Python applications quicker! Includes linting and Pytest libraries, a task runner, pre-commit hooks, and optionally create a git repository and upload to GitHub. you can also fully customize the template used.

Full documentation for this project with usage examples is available at https://py-maker.seapagan.net/

Installation

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

Install the package globally using pip:

$ pip install pyproject-maker

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

$ pip install --user pyproject-maker

or use pipx (recommended)

$ pipx install pyproject-maker

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 '-' (a dash) 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. The pyproject.toml file will not include any package information and Poetry will never try to install or publish the package.

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 😄

Linting

The generated project includes Ruff for linting and formatting. Mypy is installed for type checking.

Customise

For a 'package' project, the pyproject.toml file is set up to put the code in a sub-folder with the same name as chosen for the 'Package Name'. You can change this to whatever you require, just remember to update the pyproject.toml file to match.

You can also modify the template used to generate the new project.

Check the documentation at https://py-maker.seapagan.net/ for more details.

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

See the Task Runner section in the documentation for more details and a list of available tasks.

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.

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

GitHub Actions and Configuration

By default the generated project includes a GitHub Actions workflow to run Dependabot to keep your dependencies up to date. There are also standard templates for Pull Request and Issues.

The plan is to add more workflows in the future, for example running tests and more.

Contributing to Py-Maker

All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome.

A detailed overview on how to contribute can be found in the contributing guide and on the website.

If you are simply looking to start working with the codebase, navigate to the GitHub "issues" tab and start looking through interesting issues. There may be issues listed under documentation and good first issue where you could start out.

You can also triage issues which may include reproducing bug reports, or asking for vital information such as version numbers or reproduction instructions.

Maybe through using Py-Maker you have an idea of your own or are looking for something in the documentation and thinking ‘this can be improved’...you can do something about it!

As contributors and maintainers to this project, you are expected to abide by our code of conduct. More information can be found at: Contributor Code of Conduct

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.


py-maker's People

Contributors

dependabot[bot] avatar gnramsay avatar pre-commit-ci[bot] avatar seapagan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nad1r-pl

py-maker's Issues

Empty string for 'homepage' in `pyproject.html` crashes Poetry

Describe the bug

If the homepage value in the pyproject.toml is set to an empty string, Poetry crashes. I'm unsure if this is due to changes in the latest Poetry versions or a result of changes in this code.

To Reproduce

leave the homepage setting blank when asked

Expected behaviour

poetry install should succeed

If creating a standalone, `poetry install` should set 'package-mode=false' in the pyproject.toml

Describe the bug

Creating a standalone project and then running poetry install causes the following message :

Installing dependencies from lock file

No dependencies to install or update

Installing the current project: testpackage (0.1.0)
Warning: The current project could not be installed: No file/folder found for package testpackage
If you do not want to install the current project use --no-root.
If you want to use Poetry only for dependency management but not for packaging, you can set the operating mode to "non-package" in your pyproject.toml file.
In a future version of Poetry this warning will become an error!

To Reproduce

Create a new application and choose '-' for the package name to make it a standalone project (not for uploading to PyPI)

Expected behaviour

Poetry should never try to install the actual package.

Proposed Fix

add package-mode = false to the [tool.poetry] section of pyproject.toml in these cases. For a normal project, leave this setting out as the default is package-mode = true

When missing the config file, it does not properly read the users Git username/email

Bug Report

Bug Description

When missing config file, it does not properly read the users Git username/email

How To Reproduce

Run the app with a missing config file.

Expected behaviour

pymaker config show should show the configured user/email taken from the users system. However, these are blank.

Additional context

This seems to be a regression since this worked fine in previous versions. Not sure if the issue is in this app or the underlying library.

The templates for some generated files need updating

  • The README for the generated project still mentions flake8, black, etc, in the Task Runner and Linting sections. These have all been replaced by ruff.
  • .pre-commit-config.yaml needs tool versions updating.
  • The license name is missing in the generated pyproject.toml

--version flag does not work.

Describe the bug
The --version flag does not work

$ pymaker --version
Problem getting the Version : [Errno 2] No such file or directory: '<current working directory>/pyproject.toml'

To Reproduce
Steps to reproduce the behaviour:

Run pymaker --version from the command line

Expected behaviour

It should display the current version, taken from the project TOML file.

Additional context
App is trying to find the TOML file in the local directory but should take it from the project metadata. We can use the same methods as use to get the templates

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.