Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish releases to PyPI via a GitHub Action (and replace setup.py with pyproject.toml) #495

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This github action builds Alibi Detect and publishes it to PyPI.
# It is only run when a new tag is pushed to github.
# See https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: Publish 📦 to PyPI

# Only run when tags starting with "v" are pushed
on:
push:
tags:
- 'v*'

jobs:
build-and-publish:
name: Build and publish
runs-on: ubuntu-18.04

steps:
# Setup version extractor (from tag)
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'

# Setup Python
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9

# Build
- name: Install pypa/build
run: python -m pip install --user build==0.9.0
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .

# Publish to Test PyPI unconditionally
- name: Publish 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

# TODO - Test below by:
# 1) AVOID adding PyPI api token, to protect from inadvertant release if the conditional is broken
# 2) Uncomment.
# 3) Push a non-stable tag (e.g. v11.0.0-alpha1). Check below step is NOT triggered.
# 4) Once happy, we can setup PyPI api token and it'll be ready to go.
# # Publish to real PyPI if the tag doesn't indicate a pre-release (i.e. not an alpha, beta or rc tag)
# (see https://github.com/nowsprinting/check-version-format-action#is_stable)
# - name: Publish 📦 to PyPI
# if: steps.version.outputs.prerelease == ''
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# alibi_detect version file - ignore this as controlled by setuptools_scm
alibi_detect/_version.py

# emacs tmp files
*~

Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ repos:
types-requests~=2.25,
types-toml~=0.10
]
exclude: 'doc/'
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ build:
os: ubuntu-20.04
tools:
python: "3.9"
apt_packages:
- pandoc

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -25,3 +23,5 @@ formats:
python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
install: ## Install package in editable mode with all the dependencies
pip install -e .

.PHONY: clean
clean: # Clean up install (and build)
pip uninstall -y alibi-detect
rm -r alibi_detect.egg-info/ dist/ build/

.PHONY: test
test: ## Run all tests
python setup.py test
pytest alibi-detect

.PHONY: lint
lint: ## Check linting according to the flake8 configuration in setup.cfg
Expand Down Expand Up @@ -33,8 +38,9 @@ clean_docs: ## Clean the documentation build
rm -r doc/source/api

.PHONY: build_pypi
build_pypi: ## Build the Python package
python setup.py sdist bdist_wheel
build_pypi: ## Build the Python package (virtualenv installed due to Debian issue https://github.com/pypa/build/issues/224)
pip install --upgrade build virtualenv
python -m build --sdist --wheel

.PHONY: push_pypi_test
push_pypi_test: ## Upload the Python package to the test PyPI registry
Expand Down
1 change: 0 additions & 1 deletion alibi_detect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from . import ad, cd, models, od, utils, saving
from .version import __version__ # noqa F401

__all__ = ["ad", "cd", "models", "od", "utils", "saving"]
10 changes: 4 additions & 6 deletions alibi_detect/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Store the version here so:
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module

__version__ = "0.11.0dev"
try:
from ._version import version as __version__ # noqa: F401
except ModuleNotFoundError:
raise ImportError('alibi-detect must be installed before it can be imported.')
42 changes: 9 additions & 33 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
#
import os
import sys
# Hide RemovedInSphinx40Warning. Can remove once upgraded to sphinx>=4.0
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)

from importlib.metadata import version
sys.path.insert(0, os.path.abspath("../.."))

# -- Project information -----------------------------------------------------
Expand All @@ -26,13 +23,10 @@
copyright = "2019, Seldon Technologies Ltd"
author = "Seldon Technologies Ltd"

# The short X.Y version
# import alibi_detect
exec(open("../../alibi_detect/version.py").read())

version = __version__
# The full version, including alpha/beta/rc tags
release = __version__
# Full version including dev/commit/date tags
release = version('alibi-detect')
# Major/minor/patch version
version = '.'.join(release.split('.')[:3])

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -86,31 +80,13 @@
apidoc_separate_modules = True
apidoc_extra_args = ["-d 6"]

# mock imports
# numpy, pandas and matplotlib are not included as these are installed on
# ReadTheDocs PYTHON_VERSION_39 docker image (https://hub.docker.com/r/readthedocs/build/dockerfile/)
# mock optional deps (since these are not installed on RTD)
autodoc_mock_imports = [
"sklearn",
"skimage",
"requests",
"cv2",
"bs4",
"keras",
"seaborn",
"PIL",
"prophet",
"torch",
"tensorflow",
"spacy",
"keras",
"tensorflow_probability",
"scipy",
"fbprophet",
"torch",
"transformers",
"tqdm",
"dill",
"numba",
"pydantic",
"toml",
"catalogue",
"pykeops"
]

Expand Down
6 changes: 3 additions & 3 deletions licenses/license.txt
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ SOFTWARE.


alibi-detect
0.11.0.dev0
0.10.5.dev55+gbf6d5de.d20221111
Apache Software License
Apache License
Version 2.0, January 2004
Expand Down Expand Up @@ -1224,7 +1224,7 @@ SOFTWARE.


fsspec
2022.10.0
2022.11.0
BSD License
BSD 3-Clause License

Expand Down Expand Up @@ -7180,7 +7180,7 @@ POSSIBILITY OF SUCH DAMAGE.


tokenizers
0.13.1
0.13.2
Apache Software License
UNKNOWN

Expand Down
6 changes: 3 additions & 3 deletions licenses/license_info.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Pillow","9.3.0","Historical Permission Notice and Disclaimer (HPND)"
"PyWavelets","1.4.1","MIT License"
"PyYAML","6.0","MIT License"
"alibi-detect","0.11.0.dev0","Apache Software License"
"alibi-detect","0.10.5.dev55+gbf6d5de.d20221111","Apache Software License"
"catalogue","2.0.8","MIT License"
"certifi","2022.9.24","Mozilla Public License 2.0 (MPL 2.0)"
"charset-normalizer","2.1.1","MIT License"
Expand All @@ -12,7 +12,7 @@
"dill","0.3.6","BSD License"
"filelock","3.8.0","Public Domain"
"fonttools","4.38.0","MIT License"
"fsspec","2022.10.0","BSD License"
"fsspec","2022.11.0","BSD License"
"huggingface-hub","0.10.1","Apache Software License"
"idna","3.4","BSD License"
"idna-ssl","1.1.0","MIT License"
Expand Down Expand Up @@ -42,7 +42,7 @@
"six","1.16.0","MIT License"
"threadpoolctl","3.1.0","BSD License"
"tifffile","2022.10.10","BSD License"
"tokenizers","0.13.1","Apache Software License"
"tokenizers","0.13.2","Apache Software License"
"toml","0.10.2","MIT License"
"toolz","0.12.0","BSD License"
"tqdm","4.64.1","MIT License; Mozilla Public License 2.0 (MPL 2.0)"
Expand Down
Loading