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.
- MyRepoUtils: A Lightweight Utility Package for Repositories
(Instructions on how to install your package. This could include the command to install via pip, requirements, and any initial setup needed.)
(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.)
To deploy and manage a Python package on PyPI, with your code hosted on GitHub, follow these refined steps:
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.
-
Initialize Poetry: In your project's root directory (e.g.,
/home/sam/github/myrepoutils
), run the following to create apyproject.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 thepyproject.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"
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.
With your pyproject.toml
set up, build your package using Poetry:
poetry build
This command creates a distributable package in the dist
folder.
-
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
To release new versions:
-
Update the version in
pyproject.toml
as per semantic versioning. -
Rebuild and republish your package:
poetry version patch # Use `minor` or `major` for significant updates. poetry build poetry publish
- 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.
-
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. -
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.
When you update myrepoutils
, you'll need to follow these steps to make the latest version available in your Conda environment:
-
Update and Publish Your Package on PyPI: After making changes to
myrepoutils
, increment the version number following Semantic Versioning (e.g., to0.1.3
), rebuild, and publish the updated package to PyPI. -
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.
-
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.