This repository contains an encryption package based on AES Encryption in GCM mode, along with this Readme shows how to build a Python package from a script.
Building a local Python package involves several steps, including organizing your code, writing necessary files like setup.py, and potentially distributing it via PyPI if you want it to be installable via pip. Here's a basic guide to get you started:
- Organize Your Code First, you need to organize your Python code. Suppose you have a project named example_pkg. Your directory structure should look something like this:
example_pkg/
│
├── example_pkg/
│ ├── __init__.py
│ └── your_module.py
├── setup.py
└── README.md
In example_pkg/example_pkg/, init.py can be empty but must be present to tell Python that this directory should be considered a Python package. your_module.py is where your actual code goes.
- Write setup.py setup.py is a build script for setuptools. It tells setuptools about your package (such as the name and version) as well as which code files to include. An example setup.py might look like this:
setup.py
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
from setuptools import setup, find_packages
setup(
name="example_pkg",
version="0.1",
packages=find_packages(),
install_requires=[
# Any dependencies you have go here
],
# More metadata like author, description, etc.
)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
Create Other Important Files README.md: This is your project's readme file, which typically includes an introduction to your package, installation instructions, and examples of how to use it. LICENSE: If you want to make your package open source, you should include a license file.
-
Build Your Package You can use setuptools to create a source distribution. In your terminal, navigate to the same directory as setup.py and run:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
python setup.py sdist
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5.Install Your Package Locally
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pip install .
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++