From 805363d9283a36655172dcf5bb2018b87ef09c36 Mon Sep 17 00:00:00 2001 From: kelvin Date: Fri, 3 May 2024 11:49:03 +0800 Subject: [PATCH] using pyproject.toml over setup.py to manage the package information --- .github/workflows/test.yml | 3 +-- .gitignore | 2 ++ CHANGELOG.md | 21 +++++++++++++++++++++ README.md | 6 +----- clip/__init__.py | 2 ++ pyproject.toml | 26 ++++++++++++++++++++++++++ requirements.txt | 5 ----- setup.py | 21 --------------------- 8 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 570a54198..d1e73e528 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,5 @@ jobs: - run: conda install -n test python=${{ matrix.python-version }} pytorch=${{ matrix.pytorch-version }} torchvision=${{ matrix.torchvision-version }} cpuonly -c pytorch - uses: actions/checkout@v2 - run: echo "$CONDA/envs/test/bin" >> $GITHUB_PATH - - run: pip install pytest - - run: pip install . + - run: pip install .[dev] - run: pytest diff --git a/.gitignore b/.gitignore index 321f181f9..28aa647c1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ __pycache__/ thumbs.db .DS_Store .idea + +build diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..1f5469435 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- pyproject.toml + +### Changed + +- Start using "pyproject.toml" over "setup.py" to manage the package information. + +### Removed + +- requirements.txt +- setup.py diff --git a/README.md b/README.md index db56b56e2..67febc188 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,12 @@ CLIP (Contrastive Language-Image Pre-Training) is a neural network trained on a ## Usage -First, [install PyTorch 1.7.1](https://pytorch.org/get-started/locally/) (or later) and torchvision, as well as small additional dependencies, and then install this repo as a Python package. On a CUDA GPU machine, the following will do the trick: +First, install this repo as a Python package ```bash -$ conda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.0 -$ pip install ftfy regex tqdm $ pip install git+https://github.com/openai/CLIP.git ``` -Replace `cudatoolkit=11.0` above with the appropriate CUDA version on your machine or `cpuonly` when installing on a machine without a GPU. - ```python import torch import clip diff --git a/clip/__init__.py b/clip/__init__.py index dcc561953..76d7f9fcf 100644 --- a/clip/__init__.py +++ b/clip/__init__.py @@ -1 +1,3 @@ from .clip import * + +__version__ = "1.1.dev" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..82a35bee0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "clip" +dynamic = ["version", "readme"] +authors = [{name = "OpenAI"}] +requires-python = ">=3.8" +dependencies = [ + "ftfy", + "regex", + "tqdm", + "torch>=1.7.1", + "torchvision", +] + +[project.optional-dependencies] +dev = ["pytest"] + +[tool.setuptools.dynamic] +version = {attr = "clip.__version__"} +readme = {file = ["README.md"]} + +[tool.setuptools.packages.find] +exclude = ["tests"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 6b98c33f3..000000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -ftfy -regex -tqdm -torch -torchvision diff --git a/setup.py b/setup.py deleted file mode 100644 index c9ea7d0d2..000000000 --- a/setup.py +++ /dev/null @@ -1,21 +0,0 @@ -import os - -import pkg_resources -from setuptools import setup, find_packages - -setup( - name="clip", - py_modules=["clip"], - version="1.0", - description="", - author="OpenAI", - packages=find_packages(exclude=["tests*"]), - install_requires=[ - str(r) - for r in pkg_resources.parse_requirements( - open(os.path.join(os.path.dirname(__file__), "requirements.txt")) - ) - ], - include_package_data=True, - extras_require={'dev': ['pytest']}, -)