From 9360500d029d6a3190cf1d713989f78105ee8749 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 7 Apr 2023 11:21:59 -0700 Subject: [PATCH 1/7] Replace setup.py with pyproject.toml Signed-off-by: Mattt Zmuda --- pyproject.toml | 18 ++++++++++++++++++ setup.py | 27 --------------------------- 2 files changed, 18 insertions(+), 27 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..092e74e9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "replicate" +dynamic = ["version"] +description = "Python client for Replicate" +readme = "README.md" +license = { file = "LICENSE" } +authors = [{ name = "Replicate, Inc." }] +requires-python = ">=3.6" +dependencies = ["requests>2", "pydantic>1", "packaging"] +optional-dependencies = { dev = ["black", "pydantic", "pytest"] } + +[project.urls] +homepage = "https://replicate.com" +repository = "https://github.com/replicate/replicate-python" diff --git a/setup.py b/setup.py deleted file mode 100644 index 98794594..00000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -# !/usr/bin/env python - -from pathlib import Path - -from setuptools import setup - -this_directory = Path(__file__).parent -long_description = (this_directory / "README.md").read_text() - -# setup.py cannot safely import files, so read and exec to get the version -__version__ = None -exec(open("replicate/__about__.py").read()) - -setup( - name="replicate", - packages=["replicate"], - version=__version__, - description="Python client for Replicate", - long_description=long_description, - long_description_content_type="text/markdown", - author="Replicate, Inc.", - license="BSD", - url="https://github.com/replicate/replicate-python", - python_requires=">=3.8", - install_requires=["requests", "pydantic", "packaging"], - classifiers=[], -) From 94e6f64f6b4a12140631e07329f9da9b7aec849a Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 7 Apr 2023 15:15:59 -0700 Subject: [PATCH 2/7] Set requires-python >= 3.8 Signed-off-by: Mattt Zmuda --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 092e74e9..fa0cc00a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ description = "Python client for Replicate" readme = "README.md" license = { file = "LICENSE" } authors = [{ name = "Replicate, Inc." }] -requires-python = ">=3.6" +requires-python = ">=3.8" dependencies = ["requests>2", "pydantic>1", "packaging"] optional-dependencies = { dev = ["black", "pydantic", "pytest"] } From 546b3f07182c2129063e316ae7f70195a6bcfe04 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 7 Apr 2023 11:22:45 -0700 Subject: [PATCH 3/7] Generate requirements files from pyproject.toml using pip-tools Signed-off-by: Mattt Zmuda --- requirements-dev.txt | 46 +++++++++++++++++++++++++++++++++++++++++--- requirements.txt | 22 +++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 requirements.txt diff --git a/requirements-dev.txt b/requirements-dev.txt index b3d9b4fa..e1e2c658 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,43 @@ -packaging==21.3 -pytest==7.1.2 -responses==0.21.0 +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml +# +attrs==22.2.0 + # via pytest +black==23.3.0 + # via replicate (pyproject.toml) +certifi==2022.12.7 + # via requests +charset-normalizer==3.1.0 + # via requests +click==8.1.3 + # via black +idna==3.4 + # via requests +iniconfig==2.0.0 + # via pytest +mypy-extensions==1.0.0 + # via black +packaging==23.0 + # via + # black + # pytest + # replicate (pyproject.toml) +pathspec==0.11.1 + # via black +platformdirs==3.2.0 + # via black +pluggy==1.0.0 + # via pytest +pydantic==1.10.7 + # via replicate (pyproject.toml) +pytest==7.2.2 + # via replicate (pyproject.toml) +requests==2.28.2 + # via replicate (pyproject.toml) +typing-extensions==4.5.0 + # via pydantic +urllib3==1.26.15 + # via requests diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..fad6e32b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,22 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile --output-file=requirements.txt pyproject.toml +# +certifi==2022.12.7 + # via requests +charset-normalizer==3.1.0 + # via requests +idna==3.4 + # via requests +packaging==23.0 + # via replicate (pyproject.toml) +pydantic==1.10.7 + # via replicate (pyproject.toml) +requests==2.28.2 + # via replicate (pyproject.toml) +typing-extensions==4.5.0 + # via pydantic +urllib3==1.26.15 + # via requests From f743e219451a8a236b878a47aac641022d911de9 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 7 Apr 2023 11:23:35 -0700 Subject: [PATCH 4/7] Replace pytest.ini with pyproject.toml entry Signed-off-by: Mattt Zmuda --- pyproject.toml | 3 +++ pytest.ini | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 pytest.ini diff --git a/pyproject.toml b/pyproject.toml index fa0cc00a..6fc3e915 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,3 +16,6 @@ optional-dependencies = { dev = ["black", "pydantic", "pytest"] } [project.urls] homepage = "https://replicate.com" repository = "https://github.com/replicate/replicate-python" + +[tool.pytest.ini_options] +testpaths = "tests/" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 39baf331..00000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -testpaths = tests/ From 90f46295f997dd5af8cb984ec77061f0f81bd31f Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 7 Apr 2023 11:40:33 -0700 Subject: [PATCH 5/7] Define canonical version in pyproject.toml Set __version__ dynamically Signed-off-by: Mattt Zmuda --- pyproject.toml | 2 +- replicate/__about__.py | 4 +++- replicate/__init__.py | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6fc3e915..37884eb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "replicate" -dynamic = ["version"] +version = "0.7.0" description = "Python client for Replicate" readme = "README.md" license = { file = "LICENSE" } diff --git a/replicate/__about__.py b/replicate/__about__.py index 49e0fc1e..5f3c0243 100644 --- a/replicate/__about__.py +++ b/replicate/__about__.py @@ -1 +1,3 @@ -__version__ = "0.7.0" +from importlib.metadata import version + +__version__ = version(__package__) diff --git a/replicate/__init__.py b/replicate/__init__.py index 64f6aff6..0d35ad3b 100644 --- a/replicate/__init__.py +++ b/replicate/__init__.py @@ -1,4 +1,3 @@ -from .__about__ import __version__ from .client import Client default_client = Client() From bbfa7b2d89832f55ed098113061d5d9b7020b2dd Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 7 Apr 2023 14:25:51 -0700 Subject: [PATCH 6/7] Update CI workflow Signed-off-by: Mattt Zmuda --- .github/workflows/ci.yaml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c709a42c..77e78619 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,23 +16,16 @@ jobs: run: shell: bash steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: pip-${{ hashFiles('**/requirements-dev.txt') }} - restore-keys: | - pip-${{ secrets.CACHE_VERSION }}- - - name: Install development dependencies - run: pip install -r requirements-dev.txt - - name: Install package & dependencies - run: pip install . + cache: "pip" + - name: Install dependencies + run: python -m pip install -r requirements.txt -r requirements-dev.txt . - name: Test - run: pytest + run: python -m pytest release: name: "Release" From 6d0d0cf87de91e68fdd41e8c7c03f749fb6560ec Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 7 Apr 2023 14:44:10 -0700 Subject: [PATCH 7/7] Update dev dependencies Signed-off-by: Mattt Zmuda --- pyproject.toml | 4 ++-- requirements-dev.txt | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 37884eb7..3376263a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,8 @@ readme = "README.md" license = { file = "LICENSE" } authors = [{ name = "Replicate, Inc." }] requires-python = ">=3.8" -dependencies = ["requests>2", "pydantic>1", "packaging"] -optional-dependencies = { dev = ["black", "pydantic", "pytest"] } +dependencies = ["packaging", "pydantic>1", "requests>2"] +optional-dependencies = { dev = ["black", "pytest", "responses"] } [project.urls] homepage = "https://replicate.com" diff --git a/requirements-dev.txt b/requirements-dev.txt index e1e2c658..f10b82a5 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -35,9 +35,19 @@ pydantic==1.10.7 # via replicate (pyproject.toml) pytest==7.2.2 # via replicate (pyproject.toml) +pyyaml==6.0 + # via responses requests==2.28.2 + # via + # replicate (pyproject.toml) + # responses +responses==0.23.1 # via replicate (pyproject.toml) +types-pyyaml==6.0.12.9 + # via responses typing-extensions==4.5.0 # via pydantic urllib3==1.26.15 - # via requests + # via + # requests + # responses