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

```python
from your_package import createPackageTurner

## Example usage
createPackageTurner(inputClassOrFunction=YourClassOrFunction, packageName="your_package", publishToPypi=True, pypiApiKey="your_api_key")
```
### using package for classes
```python
import YourClass

## Example calling function inside class
A = YourClass.function()
```
### using package for functions
```python
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`.