-
Notifications
You must be signed in to change notification settings - Fork 225
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
Changes from 3 commits
c78e07c
4b37264
68e502c
f2bd5df
f5ef847
b3e2ce1
e9decc4
3163db2
529d726
807d0d4
4b65c0b
8e49a96
508542b
973424a
bf6d5de
55624e7
7c21658
b3ad7f2
ff0bd74
e9dbf83
757c4a9
8723e72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
# 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.9.2dev" | ||
# The version is read from the pyproject.toml file | ||
from importlib import metadata | ||
__version__ = metadata.version(__package__) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this actually work? Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is following the example here: https://github.com/pypa/setuptools_scm#retrieving-package-version-at-runtime It relies on the package actually being installed (and yes I've actually just pushed an update using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Update: I've merged #499 into here to check this. The RTD build now succeeds. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# setuptools settings (we could change to poetry or flit in the future) | ||
[build-system] | ||
requires = [ | ||
"setuptools>=61.0.0, <63.0.0", | ||
"wheel>=0.36.0, <0.38.0" | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools] | ||
include-package-data = true | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["."] | ||
include = ["alibi_detect*"] | ||
exclude = ["**/tests*"] # tests should be excluded by default (https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#flat-layout) but exclude explicitly in case of change | ||
namespaces = false | ||
|
||
# Project metadata | ||
[project] | ||
name = "alibi-detect" | ||
description = "Algorithms for outlier, adversarial and drift detection." | ||
authors = [ | ||
{name = "Seldon Technologies Ltd."}, | ||
{email = "[email protected]"} | ||
] | ||
license = {text = "Apache-2.0"} | ||
readme = "README.md" | ||
version = "0.9.2dev" | ||
requires-python = ">=3.7, <3.11" | ||
|
||
classifiers = [ | ||
"Intended Audience :: Science/Research", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Topic :: Scientific/Engineering" | ||
] | ||
|
||
dependencies = [ | ||
"matplotlib>=3.0.0, <4.0.0", | ||
"numpy>=1.16.2, <2.0.0", | ||
"pandas>=0.23.3, <2.0.0", | ||
"Pillow>=5.4.1, <10.0.0", | ||
"opencv-python>=3.2.0, <5.0.0", | ||
"scipy>=1.3.0, <2.0.0", | ||
'scikit-image>=0.14.2, !=0.17.1, <0.20', # https://github.com/SeldonIO/alibi/issues/215 | ||
"scikit-learn>=0.20.2, <1.1.0", | ||
"tensorflow>=2.2.0, !=2.6.0, !=2.6.1, <2.9.0", # https://github.com/SeldonIO/alibi-detect/issues/375 and 387 | ||
"tensorflow_probability>=0.8.0, <0.17.0", | ||
"transformers>=4.0.0, <5.0.0", | ||
"dill>=0.3.0, <0.4.0", | ||
"tqdm>=4.28.1, <5.0.0", | ||
"requests>=2.21.0, <3.0.0", | ||
"numba>=0.50.0, !=0.54.0, <0.56.0" # Avoid 0.54 due to: https://github.com/SeldonIO/alibi/issues/466 | ||
] | ||
|
||
[project.urls] | ||
repository = "https://github.com/SeldonIO/alibi-detect" | ||
documentation = "https://docs.seldon.io/projects/alibi-detect/en/stable/" | ||
|
||
[project.optional-dependencies] | ||
prophet = ["fbprophet>=0.5, <0.7", "holidays==0.9.11", "pystan<3.0"] | ||
torch = ["torch>=1.7.0"] | ||
|
||
|
||
# pytest | ||
[tool.pytest.ini_options] | ||
addopts = "--tb native -W ignore --cov=alibi_detect" | ||
|
||
|
||
# mypy | ||
[tool.mypy] | ||
ignore_missing_imports = true | ||
strict_optional = false | ||
show_error_codes = true | ||
|
||
|
||
# tox test environment for generating licenses (below syntax subject to change - https://tox.wiki/en/latest/example/basic.html#pyproject-toml-tox-legacy-ini) | ||
[tool.tox] | ||
legacy_tox_ini = """ | ||
[tox:tox] | ||
|
||
[testenv:licenses] | ||
basepython = python | ||
deps = | ||
pip-licenses | ||
typing_extensions # not present with py38 | ||
idna-ssl # not present with py36 | ||
dataclasses # not present with py36 | ||
importlib-metadata # not present with py38 | ||
zipp # not present with py38 | ||
fsspec # not present with py36 | ||
locket # not present with py36 | ||
partd # not present with py36 | ||
extras = all | ||
commands = | ||
pip-licenses \ | ||
--from=mixed \ | ||
--format=csv \ | ||
--output-file=./licenses/license_info.csv | ||
pip-licenses \ | ||
--from=mixed \ | ||
--format=plain-vertical \ | ||
--with-license-file \ | ||
--no-license-path \ | ||
--output-file=./licenses/license.txt | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,12 @@ | ||
[aliases] | ||
test=pytest | ||
|
||
[tool:pytest] | ||
addopts = | ||
--tb native | ||
-W ignore | ||
--cov=alibi_detect | ||
#-n auto | ||
#--forked | ||
|
||
[flake8] | ||
[flake8] # currently no pyproject.toml support for flake8 (https://github.com/PyCQA/flake8/issues/234) | ||
max-line-length = 120 | ||
exclude = | ||
# sphinx configuration | ||
doc/source/conf.py | ||
# post-test | ||
.eggs/ | ||
|
||
[mypy] | ||
ignore_missing_imports = True | ||
strict_optional = False | ||
show_error_codes = True | ||
|
||
# sphinx configuration | ||
[mypy-conf] | ||
ignore_errors = True | ||
|
||
# tox test environment for generating licenses | ||
[tox:tox] | ||
|
||
[testenv:licenses] | ||
basepython = python | ||
deps = | ||
pip-licenses | ||
typing_extensions # not present with py38 | ||
idna-ssl # not present with py36 | ||
dataclasses # not present with py36 | ||
importlib-metadata # not present with py38 | ||
zipp # not present with py38 | ||
fsspec # not present with py36 | ||
locket # not present with py36 | ||
partd # not present with py36 | ||
extras = all | ||
commands = | ||
pip-licenses \ | ||
--from=mixed \ | ||
--format=csv \ | ||
--output-file=./licenses/license_info.csv | ||
pip-licenses \ | ||
--from=mixed \ | ||
--format=plain-vertical \ | ||
--with-license-file \ | ||
--no-license-path \ | ||
--output-file=./licenses/license.txt |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the version of
build
be specified in thepyproject.toml
too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh good point. This is a weird one as we still need to
pip install build
in the Makefile, since we need to run thepython -m build --sdist --wheel
command. If we also bound thebuild
version in thepyproject.toml
, this does then pull in the correctbuild
version within the isolated build virtualenv, but I'd imagine this isn't actually used since we're already in the process of runningpython -m build
with the pre-installedbuild
...Will have a think about this one 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually think it makes sense to do the build (and publish) via a github action, in order to give is complete control over the build environment. Have added a
.github/workflows/publish.yml
(still requires testing/refinement).This approach also simplifies the release process to something like:
git checkout master
in current local repo (no need for fresh virtual env etc.setuptools_scm
will check for dirty workdir).README.md
and citation.git commit
andgit tag
.As a safety net we can have logic to push to TestPyPI if tagged with RC version, otherwise push to PyPI.