Split depedencies (#471)

This commit is contained in:
Daniel Gatis 2023-06-19 17:23:29 -03:00 committed by GitHub
parent 3cbad20f33
commit bcb45a27ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 89 additions and 99 deletions

View File

@ -10,9 +10,8 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install --upgrade pip wheel
- run: pip install --upgrade setuptools
- run: pip install bandit black flake8 flake8-bugbear flake8-comprehensions isort safety mypy
- name: Install dependencies
run: pip install .[cli,dev]
- run: mypy --install-types --non-interactive --ignore-missing-imports ./rembg
- run: bandit --recursive --skip B101,B104,B310,B311,B303,B110 --exclude ./rembg/_version.py ./rembg
- run: black --force-exclude rembg/_version.py --check --diff ./rembg

View File

@ -13,11 +13,9 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: "Installs dependencies"
run: |
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel twine
- name: "Builds and uploads to PyPI"
- name: Install dependencies
run: pip install .[cli,dev]
- name: Builds and uploads to PyPI
run: |
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*

View File

@ -15,11 +15,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
pip install .
pip install pytest
- name: Install dependencies
run: pip install .[cli,dev]
- name: Test installation with pytest
run: |
pytest

View File

@ -1,25 +0,0 @@
name: Test in specific environment
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up environment
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
- name: Test with pytest
run: |
PYTHONPATH=$PYTHONPATH:. pytest .

View File

@ -80,7 +80,8 @@ python: >3.7, <3.12
CPU support:
```bash
pip install rembg
pip install rembg # for library
pip install rembg[cli] # for library + cli
```
GPU support:
@ -96,7 +97,8 @@ Go to https://onnxruntime.ai and check the installation matrix.
If yes, just run:
```bash
pip install rembg[gpu]
pip install rembg[gpu] # for library
pip install rembg[gpu,cli] # for library + cli
```
## Usage as a cli

View File

@ -1,14 +1,33 @@
import click
from . import _version
from .commands import command_functions
import pkg_resources
@click.group()
@click.version_option(version=_version.get_versions()["version"])
def main() -> None:
pass
package_distribution = pkg_resources.get_distribution("rembg")
for extra in package_distribution.extras:
if extra == "cli":
requirements = package_distribution.requires(extras=(extra,))
for requirement in requirements:
try:
pkg_resources.require(requirement.project_name)
except pkg_resources.DistributionNotFound:
print(f"Missing dependency: '{requirement.project_name}'")
print(
"Please, install rembg with the cli feature: pip install rembg[cli]"
)
exit(1)
for command in command_functions:
main.add_command(command)
import click
from . import _version
from .commands import command_functions
@click.group()
@click.version_option(version=_version.get_versions()["version"])
def _main() -> None:
pass
for command in command_functions:
_main.add_command(command)
_main()

View File

@ -1 +0,0 @@
onnxruntime-gpu

View File

@ -1,19 +0,0 @@
aiohttp
asyncer
click
fastapi
filetype
gradio
imagehash
numpy
onnxruntime
opencv-python-headless
pillow
pooch
pymatting
python-multipart
scikit-image
scipy
tqdm
uvicorn
watchdog

View File

@ -11,6 +11,52 @@ here = pathlib.Path(__file__).parent.resolve()
long_description = (here / "README.md").read_text(encoding="utf-8")
install_requires = [
"numpy",
"onnxruntime",
"opencv-python-headless",
"pillow",
"pooch",
"pymatting",
"scikit-image",
"scipy",
]
extras_require = {
"dev": [
"bandit",
"black",
"flake8",
"imagehash",
"isort",
"mypy",
"pytest",
"setuptools",
"twine",
"wheel",
],
"gpu": ["onnxruntime-gpu"],
"cli": [
"aiohttp",
"asyncer",
"click",
"fastapi",
"filetype",
"gradio",
"python-multipart",
"tqdm",
"uvicorn",
"watchdog",
],
}
entry_points = {
"console_scripts": [
"rembg=rembg.cli:main",
],
}
setup(
name="rembg",
description="Remove image background",
@ -35,37 +81,11 @@ setup(
"Programming Language :: Python :: 3.11",
],
keywords="remove, background, u2net",
packages=["rembg", "rembg.sessions", "rembg.commands"],
python_requires=">=3.8, <3.12",
install_requires=[
"aiohttp",
"asyncer",
"click",
"fastapi",
"filetype",
"gradio",
"imagehash",
"numpy",
"onnxruntime",
"opencv-python-headless",
"pillow",
"pooch",
"pymatting",
"python-multipart",
"scikit-image",
"scipy",
"tqdm",
"uvicorn",
"watchdog",
],
entry_points={
"console_scripts": [
"rembg=rembg.cli:main",
],
},
extras_require={
"gpu": ["onnxruntime-gpu"],
},
packages=find_packages(),
install_requires=install_requires,
entry_points=entry_points,
extras_require=extras_require,
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
)