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

Updated upload to PyPi CI/CD #1597

Merged
merged 2 commits into from
Mar 18, 2024
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/upload_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
90 changes: 47 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
import os
import re
from pathlib import Path
from typing import List, Tuple

from pkg_resources import DistributionNotFound, get_distribution
from setuptools import find_packages, setup

INSTALL_REQUIRES = ["numpy>=1.24.4", "scipy>=1.10.0", "scikit-image>=0.21.0", "PyYAML", "typing-extensions>=4.9.0", "scikit-learn>=1.3.2"]
INSTALL_REQUIRES = [
"numpy>=1.24.4", "scipy>=1.10.0", "scikit-image>=0.21.0",
"PyYAML", "typing-extensions>=4.9.0", "scikit-learn>=1.3.2"
]

# If none of packages in first installed, install second package
CHOOSE_INSTALL_REQUIRES = [
(
("opencv-python>=4.9.0", "opencv-contrib-python>=4.9.0", "opencv-contrib-python-headless>=4.9.0"),
"opencv-python-headless>=4.9.0",
)
),
]


def get_version():
current_dir = os.path.abspath(os.path.dirname(__file__))
version_file = os.path.join(current_dir, "albumentations", "__init__.py")
def get_version() -> str:
current_dir = Path(__file__).parent
version_file = current_dir / "albumentations" / "__init__.py"
with open(version_file, encoding="utf-8") as f:
return re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', f.read(), re.M).group(1)


def get_long_description():
base_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(base_dir, "README.md"), encoding="utf-8") as f:
version_match = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', f.read(), re.M)
if version_match:
return version_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, secondary):
"""If some version of main requirement installed, return main,
else return secondary.

"""
def choose_requirement(mains: Tuple[str, ...], secondary: str) -> str:
chosen = secondary
for main in mains:
try:
Expand All @@ -42,43 +41,48 @@ def choose_requirement(mains, secondary):
break
except DistributionNotFound:
pass
return chosen

return str(chosen)


def get_install_requirements(install_requires, choose_install_requires):
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="albumentations",
version=get_version(),
description="Fast image augmentation library and easy to use wrapper around other libraries",
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://github.com/albumentations-team/albumentations",
packages=find_packages(exclude=["tests"]),
url="https://albumentations.ai",
packages=find_packages(exclude=["tests", "tools", "benchmark", ".github"]),
python_requires=">=3.8",
install_requires=get_install_requirements(INSTALL_REQUIRES, CHOOSE_INSTALL_REQUIRES),
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"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",
"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"
],
)
Loading