[go: nahoru, domu]

Skip to content

Utility package that caters to the common needs across various repositories

License

Notifications You must be signed in to change notification settings

mazzasaverio/myrepoutils

Repository files navigation

MyRepoUtils: A Lightweight Utility Package for Repositories

MyRepoUtils is designed to be a streamlined utility package that caters to the common needs across various repositories. Our goal is to provide a lean version of essential utilities, making your development process smoother and more efficient.

Table of Contents


Getting Started

Installation

(Instructions on how to install your package. This could include the command to install via pip, requirements, and any initial setup needed.)

Quick Start Guide

(A brief guide or example showing how to quickly get up and running with your package. This could include basic usage examples or a simple tutorial.)


Tutorials

How to Publish a Package with Poetry

To deploy and manage a Python package on PyPI, with your code hosted on GitHub, follow these refined steps:

1. Install Poetry

Poetry is a Python dependency management and packaging tool. Begin by installing it via your terminal:

curl -sSL https://install.python-poetry.org | python3 -

Ensure Poetry's path is included in your system's PATH to use it globally.

2. Initialize and Configure Poetry

  • Initialize Poetry: In your project's root directory (e.g., /home/sam/github/myrepoutils), run the following to create a pyproject.toml file. This file is essential for Poetry to recognize and manage your project.

    cd /home/sam/github/myrepoutils
    poetry init
  • Configure pyproject.toml: Edit the pyproject.toml to include your package's details, like name, version, description, authors, and dependencies. Here's an example configuration:

    [tool.poetry]
    name = "myrepoutils"
    version = "0.1.0"
    description = "A brief description of your package"
    authors = ["Your Name <you@example.com>"]
    
    [tool.poetry.dependencies]
    python = "^3.11"
    
    [tool.poetry.dev-dependencies]
    pytest = "^6.2.4"

3. Version Your Package

Adhere to Semantic Versioning (SemVer), which uses a MAJOR.MINOR.PATCH format:

  • Increment the MAJOR version for incompatible API changes.
  • Increment the MINOR version for new, backward-compatible functionalities.
  • Increment the PATCH version for backward-compatible bug fixes.

Based on your changes, update your version accordingly in the pyproject.toml file.

4. Build Your Package

With your pyproject.toml set up, build your package using Poetry:

poetry build

This command creates a distributable package in the dist folder.

5. Publish Your Package to PyPI

  • Create a PyPI Account: Ensure you have an account on PyPI.

  • Publish: Use Poetry to publish your package to PyPI. When prompted, enter your PyPI credentials:

    poetry publish

6. Update Your Package

To release new versions:

  1. Update the version in pyproject.toml as per semantic versioning.

  2. Rebuild and republish your package:

    poetry version patch  # Use `minor` or `major` for significant updates.
    poetry build
    poetry publish

Additional Tips:

  • Verify your package name is unique on PyPI.
  • Test your package locally before publishing.
  • Consider implementing a CI/CD pipeline for automated testing and deployment.

This streamlined guide facilitates the creation and publication of a Python package using Poetry on platforms like Ubuntu, ensuring adherence to best practices in the Python community.

Initial Setup in the New Environment

  1. Create and Activate a New Conda Environment: First, ensure you have a dedicated environment for your project to avoid dependency conflicts. Use Conda to create and activate a new environment:

    conda create --name myprojectenv python=3.11
    conda activate myprojectenv

    Adjust python=3.11 to the version you need.

  2. Install the Package: Install myrepoutils directly from PyPI using pip (Conda environments can use pip):

    pip install myrepoutils==0.1.2

    Specifying the version ensures you get the exact release you're after.

Managing Frequent Updates

When you update myrepoutils, you'll need to follow these steps to make the latest version available in your Conda environment:

  1. Update and Publish Your Package on PyPI: After making changes to myrepoutils, increment the version number following Semantic Versioning (e.g., to 0.1.3), rebuild, and publish the updated package to PyPI.

  2. Upgrade the Package in Your Environment: To use the latest version in your Conda environment, upgrade myrepoutils using pip:

    pip install --upgrade myrepoutils

    This command updates the package to the latest version available on PyPI.

Recommendations for Efficient Workflow

  • Automate Version Bumping: Consider using tools or scripts to automate the version bumping and package publishing process, especially if updates are frequent.

  • Use Environment Files: For projects involving multiple dependencies, it's practical to maintain a Conda environment file (environment.yml) or a pip requirements file (requirements.txt). This approach simplifies environment setup and ensures consistency across installations. However, for a single package that's frequently updated, direct pip installation commands as shown above are more straightforward.

  • Consider Local Development Installations: If myrepoutils is under active development and you're testing changes in real-time, you might install the package in editable mode (pip install -e .) in your development environment. This setup lets you see changes immediately without reinstalling after each update. Note that for production or stable environments, it's better to install the fixed versions as described.

By following these guidelines, you can efficiently manage and use your myrepoutils package across different projects and environments, ensuring you always have access to the latest features and fixes you've implemented.

About

Utility package that caters to the common needs across various repositories

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages