From 5f5400b2427fbcbc3fb59c732d9f4618b8894920 Mon Sep 17 00:00:00 2001 From: spencerwooo Date: Mon, 9 Dec 2024 13:51:31 +0800 Subject: [PATCH] Prepare for pypi publish --- .github/workflows/ci.yml | 12 +++++++----- .github/workflows/pypi-publish.yml | 29 +++++++++++++++++++++++++++++ LICENSE | 2 +- README.md | 13 ++++--------- pyproject.toml | 18 +++++++++++++++++- torchattack/__init__.py | 2 +- 6 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/pypi-publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0820896..bebe92b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,12 +13,14 @@ jobs: - uses: actions/checkout@v4 - name: Install uv - uses: astral-sh/setup-uv@v3 - - - name: Set up Python - uses: actions/setup-python@v5 + uses: astral-sh/setup-uv@v4 with: - python-version-file: "pyproject.toml" + python-version: "3.12" + + # - name: Set up Python + # uses: actions/setup-python@v5 + # with: + # python-version-file: "pyproject.toml" - name: Install the project run: uv sync --all-extras --dev diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 0000000..14577d8 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,29 @@ +name: pypi-publish + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + # - name: Set up Python + # uses: actions/setup-python@v5 + # with: + # python-version-file: "pyproject.toml" + + - name: Install the project with build deps + run: uv sync + + - name: Build package + run: uv build + + - name: Publish package + run: uv publish diff --git a/LICENSE b/LICENSE index 797ad77..e29b85d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Daisy Lab +Copyright (c) 2023 Spencer Woo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2d2d353..13ecb13 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ Code style: black + + pypi + lint @@ -19,16 +22,8 @@ 🛡 **torchattack** - A curated list of adversarial attacks in PyTorch, with a focus on transferable black-box attacks. -INSTALL FROM GITHUB SOURCE - -```shell -python -m pip install git+https://github.com/spencerwooo/torchattack@v1.0.5 -``` - -INSTALL FROM GITEE MIRROR - ```shell -python -m pip install git+https://gitee.com/spencerwoo/torchattack@v1.0.5 +pip install torchattack ``` ## Usage diff --git a/pyproject.toml b/pyproject.toml index 9a694ed..0cea060 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,19 @@ description = "A set of adversarial attacks implemented in PyTorch" authors = [{ name = "spencerwooo", email = "spencer.woo@outlook.com" }] requires-python = ">=3.10,<3.13" readme = "README.md" -license = { text = "MIT" } +license = { file = "LICENSE" } +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: GPU :: NVIDIA CUDA", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Software Development :: Libraries :: Python Modules", +] dependencies = [ "torch>=1.13.0", "torchvision>=0.14.0", @@ -13,6 +25,10 @@ dependencies = [ ] dynamic = ["version"] +[project.urls] +Repository = "https://github.com/spencerwooo/torchattack" +Documentation = "https://github.com/spencerwooo/torchattack/blob/main/README.md" + [project.optional-dependencies] dev = ["mypy", "rich", "timm"] test = ["pytest", "pytest-cov"] diff --git a/torchattack/__init__.py b/torchattack/__init__.py index c45b190..549c710 100644 --- a/torchattack/__init__.py +++ b/torchattack/__init__.py @@ -27,7 +27,7 @@ from torchattack.vmifgsm import VMIFGSM from torchattack.vnifgsm import VNIFGSM -__version__ = '1.0.5' +__version__ = '1.1.0' __all__ = [ # Helper function to create an attack by its name