diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 3bfabfc..734546a 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -18,9 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index fe54d29..dab7019 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -18,18 +18,17 @@ jobs: python-version: [3.8, 3.9] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest - python -m pip install wheel python -m pip install torch==2.4.0 torchvision==0.19.0 --index-url https://download.pytorch.org/whl/cpu - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install -e . + python -m pip install pytest - name: Test with pytest run: | - python setup.py test + pytest -q diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..58336e8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,63 @@ +[build-system] +requires = ["setuptools>=61", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "vit-pytorch" +version = "1.12.4" +description = "Vision Transformer (ViT) - Pytorch" +readme = { file = "README.md", content-type = "text/markdown" } +license = { file = "LICENSE" } +authors = [ + { name = "Phil Wang", email = "lucidrains@gmail.com" }, +] +requires-python = ">=3.8" +keywords = [ + "artificial intelligence", + "attention mechanism", + "image recognition", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "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", +] +dependencies = [ + "einops>=0.7.0", + "torch>=1.10", + "torchvision", +] + +[project.optional-dependencies] +test = [ + "pytest", + "torch==2.4.0", + "torchvision==0.19.0", +] + +[project.urls] +Homepage = "https://github.com/lucidrains/vit-pytorch" +Repository = "https://github.com/lucidrains/vit-pytorch" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +include = ["vit_pytorch*"] +exclude = ["examples*", "tests*", "test*"] + +[tool.pytest.ini_options] +testpaths = ["tests", "."] +python_files = ["test_*.py", "*_test.py"] +addopts = "-q" +filterwarnings = [ + "ignore::FutureWarning", +] diff --git a/setup.py b/setup.py deleted file mode 100644 index 7fdb521..0000000 --- a/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -from setuptools import setup, find_packages - -with open('README.md') as f: - long_description = f.read() - -setup( - name = 'vit-pytorch', - packages = find_packages(exclude=['examples']), - version = '1.12.2', - license='MIT', - description = 'Vision Transformer (ViT) - Pytorch', - long_description = long_description, - long_description_content_type = 'text/markdown', - author = 'Phil Wang', - author_email = 'lucidrains@gmail.com', - url = 'https://github.com/lucidrains/vit-pytorch', - keywords = [ - 'artificial intelligence', - 'attention mechanism', - 'image recognition' - ], - install_requires=[ - 'einops>=0.7.0', - 'torch>=1.10', - 'torchvision' - ], - setup_requires=[ - 'pytest-runner', - ], - tests_require=[ - 'pytest', - 'torch==2.4.0', - 'torchvision==0.19.0' - ], - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Topic :: Scientific/Engineering :: Artificial Intelligence', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.6', - ], -) diff --git a/tests/test.py b/tests/test.py index b0e9d77..6aa04c2 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,7 +1,7 @@ import torch from vit_pytorch import ViT -def test(): +def test_vit(): v = ViT( image_size = 256, patch_size = 32,