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.
If you have Ollama, tomifier
also comes with code generation. You can ask it to create new files in your project and provide the Prompt to generate some code (see the add
command usage below).
References:
Installation
pip install tomifier
Usage
Initialize a package in current Folder:
tomifier init
Initialize a package at a target folder:
tomifier init -o target_folder/
Initialize a package with a given package name and at a target folder:
tomifier init --name my-package1 --output target_folder/
Add a file
tomifier add -f myproject1/services/service1.py
Add a file and generate Ollama code
tomifier add -f myproject1/services/service1.py -p "write a function to add two integers"
Sample output of creating a file and generating code:
File: myproject1/service1.py added
Code generated.
Sample run
This is what a sample tomifier
run looks like:
tomifier CLI
Description [My package]: Description for myproject1
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-project1
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
andMANIFIST.in
files
Scaffolded files
The CLI will scaffold the following files and folder structure at the current folder or at the given target folder:
.
├── .devcontainer
│ └── devcontainer.json
├── .github
│ └── dependabot.yml
├── .gitignore
├── LICENSE
├── MANIFEST.in
├── README.md
├── build.sh
├── myproject1
│ ├── __init__.py
│ ├── cmd
│ │ ├── __init__.py
│ │ ├── root.py
│ │ └── static
│ │ └── index.html
│ └── version.py
├── pyproject.toml
├── requirements.txt
└── setup.py
The scaffolded files include:
- The project files
- The project publishing files including:
pyproject.toml, setup.py, MANIFEST.in, LICENSE, build.sh, and README.md
- The
devcontainer
anddependabot
folders and files for VS Code - A
.gitignore
file
Sample generated pyproject.toml
file
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[project]
name = "my-package1"
authors = [
{ name="Name", email="name@email.com" },
]
description = "Description my-package1"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.9"
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 = "mypackage1.version.VERSION"}
readme = {file = ["README.md"]}
[tool.setuptools.packages.find]
include = ["mypackage1*"]
exclude = ["*.tests*"]
namespaces = false
[tool.setuptools.package-data]
"mypackage1" = ["*.*"]
[project.urls]
"Homepage" = "https://github.com/<usernane>/<repo>"
[project.scripts]
mypackage1 = "mypackage1.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 mypackage1 -y
python -m build
pip install -e .
mypackage1 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tomifier-0.0.6.tar.gz
.
File metadata
- Download URL: tomifier-0.0.6.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea800083c4cb5b3a20a870c2ec1cfd2e724a116f244f5f79197643430ef3901a |
|
MD5 | 22f8b68383eef0db3d4cc5dfce105c9e |
|
BLAKE2b-256 | c96424a831cd12bde101d35be96cb1d968e8929f686abea85a00dd6332f7160d |
File details
Details for the file tomifier-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: tomifier-0.0.6-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ca5d6c7105e8a4a41624ae556c977e8ff16c99f906f2df8f0a283d8812d0581 |
|
MD5 | 007af8b725ec8b3db5d2ad1d667e3542 |
|
BLAKE2b-256 | 96f27f1e7a3055d3ad1d882b3ca5615c25f895b4473c9777bf557df026af56d7 |