using pyproject.toml over setup.py to manage the package information

This commit is contained in:
kelvin 2024-05-03 11:49:03 +08:00
parent a1d071733d
commit 805363d928
8 changed files with 53 additions and 33 deletions

View File

@ -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

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ __pycache__/
thumbs.db
.DS_Store
.idea
build

21
CHANGELOG.md Normal file
View File

@ -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

View File

@ -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

View File

@ -1 +1,3 @@
from .clip import *
__version__ = "1.1.dev"

26
pyproject.toml Normal file
View File

@ -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"]

View File

@ -1,5 +0,0 @@
ftfy
regex
tqdm
torch
torchvision

View File

@ -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']},
)