Skip to main content

A simple pyproject.toml initiator

Project description

tomifier

pyproject.toml is a modern way to create a Pathon package. tomifier is CLI to initialize a simple Python pyproject.toml file and starting code. The starting code is itself a CLI that can launch a FastAPI application.

References:

Installation

pip install tomifier

Usage

Initialize on current Folder:

  • tomifier init

Initialize on target folder:

  • tomifier init -o target_folder/

Initialize with a project name and a target folder:

  • tomifier init --name myproject1 --output target_folder/

Scaffolded files

The CLI will scaffold the following files and folder structure at the current folder or at the given target folder:

.
├── .gitignore
├── LICENSE
├── MANIFEST.in
├── README.md
├── build.sh
├── mypackage1
│   ├── __init__.py
│   ├── cmd
│   │   ├── __init__.py
│   │   ├── root.py
│   │   └── static
│   │       └── index.html
│   └── version.py
├── pyproject.toml
├── requirements.txt
└── setup.py

Sample run

This is what a sample tomifier run looks like:

tomifier CLI
Description [My package]: Description for mypackage1                            
Author [Name]: 
Author email [name@email.com]: 
Homepage [https://github.com/<usernane>/<repo>]: 
The following packages will be added by default: click, fastapi, and uvicorn[standard]
Command separated list of additional packages [ ]: 
Ready to inialize project. Proceed [Y/n]: 
Creating package: my-package1
Creating folder test1
New project iniatialized at: test1
Type: cd test1
 - Review the generated code
 - Check the package requirements in pyproject.toml and requirements.txt
 - To build the project type: sh.build

Note: if you intend to deploy the package to pypi.org, make sure that the name is available. Even if it is available, the name could be too close to another name preventing posting. If you end up having to choose a different name, you will need to rename the package directory and the package name references in the README.md,pyproject.toml and MANIFIST.in files

Sample generated pyproject.toml file

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "my-project1"
authors = [
  { name="Name", email="name@email.com" },
]
description = "Description for myproject1"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.10, <3.12"
classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
]
dependencies = [
  "click",
  "fastapi",
  "uvicorn[standard]"
]
dynamic = ["version"]

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "myproject1.version.VERSION"}
readme = {file = ["README.md"]}

[tool.setuptools.packages.find]
include = ["myproject1*"]
exclude = ["*.tests*"]
namespaces = false

[tool.setuptools.package-data]
"myproject1" = ["*.*"]

[project.urls]
"Homepage" = "https://github/usernane/repo"

[project.scripts]
myproject1 = "myproject1.cmd.root:main"

Note: the pyproject.toml contents of this file can be and most likely will need to be modified further to meet your needs.

Building the package

build.sh is a useful bash script included as part of the scaffolded code to build and deploy the package locally in editable mode.

To run it from a bash terminal type:

sh build.sh

The bash script includes the following commands:

rm -rf dist
pip uninstall <package_name> -y
python -m build
pip install -e .
<package_name> ui

Pushing the package to pypi.org

After building the package, to push the build to pypi.org using twine. Type:

# Verfify that the package name does not exist
# Install twine
pip install twine
# Make sure to get and install pypi.org token
# Publish the package
twine upload dis/*

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

tomifier-0.0.5.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

tomifier-0.0.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file tomifier-0.0.5.tar.gz.

File metadata

  • Download URL: tomifier-0.0.5.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for tomifier-0.0.5.tar.gz
Algorithm Hash digest
SHA256 596f0961edb2d178b0bcdc057c636f03792ec344d66c834e55ed4fef513078be
MD5 4a1856e1c7fb5553afb07c27409f60a6
BLAKE2b-256 de54fa03d7f16b8f58851bddffbf3e1047877d0f0064ad90a55f5b38ee44d848

See more details on using hashes here.

File details

Details for the file tomifier-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: tomifier-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for tomifier-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4bc3de8f2e2537ac9211dc76ff962f1f6ec9272f935072d4c7623fa59b34d92f
MD5 e9be69a2bdd562f06c2079a183f21367
BLAKE2b-256 330ea52681117fc0bdc0ba62f4dc0f8f643a6e823eda3c0df3ebd79f29e82dad

See more details on using hashes here.

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