Skip to main content

A Python library to generate some motivation quotes.

Project description

My Library

A sample Python library.

Installation

To install this library, run the following command:

pip install my_library




# Create Python Module Guide
November 12, 2024
This conversation may reflect the link creator’s personalized data, which isn’t shared and can meaningfully change how the model responds.

## Step 1: Create Your Python Module/Library
Project Structure: Start by organizing your project into a folder structure like this:

```markdown
my_library/
├── my_library/
│   ├── __init__.py
│   ├── core.py
│   └── utils.py
├── tests/
│   └── test_core.py
├── README.md
├── LICENSE
├── setup.py
├── pyproject.toml
└── requirements.txt

my_library/: Contains your main package code. tests/: Holds your test files. README.md: Contains documentation for your project. LICENSE: Specifies the license type (e.g., MIT License). setup.py: Provides metadata and instructions to package your module. pyproject.toml: Defines build system requirements (e.g., setuptools). requirements.txt: Lists dependencies your package needs.

Step 2: Write Your Python Code

Create a Python module (e.g., core.py) with functions or classes you want to package.

# my_library/core.py
def greet(name):
    return f"Hello, {name}!"

Step 3: Add an init.py File

This file makes your directory a package. You can import your functions here if needed.

# my_library/__init__.py
from .core import greet

Step 4: Write Tests

Testing ensures that your code works as expected.

# tests/test_core.py
from my_library.core import greet

def test_greet():
    assert greet("Sridhar") == "Hello, Sridhar!"

Run your tests using a tool like pytest:

pip install pytest
pytest

Step 5: Create setup.py

This file is used to define your package metadata.

from setuptools import setup, find_packages

setup(
    name="my_library",
    version="0.1.0",
    description="A sample Python library",
    author="Sridhar",
    author_email="your_email@example.com",
    url="https://github.com/your_username/my_library",
    packages=find_packages(),
    install_requires=[],
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires='>=3.6',
)

Step 6: Create pyproject.toml

This file tells Python which build system to use.

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

Step 7: Create README.md and LICENSE

README.md: Add documentation, usage examples, etc. LICENSE: Include a license file, like the MIT License.

Step 7: Create README.md and LICENSE

README.md

# My Library

A sample Python library.

## Installation

To install this library, run the following command:

```bash
pip install my_library

Usage

Here's an example of how to use this library:

from my_library import greet
print(greet("Sridhar"))

Contributing

Contributions are welcome! If you'd like to contribute to this library, please fork the repository and submit a pull request.

License

This library is licensed under the MIT License. See the LICENSE file for more information.


#### LICENSE
```text
MIT License

Copyright (c) 2024 Sridhar

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.

Step 8: Generate Distribution Files

Now, it's time to package your project.

pip install setuptools wheel
python setup.py sdist bdist_wheel

This will create a dist/ directory with .tar.gz and .whl files.

Step 9: Upload to PyPI

Create a PyPI account: If you don’t have one, create an account on PyPI.

Install twine: This tool helps upload your package to PyPI.

pip install twine

Upload Your Package:

twine upload dist/*

Enter your credentials: You’ll be prompted for your PyPI username and password.

Step 10: Test Your Package

After uploading, you can install your package using:

pip install my_library

And test it:

from my_library import greet
print(greet("Sridhar"))

Step 11: Update Your Package

When making updates, increase the version number in setup.py and pyproject.toml. Rebuild and upload the new version:

python setup.py sdist bdist_wheel
twine upload dist/*

Tips Use a virtual environment to avoid conflicts with your system packages:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

Consider using setuptools-scm for automatic versioning if your project is hosted on GitHub.

By following these steps, you can successfully create, test, and publish your own Python module to PyPI. Happy coding, Sridhar!

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

quotesengine-0.1.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

QuotesEngine-0.1.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file quotesengine-0.1.2.tar.gz.

File metadata

  • Download URL: quotesengine-0.1.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for quotesengine-0.1.2.tar.gz
Algorithm Hash digest
SHA256 71fd4ea4384ac3fe93a8e0baf6535f8c6fb2a5aef2d5a6516f46461037395c85
MD5 f98f25d4405c8c856e0d35905492f896
BLAKE2b-256 0608758d1cc9db223105fd4f9dea195b96511670ebe621db02a24be717f4d203

See more details on using hashes here.

File details

Details for the file QuotesEngine-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: QuotesEngine-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for QuotesEngine-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cdc8c32c20089161418747a33c91688ee51622480965e98abb0260ca012efb50
MD5 aa67b141c8c21b186b65fefa1e0ac784
BLAKE2b-256 eb93de1e0c16707d2e210738f567f1a4370d656da9254d02466a15fe21828280

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