From 04c7457e81a068bbb8af70f13e245a0dd2e47450 Mon Sep 17 00:00:00 2001 From: Chris Guidry Date: Fri, 2 Aug 2024 10:34:32 -0400 Subject: [PATCH] Splits production and development requirements, makes versioning virtual (#11) --- .gitignore | 1 + Makefile | 11 +- prefect_operator/__init__.py | 4 +- prefect_operator/_version.py | 17 -- pyproject.toml | 10 +- requirements-dev.in | 9 + requirements-dev.txt | 264 +++++++++++++++++++++++++++ requirements.in | 13 +- requirements.txt | 338 ++--------------------------------- sync-pre-commit | 2 +- tests/test_version.py | 9 + 11 files changed, 319 insertions(+), 359 deletions(-) delete mode 100644 prefect_operator/_version.py create mode 100644 requirements-dev.in create mode 100644 requirements-dev.txt create mode 100644 tests/test_version.py diff --git a/.gitignore b/.gitignore index 5729aad..f62afda 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__ .pytest_cache .python-version .vscode +.ruff_cache diff --git a/Makefile b/Makefile index 55b8bbc..ec80b29 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,9 @@ endif mv .bookkeeping/uv.next .bookkeeping/uv -.bookkeeping/development.txt: .bookkeeping/uv requirements.txt pyproject.toml +.bookkeeping/development.txt: .bookkeeping/uv requirements-dev.txt pyproject.toml mkdir -p .bookkeeping - cat requirements.txt > .bookkeeping/development.txt.next + cat requirements-dev.txt > .bookkeeping/development.txt.next uv pip sync .bookkeeping/development.txt.next @@ -24,8 +24,11 @@ endif mv .bookkeeping/development.txt.next .bookkeeping/development.txt -%.txt: %.in .bookkeeping/uv - uv pip compile --resolver=backtracking --upgrade --output-file $@ $< +requirements.txt: requirements.in .bookkeeping/uv + uv pip compile requirements.in --output-file $@ + +requirements-dev.txt: requirements.txt requirements-dev.in .bookkeeping/uv + uv pip compile requirements.txt requirements-dev.in --output-file $@ .git/hooks/pre-commit: .bookkeeping/development.txt pre-commit install diff --git a/prefect_operator/__init__.py b/prefect_operator/__init__.py index 24477f7..eb01ee4 100644 --- a/prefect_operator/__init__.py +++ b/prefect_operator/__init__.py @@ -1,3 +1,5 @@ -from prefect_operator._version import __version__ # noqa: F401 +from setuptools_scm import get_version + +__version__ = get_version() DEFAULT_PREFECT_VERSION = "3.0.0rc13" diff --git a/prefect_operator/_version.py b/prefect_operator/_version.py deleted file mode 100644 index f79f470..0000000 --- a/prefect_operator/_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# file generated by setuptools_scm -# don't change, don't track in version control -TYPE_CHECKING = False -if TYPE_CHECKING: - from typing import Tuple, Union - - VERSION_TUPLE = Tuple[Union[int, str], ...] -else: - VERSION_TUPLE = object - -version: str -__version__: str -__version_tuple__: VERSION_TUPLE -version_tuple: VERSION_TUPLE - -__version__ = version = "0.1.dev8+gdaee741.d20240801" -__version_tuple__ = version_tuple = (0, 1, "dev8", "gdaee741.d20240801") diff --git a/pyproject.toml b/pyproject.toml index 392c476..04ac076 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,12 @@ requires-python = ">=3.11" dynamic = ["version"] -[tool.setuptools_scm] -version_file = "prefect_operator/_version.py" - [project.scripts] prefect-operator = "prefect_operator.__main__:main" + +[tool.pytest.ini_options] +minversion = "8.3" +addopts = "--cov prefect_operator --cov tests --cov-branch --cov-report=term-missing" +testpaths = [ + "tests" +] diff --git a/requirements-dev.in b/requirements-dev.in new file mode 100644 index 0000000..6d6fe0e --- /dev/null +++ b/requirements-dev.in @@ -0,0 +1,9 @@ +ipython +mypy +pre-commit +pytest +pytest-coverage +ruff +types-pyyaml +yamlfix +uv diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..03db563 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,264 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.txt requirements-dev.in --output-file requirements-dev.txt +-e . + # via -r requirements.txt +aiohappyeyeballs==2.3.4 + # via + # -r requirements.txt + # aiohttp +aiohttp==3.10.0 + # via + # -r requirements.txt + # kopf +aiosignal==1.3.1 + # via + # -r requirements.txt + # aiohttp +annotated-types==0.7.0 + # via + # -r requirements.txt + # pydantic +anyio==4.4.0 + # via + # -r requirements.txt + # httpx +asttokens==2.4.1 + # via stack-data +attrs==23.2.0 + # via + # -r requirements.txt + # aiohttp +cachetools==5.4.0 + # via + # -r requirements.txt + # google-auth +certifi==2024.7.4 + # via + # -r requirements.txt + # httpcore + # httpx + # kubernetes + # requests +cfgv==3.4.0 + # via pre-commit +charset-normalizer==3.3.2 + # via + # -r requirements.txt + # requests +click==8.1.7 + # via + # -r requirements.txt + # kopf + # maison + # yamlfix +coverage==7.6.0 + # via pytest-cov +decorator==5.1.1 + # via ipython +distlib==0.3.8 + # via virtualenv +distro==1.9.0 + # via ruyaml +executing==2.0.1 + # via stack-data +filelock==3.15.4 + # via virtualenv +frozenlist==1.4.1 + # via + # -r requirements.txt + # aiohttp + # aiosignal +google-auth==2.32.0 + # via + # -r requirements.txt + # kubernetes +h11==0.14.0 + # via + # -r requirements.txt + # httpcore +httpcore==1.0.5 + # via + # -r requirements.txt + # httpx +httpx==0.27.0 + # via -r requirements.txt +identify==2.6.0 + # via pre-commit +idna==3.7 + # via + # -r requirements.txt + # anyio + # httpx + # requests + # yarl +iniconfig==2.0.0 + # via pytest +ipython==8.26.0 + # via -r requirements-dev.in +iso8601==2.1.0 + # via + # -r requirements.txt + # kopf +jedi==0.19.1 + # via ipython +kopf==1.37.2 + # via -r requirements.txt +kubernetes==30.1.0 + # via -r requirements.txt +maison==1.4.3 + # via yamlfix +matplotlib-inline==0.1.7 + # via ipython +multidict==6.0.5 + # via + # -r requirements.txt + # aiohttp + # yarl +mypy==1.11.1 + # via -r requirements-dev.in +mypy-extensions==1.0.0 + # via mypy +nodeenv==1.9.1 + # via pre-commit +oauthlib==3.2.2 + # via + # -r requirements.txt + # kubernetes + # requests-oauthlib +packaging==24.1 + # via + # -r requirements.txt + # pytest + # setuptools-scm +parso==0.8.4 + # via jedi +pexpect==4.9.0 + # via ipython +platformdirs==4.2.2 + # via virtualenv +pluggy==1.5.0 + # via pytest +pre-commit==3.8.0 + # via -r requirements-dev.in +prompt-toolkit==3.0.47 + # via ipython +ptyprocess==0.7.0 + # via pexpect +pure-eval==0.2.3 + # via stack-data +pyasn1==0.6.0 + # via + # -r requirements.txt + # pyasn1-modules + # rsa +pyasn1-modules==0.4.0 + # via + # -r requirements.txt + # google-auth +pydantic==2.8.2 + # via + # -r requirements.txt + # maison +pydantic-core==2.20.1 + # via + # -r requirements.txt + # pydantic +pygments==2.18.0 + # via ipython +pytest==8.3.2 + # via + # -r requirements-dev.in + # pytest-cov +pytest-cov==5.0.0 + # via pytest-cover +pytest-cover==3.0.0 + # via pytest-coverage +pytest-coverage==0.0 + # via -r requirements-dev.in +python-dateutil==2.9.0.post0 + # via + # -r requirements.txt + # kubernetes +python-json-logger==2.0.7 + # via + # -r requirements.txt + # kopf +pyyaml==6.0.1 + # via + # -r requirements.txt + # kopf + # kubernetes + # pre-commit +requests==2.32.3 + # via + # -r requirements.txt + # kubernetes + # requests-oauthlib +requests-oauthlib==2.0.0 + # via + # -r requirements.txt + # kubernetes +rsa==4.9 + # via + # -r requirements.txt + # google-auth +ruff==0.5.5 + # via -r requirements-dev.in +ruyaml==0.91.0 + # via yamlfix +setuptools==72.1.0 + # via + # -r requirements.txt + # ruyaml + # setuptools-scm +setuptools-scm==8.1.0 + # via -r requirements.txt +six==1.16.0 + # via + # -r requirements.txt + # asttokens + # kubernetes + # python-dateutil +sniffio==1.3.1 + # via + # -r requirements.txt + # anyio + # httpx +stack-data==0.6.3 + # via ipython +toml==0.10.2 + # via maison +traitlets==5.14.3 + # via + # ipython + # matplotlib-inline +types-pyyaml==6.0.12.20240724 + # via -r requirements-dev.in +typing-extensions==4.12.2 + # via + # -r requirements.txt + # kopf + # mypy + # pydantic + # pydantic-core +urllib3==2.2.2 + # via + # -r requirements.txt + # kubernetes + # requests +uv==0.2.33 + # via -r requirements-dev.in +virtualenv==20.26.3 + # via pre-commit +wcwidth==0.2.13 + # via prompt-toolkit +websocket-client==1.8.0 + # via + # -r requirements.txt + # kubernetes +yamlfix==1.16.0 + # via -r requirements-dev.in +yarl==1.9.4 + # via + # -r requirements.txt + # aiohttp diff --git a/requirements.in b/requirements.in index 488e57f..cd68c75 100644 --- a/requirements.in +++ b/requirements.in @@ -1,17 +1,8 @@ +httpx kopf kubernetes -prefect==3.0.0rc13 pydantic pyyaml +setuptools_scm -e . - -# development -ipython -mypy -pre-commit -pytest -ruff -types-pyyaml -yamlfix -uv diff --git a/requirements.txt b/requirements.txt index df7d29f..dca1c6b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# uv pip compile --resolver=backtracking --output-file requirements.txt requirements.in +# uv pip compile requirements.in --output-file requirements.txt -e . # via -r requirements.in aiohappyeyeballs==2.3.4 @@ -8,413 +8,107 @@ aiohttp==3.10.0 # via kopf aiosignal==1.3.1 # via aiohttp -aiosqlite==0.20.0 - # via prefect -alembic==1.13.2 - # via prefect annotated-types==0.7.0 # via pydantic anyio==4.4.0 - # via - # httpx - # prefect - # starlette - # watchfiles -apprise==1.8.1 - # via prefect -asgi-lifespan==2.1.0 - # via prefect -asttokens==2.4.1 - # via stack-data -asyncpg==0.29.0 - # via prefect + # via httpx attrs==23.2.0 - # via - # aiohttp - # jsonschema - # referencing + # via aiohttp cachetools==5.4.0 - # via - # google-auth - # prefect + # via google-auth certifi==2024.7.4 # via - # apprise # httpcore # httpx # kubernetes # requests -cffi==1.16.0 - # via cryptography -cfgv==3.4.0 - # via pre-commit charset-normalizer==3.3.2 # via requests click==8.1.7 - # via - # apprise - # kopf - # maison - # prefect - # typer - # uvicorn - # yamlfix -cloudpickle==3.0.0 - # via prefect -colorama==0.4.6 - # via griffe -coolname==2.2.0 - # via prefect -croniter==3.0.3 - # via prefect -cryptography==43.0.0 - # via prefect -dateparser==1.2.0 - # via prefect -decorator==5.1.1 - # via ipython -distlib==0.3.8 - # via virtualenv -distro==1.9.0 - # via ruyaml -dnspython==2.6.1 - # via email-validator -docker==7.1.0 - # via prefect -email-validator==2.2.0 - # via fastapi -exceptiongroup==1.2.2 - # via prefect -executing==2.0.1 - # via stack-data -fastapi==0.111.1 - # via prefect -fastapi-cli==0.0.4 - # via fastapi -filelock==3.15.4 - # via virtualenv + # via kopf frozenlist==1.4.1 # via # aiohttp # aiosignal -fsspec==2024.6.1 - # via prefect google-auth==2.32.0 # via kubernetes -graphviz==0.20.3 - # via prefect -greenlet==3.0.3 - # via sqlalchemy -griffe==0.47.0 - # via prefect h11==0.14.0 - # via - # httpcore - # uvicorn -h2==4.1.0 - # via httpx -hpack==4.0.0 - # via h2 + # via httpcore httpcore==1.0.5 - # via - # httpx - # prefect -httptools==0.6.1 - # via uvicorn + # via httpx httpx==0.27.0 - # via - # fastapi - # prefect -humanize==4.10.0 - # via - # jinja2-humanize-extension - # prefect -hyperframe==6.0.1 - # via h2 -identify==2.6.0 - # via pre-commit + # via -r requirements.in idna==3.7 # via # anyio - # email-validator # httpx # requests # yarl -importlib-resources==6.1.3 - # via prefect -iniconfig==2.0.0 - # via pytest -ipython==8.26.0 - # via -r requirements.in iso8601==2.1.0 # via kopf -jedi==0.19.1 - # via ipython -jinja2==3.1.4 - # via - # fastapi - # jinja2-humanize-extension - # prefect -jinja2-humanize-extension==0.4.0 - # via prefect -jsonpatch==1.33 - # via prefect -jsonpointer==3.0.0 - # via jsonpatch -jsonschema==4.23.0 - # via prefect -jsonschema-specifications==2023.12.1 - # via jsonschema kopf==1.37.2 # via -r requirements.in kubernetes==30.1.0 # via -r requirements.in -maison==1.4.3 - # via yamlfix -mako==1.3.5 - # via alembic -markdown==3.6 - # via apprise -markdown-it-py==3.0.0 - # via rich -markupsafe==2.1.5 - # via - # jinja2 - # mako -matplotlib-inline==0.1.7 - # via ipython -mdurl==0.1.2 - # via markdown-it-py multidict==6.0.5 # via # aiohttp # yarl -mypy==1.11.1 - # via -r requirements.in -mypy-extensions==1.0.0 - # via mypy -nodeenv==1.9.1 - # via pre-commit oauthlib==3.2.2 # via # kubernetes # requests-oauthlib -orjson==3.10.6 - # via prefect packaging==24.1 - # via - # prefect - # pytest -parso==0.8.4 - # via jedi -pathspec==0.12.1 - # via prefect -pendulum==3.0.0 - # via prefect -pexpect==4.9.0 - # via ipython -platformdirs==4.2.2 - # via virtualenv -pluggy==1.5.0 - # via pytest -pre-commit==3.8.0 - # via -r requirements.in -prefect==3.0.0rc13 - # via -r requirements.in -prompt-toolkit==3.0.47 - # via ipython -ptyprocess==0.7.0 - # via pexpect -pure-eval==0.2.3 - # via stack-data + # via setuptools-scm pyasn1==0.6.0 # via # pyasn1-modules # rsa pyasn1-modules==0.4.0 # via google-auth -pycparser==2.22 - # via cffi pydantic==2.8.2 - # via - # -r requirements.in - # fastapi - # maison - # prefect - # pydantic-extra-types - # pydantic-settings -pydantic-core==2.20.1 - # via - # prefect - # pydantic -pydantic-extra-types==2.9.0 - # via prefect -pydantic-settings==2.4.0 - # via prefect -pygments==2.18.0 - # via - # ipython - # rich -pytest==8.3.2 # via -r requirements.in +pydantic-core==2.20.1 + # via pydantic python-dateutil==2.9.0.post0 - # via - # croniter - # dateparser - # kubernetes - # pendulum - # prefect - # time-machine -python-dotenv==1.0.1 - # via - # pydantic-settings - # uvicorn + # via kubernetes python-json-logger==2.0.7 # via kopf -python-multipart==0.0.9 - # via fastapi -python-slugify==8.0.4 - # via prefect -pytz==2024.1 - # via - # croniter - # dateparser - # prefect pyyaml==6.0.1 # via # -r requirements.in - # apprise # kopf # kubernetes - # pre-commit - # prefect - # uvicorn -readchar==4.1.0 - # via prefect -referencing==0.35.1 - # via - # jsonschema - # jsonschema-specifications -regex==2024.7.24 - # via dateparser requests==2.32.3 # via - # apprise - # docker # kubernetes # requests-oauthlib requests-oauthlib==2.0.0 - # via - # apprise - # kubernetes -rfc3339-validator==0.1.4 - # via prefect -rich==13.7.1 - # via - # prefect - # typer -rpds-py==0.19.1 - # via - # jsonschema - # referencing + # via kubernetes rsa==4.9 # via google-auth -ruamel-yaml==0.18.6 - # via prefect -ruamel-yaml-clib==0.2.8 - # via ruamel-yaml -ruff==0.5.5 - # via -r requirements.in -ruyaml==0.91.0 - # via yamlfix setuptools==72.1.0 - # via ruyaml -shellingham==1.5.4 - # via typer + # via setuptools-scm +setuptools-scm==8.1.0 + # via -r requirements.in six==1.16.0 # via - # asttokens # kubernetes # python-dateutil - # rfc3339-validator sniffio==1.3.1 # via # anyio - # asgi-lifespan # httpx - # prefect -sqlalchemy==2.0.31 - # via - # alembic - # prefect -stack-data==0.6.3 - # via ipython -starlette==0.37.2 - # via fastapi -text-unidecode==1.3 - # via python-slugify -time-machine==2.14.2 - # via pendulum -toml==0.10.2 - # via - # maison - # prefect -traitlets==5.14.3 - # via - # ipython - # matplotlib-inline -typer==0.12.3 - # via - # fastapi-cli - # prefect -types-pyyaml==6.0.12.20240724 - # via -r requirements.in typing-extensions==4.12.2 # via - # aiosqlite - # alembic - # fastapi # kopf - # mypy - # prefect # pydantic # pydantic-core - # sqlalchemy - # typer -tzdata==2024.1 - # via pendulum -tzlocal==5.2 - # via dateparser -ujson==5.10.0 - # via prefect urllib3==2.2.2 # via - # docker # kubernetes # requests -uv==0.2.32 - # via -r requirements.in -uvicorn==0.30.4 - # via - # fastapi - # prefect -uvloop==0.19.0 - # via uvicorn -virtualenv==20.26.3 - # via pre-commit -watchfiles==0.22.0 - # via uvicorn -wcwidth==0.2.13 - # via prompt-toolkit websocket-client==1.8.0 # via kubernetes -websockets==12.0 - # via - # prefect - # uvicorn -wrapt==1.16.0 - # via prefect -yamlfix==1.16.0 - # via -r requirements.in yarl==1.9.4 # via aiohttp diff --git a/sync-pre-commit b/sync-pre-commit index 5bd5107..7794786 100755 --- a/sync-pre-commit +++ b/sync-pre-commit @@ -11,7 +11,7 @@ def pinned_development_requirements() -> dict[str, str]: specifiers (values)""" pinned: dict[str, str] = {} - with open("requirements.txt", "r") as dev_requirements: + with open("requirements-dev.txt", "r") as dev_requirements: for line in dev_requirements: line = line.strip() if line.startswith("#") or line.startswith("-e"): diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..b7b9c99 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,9 @@ +from packaging.version import Version + +from prefect_operator import __version__ + + +def test_version_is_sensible(): + version = Version(__version__) + assert version.major >= 0 + assert version.minor > 0