Skip to content

Commit

Permalink
Updated build code (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
ternaus authored Oct 18, 2024
1 parent 1624105 commit 78da3ab
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ repos:
# hooks:
# - id: markdownlint
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.3.1"
rev: "2.4.3"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tomli"]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
rev: v0.7.0
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion albucore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.0.17"
__version__ = "0.0.18"

from .decorators import *
from .functions import *
Expand Down
80 changes: 64 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,50 @@
# 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 = "albucore"
description = "High-performance image processing functions for deep learning and computer vision."
readme = "README.md"
keywords = [ "deep learning", "image processing" ]
license = { file = "LICENSE" }
authors = [ { name = "Vladimir I. Iglovikov" } ]
requires-python = ">=3.9"

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.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"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" ]

[tool.setuptools]
packages = { find = { include = [
"albucore*",
], exclude = [
"tests",
"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.
Expand Down Expand Up @@ -36,6 +75,7 @@ exclude = [
".vscode",
"__pypackages__",
"_build",
"benchmark",
"buck-out",
"build",
"dist",
Expand All @@ -56,31 +96,38 @@ format.line-ending = "auto"
format.skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
lint.select = [ "ALL" ]
# Like Black, use double quotes for strings.
lint.ignore = [
"ANN101",
"ANN102",
"ANN204",
"ANN401",
"B023",
"BLE001",
"C901",
"COM812",
"ARG001",
"ARG002",
"B008",
"B027",
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
"E402",
"D205",
"D415",
"EM101",
"EM102",
"F403",
"FBT001",
"FBT002",
"PD901",
"PERF203",
"FBT003",
"G004",
"PLR0913",
"T201",
"PTH123",
"S311",
"TCH001",
"TCH002",
"TCH003",
"TRY003",
]

Expand All @@ -91,10 +138,11 @@ lint.fixable = [ "ALL" ]
lint.unfixable = [ ]
# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Like Black, use double quotes for strings.
lint.pydocstyle.convention = "google"

[tool.mypy]
python_version = "3.8"
python_version = "3.9"
ignore_missing_imports = true
follow_imports = "silent"
warn_redundant_casts = true
Expand Down
79 changes: 21 additions & 58 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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",
"numpy>=1.24.4",
"typing-extensions>=4.9.0; python_version<'3.10'",
"stringzilla==3.10.4"
"stringzilla==3.10.4",

]

MIN_OPENCV_VERSION = "4.9.0.80"
Expand All @@ -20,73 +21,35 @@
),
]

def get_version() -> str:
current_dir = Path(__file__).parent
version_file = current_dir / "albucore" / "__init__.py"
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__), 'albucore', '__init__.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:
try:
# Extract the package name from the requirement string
package_name = re.split(r"[!<>=]", main)[0]
# Check if the package is already installed
get_distribution(package_name)
return main
name = re.split(r"[!<>=]", main)[0]
get_distribution(name)
chosen = main
break
except DistributionNotFound:
continue
return secondary

pass
return chosen

def get_install_requirements(install_requires: List[str], choose_install_requires: List[Tuple[Tuple[str, ...], str]]) -> List[str]:
for mains, secondary in choose_install_requires:
install_requires.append(choose_requirement(mains, secondary))
return install_requires

setup(
name="albucore",
version=get_version(),
description='A high-performance image processing library designed to optimize and extend the Albumentations library with specialized functions for advanced image transformations. Perfect for developers working in computer vision who require efficient and scalable image augmentation.',
long_description=get_long_description(),
long_description_content_type="text/markdown",
author="Vladimir I. Iglovikov",
license="MIT",
url="https://github.com/albumentations-team/albucore",
packages=find_packages(exclude=["tests", "benchmark", ".github"]),
python_requires=">=3.8",
packages=find_packages(exclude=["tests", "benchmark"], include=['albucore*']),
install_requires=get_install_requirements(INSTALL_REQUIRES, CHOOSE_INSTALL_REQUIRES),
classifiers=[
"Development Status :: 4 - Beta",
"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.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Processing",
"Typing :: Typed"
],
keywords=[
"Image Processing", "Computer Vision", "Image Augmentation", "Albumentations", "Optimization", "Machine Learning",
"Deep Learning", "Python Imaging", "Data Augmentation", "Performance", "Efficiency", "High-Performance",
"CV", "OpenCV", "Automation"
],
zip_safe=False
)

0 comments on commit 78da3ab

Please sign in to comment.