From 47f9592c5f5d6837fd0a3815d80e2d135660de02 Mon Sep 17 00:00:00 2001 From: Vladimir Iglovikov Date: Tue, 8 Oct 2024 15:28:06 -0700 Subject: [PATCH] Udpated building scripts (#1983) * Empty-Commit * Version boosted to 1.4.18 * Updated version builder * Correctly handles version * Cleaned package build --- .github/workflows/upload_to_pypi.yml | 1 - MANIFEST.in | 10 ++++ albumentations/_version.py | 2 +- pyproject.toml | 82 ++++++++++++++++++++++++++-- setup.py | 65 ++++------------------ 5 files changed, 98 insertions(+), 62 deletions(-) diff --git a/.github/workflows/upload_to_pypi.yml b/.github/workflows/upload_to_pypi.yml index d61628626..cd4f37aaf 100644 --- a/.github/workflows/upload_to_pypi.yml +++ b/.github/workflows/upload_to_pypi.yml @@ -22,6 +22,5 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: | - rm -rf tests tools benchmark python -m build twine upload dist/* diff --git a/MANIFEST.in b/MANIFEST.in index 4e5c8ccad..60feb1c4f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,3 +5,13 @@ prune docs/_build global-exclude docs/augs_overview/*/images/*.jpg global-exclude *.py[co] .DS_Store + +# Exclude test, tools, and benchmark directories +prune tests +prune tools +prune benchmark +prune conda.recipe +prune codecov.yaml +prune pre-commit-config.yaml +prune .github +prune requirements-dev.txt diff --git a/albumentations/_version.py b/albumentations/_version.py index 122fcbff3..ba5ed8f09 100644 --- a/albumentations/_version.py +++ b/albumentations/_version.py @@ -1 +1 @@ -__version__ = "1.4.17" +__version__ = "1.4.18" diff --git a/pyproject.toml b/pyproject.toml index cf186165b..06d61ac5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,81 @@ -# NOTE: you have to use single-quoted strings in TOML for regular expressions. -# It's the equivalent of r-strings in Python. Multiline strings are treated as -# verbose regular expressions by Black. Use [ ] to denote a significant space -# character. - [build-system] build-backend = "setuptools.build_meta" -requires = [ "setuptools", "wheel" ] + +requires = [ "setuptools>=45", "wheel" ] + +[project] +name = "albumentations" +description = "Fast, flexible, and advanced image augmentation library for deep learning and computer vision. Albumentations offers a wide range of transformations for images, masks, bounding boxes, and keypoints, with optimized performance and seamless integration into ML workflows." +readme = "README.md" +keywords = [ + "artificial intelligence", + "bounding box", + "computer vision", + "computer vision library", + "data augmentation", + "data preprocessing", + "deep learning", + "fast augmentation", + "image augmentation", + "image classification", + "image processing", + "image transformation", + "instance segmentation", + "keras", + "keypoint detection", + "machine learning", + "object detection", + "pytorch", + "semantic segmentation", + "tensorflow", +] +license = { file = "LICENSE" } +authors = [ + { name = "Vladimir I. Iglovikov" }, + { name = "Mikhail Druzhinin" }, + { name = "Alex Parinov" }, + { name = "Alexander Buslaev" }, + { name = "Eugene Khvedchenya" }, +] +requires-python = ">=3.8" + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Scientific/Engineering :: Image Processing", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", + "Typing :: Typed", +] +dynamic = [ "dependencies", "version" ] +optional-dependencies.hub = [ "huggingface-hub" ] +optional-dependencies.text = [ "pillow" ] +urls.Homepage = "https://albumentations.ai" + +[tool.setuptools] +packages = { find = { include = [ + "albumentations*", +], exclude = [ + "tests", + "tools", + "benchmark", +] } } + +package-data = { albumentations = [ "*.txt", "*.md" ] } + +[tool.setuptools.exclude-package-data] +"*" = [ "tests*", "tools*", "benchmark*", "conda.recipe*" ] [tool.ruff] # Exclude a variety of commonly ignored directories. diff --git a/setup.py b/setup.py index 8ec483cbd..fe90b8e4d 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ import re -from pathlib import Path from typing import List, Tuple +import os from pkg_resources import DistributionNotFound, get_distribution -from setuptools import find_packages, setup +from setuptools import setup, find_packages INSTALL_REQUIRES = [ "numpy>=1.24.4", "scipy>=1.10.0", "scikit-image>=0.21.0", @@ -23,22 +23,16 @@ ), ] -def get_version() -> str: - current_dir = Path(__file__).parent - version_file = current_dir / "albumentations" / "_version.py" - if not version_file.is_file(): - raise FileNotFoundError(f"Version file not found: {version_file}") - with open(version_file, encoding="utf-8") as f: - version_match = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', f.read(), re.M) - if version_match: - return version_match.group(1) +def get_version(): + version_file = os.path.join(os.path.dirname(__file__), 'albumentations', '_version.py') + with open(version_file, 'r') as f: + version_line = f.read().strip() + version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]" + match = re.match(version_regex, version_line, re.M) + if match: + return match.group(1) raise RuntimeError("Unable to find version string.") -def get_long_description() -> str: - base_dir = Path(__file__).parent - with open(base_dir / "README.md", encoding="utf-8") as f: - return f.read() - def choose_requirement(mains: Tuple[str, ...], secondary: str) -> str: chosen = secondary for main in mains: @@ -57,44 +51,7 @@ def get_install_requirements(install_requires: List[str], choose_install_require return install_requires setup( - name="albumentations", version=get_version(), - description="An efficient library for image augmentation, providing extensive transformations to support machine learning and computer vision tasks.", - long_description=get_long_description(), - long_description_content_type="text/markdown", - author="Vladimir I. Iglovikov, Mikhail Druzhinin, Alex Parinov, Alexander Buslaev, Eugene Khvedchenya", - license="MIT", - url="https://albumentations.ai", - packages=find_packages(exclude=["tests", "tools", "benchmark"]), - python_requires=">=3.8", + packages=find_packages(exclude=["tests", "tools", "benchmark"], include=['albumentations*']), install_requires=get_install_requirements(INSTALL_REQUIRES, CHOOSE_INSTALL_REQUIRES), - extras_require={ - "hub": ["huggingface_hub"], - "text": ["pillow"] - }, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development :: Libraries", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - "Topic :: Scientific/Engineering :: Image Processing", - "Typing :: Typed" - ], - keywords=[ - "image augmentation", "data augmentation", "computer vision", - "deep learning", "machine learning", "image processing", - "artificial intelligence", "augmentation library", - "image transformation", "vision augmentation" - ], )