Skip to main content

**createPackageTurner** is an automated Python package creation tool designed to quickly turn a Python class into a fully functional Python package. It generates the required package structure, metadata, setup files, and optionally publishes the package to PyPI. By providing an input class or function, you can automatically generate a Python package and optionally upload it to PyPI for distribution.

Project description

createPackageTurner

createPackageTurner is an automated Python package creation tool designed to quickly turn a Python class into a fully functional Python package. It generates the required package structure, metadata, setup files, and optionally publishes the package to PyPI. By providing an input class or function, you can automatically generate a Python package and optionally upload it to PyPI for distribution.

Features

  • Automatically generates a package structure based on the given input class or function.
  • This supports publishing functions as packages as well.
  • Users can specify the path to packages files. Afterwards, for greater customization, users can alter the generated setup.py file and upon running this module again, this module is smart enough to preserve the changes they made to the setup.py when regenerating the package.
  • Supports adding custom metadata (author, email, description, readme, etc.). It will still work without providing this information however (even packageName will default to be identical to the name of inputClassOrFunction if not provided). The only argument it always needs is inputClassOrFunction.
  • Can upload the generated package to PyPI.
  • Automatically increments the version number. If there already are package files in the path specified, it chooses the version from those files and adds one. If one has already published a prior version of this package to pypi, it will take the version from that and add one. If both, then it chooses the max version, and if neither then by default the first version is 0.2.2.
  • Flexible options for including or excluding package requirements.

How to Use

uploading package

To use the package, call the createPackageTurner function with the desired parameters.

from your_package import createPackageTurner

## Example usage
createPackageTurner(inputClassOrFunction=YourClassOrFunction, packageName="your_package", publishToPypi=True, pypiApiKey="your_api_key")

using package for classes

import YourClass

## Example calling function inside class
A = YourClass.function()

using package for functions

import yourFunction

## Example calling function inside class
A = yourFunction()

Arguments

  • inputClassOrFunction (class): The input Python class that contains the functions you want to include in the package. This is the primary input to generate the package from.

  • packageName (str, default="na"): The name of the package. If not provided, the package name will be identical to the name of the class/function provided. This will be used as the folder name and in the generated setup file.

  • packageHousePath (str, default="na"): The path to the location where the package will be saved. If not specified, defaults to "na". It is the base directory for the package.

  • specificPackageFolder (str, default="na"): Path to a specific folder where the package will be created. Defaults to "na", which means the current working directory will be used.

  • pythonAbove (str, default="3.6"): Minimum version of Python required for the package. Set it as a string (e.g., "3.7").

  • author_email (str, default="brianbrandonturner@gmail.com"): Email address of the package author.

  • author (str, default="Brigham Turner"): The name of the author for the package.

  • description (str, default="auto generated package from packageMaker"): A short description of the package. You can provide a custom description, or it will default to "auto generated package from packageMaker".

  • readme (str, default="this package was generated by packageMaker using a class as input that contains functions"): The content for the README file. Defaults to a basic message about the package.

  • publishToPypi (bool, default=False): Whether to publish the generated package to PyPI. If True, the package will be uploaded automatically after it is created.

  • pypiApiKey (str, default="unknown"): The API key required for publishing the package to PyPI. You must provide your PyPI API key if you want to publish the package.

  • requirementsReplacement (dict, default={}): A dictionary of requirements to replace in the generated requirements.txt file. For example, { "numpy": "1.21.0" } to specify a version.

  • overwriteRequirements (str, default="na"): Whether to overwrite the requirements.txt file. If "na", it will not overwrite it.

  • relyOnOldSetupWhenPossible (bool, default=True): Whether to reuse an existing setup.py template if one exists.

  • linkRepo (str, default="na"): A URL linking to the source code repository. If "na", the default behavior will be used. "na" means to not change the default (if there is one). "none" means to delete the default (if there is one).

  • linkDocumentation (str, default="na"): A URL linking to the documentation for the package. If "na", no link is added. "na" means to not change the default (if there is one). "none" means to delete the default (if there is one).

  • linkSourceCode (str, default="na"): A URL linking to the source code for the package. If "na", no link is added. "na" means to not change the default (if there is one). "none" means to delete the default (if there is one).

  • linkBugTracker (str, default="na"): A URL linking to the bug tracker for the package. If "na", no link is added. "na" means to not change the default (if there is one). "none" means to delete the default (if there is one).

Package Folder Creation and Behavior

The package will be saved to the folder specified in specificPackageFolder. If specificPackageFolder is "na", then it will create a folder in packageHousePath, using the same name as the package, and use this to hold the package files. If packageHousePath is "na", then it will create a folder in the present directory called "packageHolder" and set the packageHousePath to be that.

If a pre-existing package is found in the final specified folder for the package, then it will completely replace the code in that package, but it will preserve most of the code found in the setup.py file. In the setup file, it will, however, still always replace the requirements and the version. If any of the following variables are edited from the default, they will also be replaced in the setup.py file: author, author_email, description, readme, linkRepo, linkDocumentation, linkSourceCode, linkBugTracker.

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

createpackageturner-0.2.49.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

createPackageTurner-0.2.49-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file createpackageturner-0.2.49.tar.gz.

File metadata

  • Download URL: createpackageturner-0.2.49.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for createpackageturner-0.2.49.tar.gz
Algorithm Hash digest
SHA256 05016b30825c33913bf27fbfdaf9cd33deb0bc068ba16a38a756e0173539e487
MD5 ce17f9b62bb31c913cfb8e12022952b0
BLAKE2b-256 ed11703f87ee98ea218f3bdfedf1bedb9c79f27c3e1602a70ae62dd875d0b0af

See more details on using hashes here.

File details

Details for the file createPackageTurner-0.2.49-py3-none-any.whl.

File metadata

File hashes

Hashes for createPackageTurner-0.2.49-py3-none-any.whl
Algorithm Hash digest
SHA256 3dbc7dd9633b4885c17163f4967705d545f43d17e3b99e8a088b5d915aa0e6c8
MD5 525f6be78f75b0feb4a84288b2fcb4a5
BLAKE2b-256 cce610359ce1815b4f3cd9ef766084a1b3a6fd353ec13cfb66a67e5222a4bdc1

See more details on using hashes here.

Supported by

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