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

feature: package and publish xplique-cpu in addition to xplique #170

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.XPLIQUE_TOKEN }}
run: |
# package classic xplique
python setup.py sdist bdist_wheel
# package xplique-cpu
export PACKAGE_CPU=1
python setup.py sdist bdist_wheel
# publish both
twine upload dist/*
6 changes: 4 additions & 2 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test with tox (Python ${{ matrix.python-version }} - TF ${{ matrix.tf-version }})
run: tox -e py$(echo ${{ matrix.python-version }}-tf${{ matrix.tf-version }} | tr -d .)
- name: Test with tox (Python ${{ matrix.python-version }} - TF ${{ matrix.tf-version }}(-cpu))
run: |
tox -e py$(echo ${{ matrix.python-version }}-tf${{ matrix.tf-version }} | tr -d .)
tox -e py$(echo ${{ matrix.python-version }}-tf${{ matrix.tf-version }}-cpu | tr -d .)
8 changes: 8 additions & 0 deletions requirements_cpu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
numpy<2.0.0
tensorflow-cpu>=2.1.0
scikit-learn
scikit-image
matplotlib
scipy
opencv-python
deprecated
33 changes: 25 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tag = False
[bumpversion:file:xplique/__init__.py]

[pylint]
disable =
disable =
R0903, # allows to expose only one public method
R0914, # allow multiples local variables
E0401, # pending issue with pylint see pylint#2603
Expand All @@ -30,29 +30,41 @@ ignore-imports = no
ignore-signatures = yes

[tox:tox]
envlist = py{37,38,39,310}-lint, py{37,38,39,310}-tf{22,25,28,211}, py{38,39,310}-tf{25,28,211}-torch{111,113,200}
envlist = py{37,38,39,310}-lint, py{37,38,39,310}-tf{22,25,28,211}, py{37,38,39,310}-tf{22,25,28,211}-cpu, py{38,39,310}-tf{25,28,211}-torch{111,113,200}

[testenv:py{37,38,39,310}-lint]
deps =
deps =
pylint
-rrequirements.txt
commands =
commands =
python -m pylint xplique

[testenv:py{37,38,39,310}-tf{22,25,28,211}]
deps =
deps =
pytest
pytest-cov
tf21: tensorflow ~= 2.2.0,<2.16
tf25: tensorflow ~= 2.5.0,<2.16
tf28: tensorflow ~= 2.8.0,<2.16
tf211: tensorflow ~= 2.11.0,<2.16
-rrequirements.txt
commands =
commands =
pytest --cov=xplique --ignore=xplique/wrappers/pytorch.py --ignore=tests/wrappers/test_pytorch_wrapper.py --ignore=tests/concepts/test_craft_torch.py --ignore=tests/example_based/test_torch.py {posargs}

[testenv:py{37,38,39,310}-tf{22,25,28,211}-cpu]
deps =
pytest
pytest-cov
tf21: tensorflow-cpu ~= 2.2.0,<2.16
tf25: tensorflow-cpu ~= 2.5.0,<2.16
tf28: tensorflow-cpu ~= 2.8.0,<2.16
tf211: tensorflow-cpu ~= 2.11.0,<2.16
-rrequirements_cpu.txt
commands =
pytest --cov=xplique --ignore=xplique/wrappers/pytorch.py --ignore=tests/wrappers/test_pytorch_wrapper.py --ignore=tests/concepts/test_craft_torch.py --ignore=tests/example_based/test_torch.py {posargs}

[testenv:py{38,39,310}-tf{25,28,211}-torch{111,113,200}]
deps =
deps =
pytest
pytest-cov
tf25: tensorflow ~= 2.5.0,<2.16
Expand All @@ -62,9 +74,14 @@ deps =
torch113: torch == 1.13.0
torch200: torch
-rrequirements.txt
commands =
commands =
pytest --cov=xplique/wrappers/pytorch tests/wrappers/test_pytorch_wrapper.py tests/concepts/test_craft_torch.py tests/example_based/test_torch.py

[testenv:.pkg]
setenv =
PACKAGE_CPU = 1
passenv = * # needed by tox4, so env vars are visible for building borg

[mypy]
check_untyped_defs = True
warn_unused_configs = True
Expand Down
25 changes: 22 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
from setuptools import setup, find_packages
import os

INSTALL_REQUIRES = [
'numpy<2.0.0',
'scikit-learn',
'scikit-image',
'matplotlib',
'scipy',
'opencv-python',
'deprecated'
]
TENSORFLOW_VERSION = '>=2.1.0,<2.16.0'
PACKAGE_NAME = "Xplique"

if os.getenv("PACKAGE_CPU", False):
INSTALL_REQUIRES.append('tensorflow-cpu' + TENSORFLOW_VERSION)
PACKAGE_NAME += "-cpu"
else:
INSTALL_REQUIRES.append('tensorflow' + TENSORFLOW_VERSION)


with open("README.md", encoding="utf-8") as fh:
README = fh.read()

setup(
name="Xplique",
name=PACKAGE_NAME,
version="1.4.0",
description="Explanations toolbox for Tensorflow 2",
long_description=README,
long_description_content_type="text/markdown",
author="Thomas FEL",
author_email="[email protected]",
license="MIT",
install_requires=['numpy<2.0.0', 'tensorflow>=2.1.0,<2.16.0', 'scikit-learn', 'scikit-image',
'matplotlib', 'scipy', 'opencv-python', 'deprecated'],
install_requires=INSTALL_REQUIRES,
extras_require={
"tests": ["pytest", "pylint"],
"docs": ["mkdocs", "mkdocs-material", "numkdoc"],
Expand Down