tomifier


Nametomifier JSON
Version 0.0.7 PyPI version JSON
download
home_pageNone
SummaryA simple pyproject.toml initiator
upload_time2024-08-25 06:59:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License 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.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tomifier

`pyproject.toml` is a modern configuration file to package and publish Python packages. `tomifier` is a command-line tool to help you initialize a simple Python project. This is similar to the way  you can initialize a package in npm with `npm init`. The starter code itsef is a command-line interface (CLI) that can launch a FastAPI application and it comes with all the settings and tools to package and publish the generated code as a package.

If you have Ollama installed, `tomifier` now also offers code generation capabilities. You can use it to create new files in your project and/or generate code based on a prompt (see the `add` command usage details below).

References:
- [pyproject.toml vs setup.py](https://packaging.python.org/en/latest/guides/modernize-setup-py-project/)

## 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:

```text
File: myproject1/service1.py added
code generated
```

## Sample run

This is what a sample `tomifier` run looks like:


```text
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` and `MANIFIST.in` files

## Scaffolded files

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

```text
.
├── .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` and `dependabot` folders and files for VS Code
- A `.gitignore` file

## Sample generated `pyproject.toml` file

```toml
[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: 

```bash
sh build.sh
```

The bash script includes the following commands:

```bash
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: 

```bash
# 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/*
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tomifier",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Alex Morales <am8850mia@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/23/98/37630e9b3e9cca362913d662735a56b5f27cb838582e1f6f7a025d360d24/tomifier-0.0.7.tar.gz",
    "platform": null,
    "description": "# tomifier\n\n`pyproject.toml` is a modern configuration file to package and publish Python packages. `tomifier` is a command-line tool to help you initialize a simple Python project. This is similar to the way  you can initialize a package in npm with `npm init`. The starter code itsef is a command-line interface (CLI) that can launch a FastAPI application and it comes with all the settings and tools to package and publish the generated code as a package.\n\nIf you have Ollama installed, `tomifier` now also offers code generation capabilities. You can use it to create new files in your project and/or generate code based on a prompt (see the `add` command usage details below).\n\nReferences:\n- [pyproject.toml vs setup.py](https://packaging.python.org/en/latest/guides/modernize-setup-py-project/)\n\n## Installation\n\n`pip install tomifier`\n\n## Usage\n\nInitialize a package in current Folder:\n- `tomifier init`\n\nInitialize a package at a target folder: \n- `tomifier init -o target_folder/`\n\nInitialize a package with a given package name and at a target folder: \n- `tomifier init --name my-package1 --output target_folder/`\n\nAdd a file:\n- `tomifier add -f myproject1/services/service1.py`\n\nAdd a file and generate Ollama code:\n- `tomifier add -f myproject1/services/service1.py -p \"write a function to add two integers\"`\n\nSample output of creating a file and generating code:\n\n```text\nFile: myproject1/service1.py added\ncode generated\n```\n\n## Sample run\n\nThis is what a sample `tomifier` run looks like:\n\n\n```text\ntomifier CLI\nDescription [My package]: Description for myproject1\nAuthor [Name]: \nAuthor email [name@email.com]: \nHomepage [https://github.com/<usernane>/<repo>]: \nThe following packages will be added by default: click, fastapi, and uvicorn[standard]\nCommand separated list of additional packages [ ]: \nReady to inialize project. Proceed [Y/n]: \nCreating package: my-project1\nCreating folder test1\nNew project iniatialized at: test1\nType: cd test1\n - Review the generated code\n - Check the package requirements in pyproject.toml and requirements.txt\n - To build the project type: sh.build\n```\n\n> **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\n\n## Scaffolded files\n\nThe CLI will scaffold the following files and folder structure at the current folder or at the given target folder:\n\n```text\n.\n\u251c\u2500\u2500 .devcontainer\n\u2502   \u2514\u2500\u2500 devcontainer.json\n\u251c\u2500\u2500 .github\n\u2502   \u2514\u2500\u2500 dependabot.yml\n\u251c\u2500\u2500 .gitignore\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 MANIFEST.in\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 build.sh\n\u251c\u2500\u2500 myproject1\n\u2502   \u251c\u2500\u2500 __init__.py\n\u2502   \u251c\u2500\u2500 cmd\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\n\u2502   \u2502   \u251c\u2500\u2500 root.py\n\u2502   \u2502   \u2514\u2500\u2500 static\n\u2502   \u2502       \u2514\u2500\u2500 index.html\n\u2502   \u2514\u2500\u2500 version.py\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 requirements.txt\n\u2514\u2500\u2500 setup.py\n```\n\nThe scaffolded files include:\n- The project files\n- The project publishing files including: `pyproject.toml, setup.py, MANIFEST.in, LICENSE, build.sh, and README.md`\n- The `devcontainer` and `dependabot` folders and files for VS Code\n- A `.gitignore` file\n\n## Sample generated `pyproject.toml` file\n\n```toml\n[build-system]\nrequires = [\"setuptools\", \"setuptools-scm\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"my-package1\"\nauthors = [\n  { name=\"Name\", email=\"name@email.com\" },\n]\ndescription = \"Description my-package1\"\nreadme = \"README.md\"\nlicense = { file=\"LICENSE\" }\nrequires-python = \">=3.9\"\nclassifiers = [\n    \"Programming Language :: Python :: 3\",\n    \"License :: OSI Approved :: MIT License\",\n    \"Operating System :: OS Independent\",\n]\ndependencies = [\n  \"click\",\n  \"fastapi\",\n  \"uvicorn[standard]\"\n]\ndynamic = [\"version\"]\n\n[tool.setuptools]\ninclude-package-data = true\n\n[tool.setuptools.dynamic]\nversion = {attr = \"mypackage1.version.VERSION\"}\nreadme = {file = [\"README.md\"]}\n\n[tool.setuptools.packages.find]\ninclude = [\"mypackage1*\"]\nexclude = [\"*.tests*\"]\nnamespaces = false\n\n[tool.setuptools.package-data]\n\"mypackage1\" = [\"*.*\"]\n\n[project.urls]\n\"Homepage\" = \"https://github.com/<usernane>/<repo>\"\n\n[project.scripts]\nmypackage1 = \"mypackage1.cmd.root:main\"\n```\n\n> **Note:** the `pyproject.toml` contents of this file can be and most likely will need to be modified further to meet your needs.\n\n## Building the package\n\n`build.sh` is a useful bash script included as part of the scaffolded code to build and deploy the package locally in editable mode. \n\nTo run it from a bash terminal type: \n\n```bash\nsh build.sh\n```\n\nThe bash script includes the following commands:\n\n```bash\nrm -rf dist\npip uninstall mypackage1 -y\npython -m build\npip install -e .\nmypackage1 ui\n```\n\n## Pushing the package to pypi.org\n\nAfter building the package, to push the build to pypi.org using twine. Type: \n\n```bash\n# Verfify that the package name does not exist\n# Install twine\npip install twine\n# Make sure to get and install pypi.org token\n# Publish the package\ntwine upload dis/*\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  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. ",
    "summary": "A simple pyproject.toml initiator",
    "version": "0.0.7",
    "project_urls": {
        "Homepage": "https://github.com/am8850/tomifier"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "874eb0cfa1294ece3e6b6e42aa580e9813c58505010f50ea0a43db76613167c7",
                "md5": "3c9e11deca43166dad3af35bab01bf48",
                "sha256": "b5b59dd33f64a02a4a29218d11c7d99113225ee8a9b0260bd61499b1c245a300"
            },
            "downloads": -1,
            "filename": "tomifier-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3c9e11deca43166dad3af35bab01bf48",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12545,
            "upload_time": "2024-08-25T06:59:10",
            "upload_time_iso_8601": "2024-08-25T06:59:10.605536Z",
            "url": "https://files.pythonhosted.org/packages/87/4e/b0cfa1294ece3e6b6e42aa580e9813c58505010f50ea0a43db76613167c7/tomifier-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "239837630e9b3e9cca362913d662735a56b5f27cb838582e1f6f7a025d360d24",
                "md5": "57157f46a403721ea94485d2b888576e",
                "sha256": "69553e8f0c0cb4add01339b0164201fd473be7a5f5192b08bd96a40a2c1d2b09"
            },
            "downloads": -1,
            "filename": "tomifier-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "57157f46a403721ea94485d2b888576e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 11968,
            "upload_time": "2024-08-25T06:59:12",
            "upload_time_iso_8601": "2024-08-25T06:59:12.076996Z",
            "url": "https://files.pythonhosted.org/packages/23/98/37630e9b3e9cca362913d662735a56b5f27cb838582e1f6f7a025d360d24/tomifier-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-25 06:59:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "am8850",
    "github_project": "tomifier",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "tomifier"
}
        
Elapsed time: 0.32141s