2.5.30 • Published 2 years ago

semantic-release-python v2.5.30

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

A semantic-release plugin for PyPi.org that supports both regular and Poetry projects

Table of Contents

Overview

Semantic Release Python is a semantic-release plugin that brings support for managing the publication of PyPi packages. It supports traditional Python projects with a setup.cfg file and also supports Poetry projects.

This plugin requires both Python 3 and a recent version of Node.js to be present. After installing the plugin, a few supporting Python packages will automatically be installed into a virtualenv located at .venv. Using a virtualenv helps to prevent incompatibilities with your current installed software. Before you run any configuration that contains, you must source the virtualenv by running . venv/bin/activate or install the dependencies in this project's requirements.txt through other means prior to utilizing the plugin.

Requirements

If you are simply including this library in your project, all you need is a recent version of Node.js. Node.js >14.18.0 is sometimes required and is the only version range we actively support. Albeit, it is highly probable that lower versions will work as well depending on the requirements that this project imports.

Developer Requirements

The following versions of Node.js and Python are required for development:

Other versions may work, but only the above versions are supported. Most development dependencies are installed automatically by our Taskfile.yml set-up (even Node.js and Python). Run bash start.sh to install Bodega (an improved fork of go-task) and run the initialization sequence. The taskfiles will automatically install dependencies as they are needed, based on what development tasks you are running. For more information, check out the CONTRIBUTING.md or simply run:

npm run help

npm run help will ensure Bodega is installed and then open an interactive dialog where you can explore and learn about various developer commands.

Lifecycle Hooks

StepDescription
verifyConditionsVerify the environment variable PYPI_TOKENVerify PYPI_TOKEN is authorized to publish on the specified repositoryIf the project is not a Poetry project (i.e. it has a setup.cfg), then verify that version is not set inside setup.py (version will be set in setup.cfg)If it is not Poetry project, check if the packages setuptools, wheel and twine are installedIf it is a Poetry project (i.e. contains pyproject.toml instead of setup.cfg), ensure Poetry is installed
prepareUpdate the version in setup.cfg and create the distribution packages if it is not a Poetry project. But, if it is a Poetry project, then just update the version.
publishBuild the project if it is a Poetry project and then publish the Python package to the PYPI_REPO_URL

Environment Variables

VariableDescriptionRequiredDefault
PYPI_TOKENAPI token for PyPi (or password if PYPI_USERNAME is specified)true
PYPI_USERNAMEPyPi username (only required if you are using a password instead of an API token)false__token__
PYPI_REPO_URLURL of remote Python package repositoryfalsehttps://upload.pypi.org/legacy/

Options

OptionTypeDefaultDescription
setupPystring./setup.pyLocation of setup.py (or any file in the root of the project for a Poetry project)
distDirstringdistDirectory to put the source distribution archive(s) in, relative to the directory of setup.py (this variable is not used in Poetry projects)
repoUrlstringhttps://upload.pypi.org/legacy/The repository to upload the package to
pypiPublishbooleantrueWhether to publish the Python package to the PyPi registry. If false, the package version will still be updated.
gpgSignbooleanfalseWhether to sign the package using GPG. A valid PGP key must already be installed and configured on the host. Our implementation for Poetry projects currently do not support this feature.
gpgIdentitystringnullWhen gpgSign is true, set the GPG identify to use when signing files. Leave empty to use the default identity. Our implementation for Poetry projects currently do not support this feature.

Examples

This plugin can be configured in the semantic-release configuration file. For a full example of a configuration used for multiple project types, check out the shareable configuration we use for all our of projects.

Basic Example Using setup.cfg

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "semantic-release-python"
  ]
}

Example Using Poetry

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "semantic-release-python",
      {
        "setupPy": "./pyproject.toml"
      }
    ]
  ]
}

Post-Install Hook

Whenever this package is installed, it will run a bash script that ensures Bodega is installed and then install dependencies using a task defined in the Taskfiles included in the modules source. It attempts to use Poetry if it is installed but falls back to a regular venv if Poetry is not available.

Using Poetry might be the easier route. It will be easier to figure out exactly how this plugin can be used (by looking at semantic-release-config and our semantic-release task which is run by Bodega, a fork of go-task/task).

Running Without Poetry

If you do not use Poetry, then before running semantic-release you should ensure that you activate the virtual environment that the post-install hook should automatically install (as long as Python 3 is installed). You can activate the Python virtual environment by running:

. .venv/bin/activate

After you run that, you enter a shell where you will have access to the dependencies that the post-install hook installed. You can then run the semantic-release CLI.

Bypassing the Post-Install Hook

There may be some cases where you do not want the dependencies to be installed automatically by the plugin. For instance, you may want to bypass the post-install hook when running in a CI environment where it does not make a difference when using Python virtual environments. To disable the post-install hook, run the following somewhere before the installation:

export SEMANTIC_PYTHON_POST_INSTALL=false

If SEMANTIC_PYTHON_POST_INSTALL is set to false, then the post-install hook will be skipped. This allows you to permit other NPM packages to run post-install hooks without having to disable all scripts by running npm i --ignore-scripts.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page. If you would like to contribute, please take a look at the contributing guide.

Brian Zalewski

License

Copyright © 2020-2021 Megabyte LLC. This project is MIT licensed.

2.5.30

2 years ago

2.5.24

2 years ago

2.5.23

2 years ago

2.5.22

2 years ago

2.5.20

2 years ago

2.5.19

2 years ago

2.5.18

2 years ago

2.5.17

2 years ago

2.5.16

2 years ago

2.5.15

2 years ago

2.5.14

2 years ago

2.5.12

2 years ago

2.5.11

2 years ago

2.5.10

2 years ago

2.5.9

2 years ago

2.5.8

2 years ago

2.5.7

2 years ago

2.5.6

2 years ago

2.5.5

2 years ago

2.5.4

2 years ago

2.5.3

2 years ago

2.5.2

2 years ago

2.5.1

2 years ago

2.5.0

2 years ago