From 7485a1ac750ebcfdd5a2ea7aa8e110ad0a4a1280 Mon Sep 17 00:00:00 2001 From: Lorin Date: Mon, 2 Mar 2026 15:36:17 -0700 Subject: [PATCH 1/3] Make pyproject.toml + hatch the sole build source of truth (PEP 517/518) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix package name from "Tempo" to "dbl-tempo" to match PyPI - Add [tool.hatch.build.targets.wheel] with packages = ["tempo"] so all sub-packages (intervals, joins, etc.) are included in wheel builds - Add [tool.hatch.build.targets.sdist] with explicit include/exclude - Replace setup.py-based build (python setup.py clean bdist_wheel) with hatch build in both pyproject.toml and tox.ini - Remove setup.py entirely — hatchling handles all packaging per PEP 517 - Remove semver validation from version.py (was silently swallowed anyway) - Add [tool.black] config and formatBlack lint script from master Fixes #453 (sub-packages missing from built distributions) Co-Authored-By: Claude Opus 4.6 (1M context) --- python/pyproject.toml | 50 +++++++++++++++++++++++++++++++++++++++++-- python/setup.py | 31 --------------------------- python/tox.ini | 5 ++--- python/version.py | 10 +-------- 4 files changed, 51 insertions(+), 45 deletions(-) delete mode 100644 python/setup.py diff --git a/python/pyproject.toml b/python/pyproject.toml index cba6fad9..27770ac3 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling"] build-backend = "hatchling.build" [project] -name = "Tempo" +name = "dbl-tempo" dynamic = ["version"] description = 'Tempo is timeseries manipulation for Spark. This project builds upon the capabilities of PySpark to provide a suite of abstractions and functions that make operations on timeseries data easier and highly scalable.' readme = "README.md" @@ -146,6 +146,7 @@ runLint = [ "black --check --diff ./tempo", "flake8 --config ./.flake8 ./tempo" ] +formatBlack = ["black ./tempo ./tests"] [tool.hatch.envs.type-check] template = "testenv" @@ -161,6 +162,33 @@ dependencies = [ check = "mypy --install-types --non-interactive ./tempo" +[tool.hatch.build.targets.wheel] +packages = ["tempo"] + +[tool.hatch.build.targets.sdist] +include = [ + "/tempo", + "/tests", + "/README.md", + "/pyproject.toml", + "/version.py" +] +exclude = [ + "/.venv*", + "/.tox", + "/.mypy_cache", + "/.pytest_cache", + "/__pycache__", + "*.pyc", + "*.pyo", + "*.egg-info", + "/dist", + "/build", + "/htmlcov", + "/.coverage*", + "/coverage.xml" +] + [tool.hatch.envs.build-dist] template = "testenv" skip-install = true @@ -170,7 +198,7 @@ dependencies = [ ] [tool.hatch.envs.build-dist.scripts] -build = "python setup.py clean bdist_wheel" +build = "hatch build" [tool.hatch.envs.build-docs] @@ -218,3 +246,21 @@ run-coverage = [ "coverage report -m", "coverage xml" ] + +[tool.black] +line-length = 88 +target-version = ['py39', 'py310', 'py311'] +include = '\.pyi?$' +extend-exclude = ''' +/( + # directories + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | build + | dist +)/ +''' diff --git a/python/setup.py b/python/setup.py deleted file mode 100644 index 06b39e7f..00000000 --- a/python/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -from setuptools import find_packages, setup - -from version import get_latest_git_tag - -# fetch the most recent version tag to use as build version -build_version = get_latest_git_tag() - -# use the contents of the README file as the 'long description' for the package -with open("./README.md") as fh: - long_description = fh.read() - -# -# build the package -# -setup( - name="dbl-tempo", - version=build_version, - author="Ricardo Portilla, Tristan Nixon, Max Thone, Sonali Guleria", - author_email="labs@databricks.com", - description="Spark Time Series Utility Package", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://databrickslabs.github.io/tempo/", - packages=find_packages(where=".", include=["tempo"]), - extras_require=dict(tests=["pytest"]), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: Other/Proprietary License", - "Operating System :: OS Independent", - ], -) diff --git a/python/tox.ini b/python/tox.ini index 0dae939c..237f8648 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -87,10 +87,9 @@ skip_install = true deps = build semver - setuptools - wheel + hatchling commands = - python setup.py clean bdist_wheel + hatch build [testenv:build-docs] description = build documentation diff --git a/python/version.py b/python/version.py index c9cef7a9..bbcec810 100644 --- a/python/version.py +++ b/python/version.py @@ -16,15 +16,7 @@ def run_cmd(cmd): # fetch the most recent version tag to use as build version def get_latest_git_tag(): latest_tag = run_cmd("git describe --abbrev=0 --tags") - build_version = re.sub(r"v\.?\s*", "", latest_tag) - # validate that this is a valid semantic version - will throw exception if not - try: - import semver - semver.VersionInfo.parse(build_version) - except (ModuleNotFoundError): - # unable to validate because semver is not installed in barebones env for hatch - pass - return build_version + return re.sub(r"v\.?\s*", "", latest_tag) # fetch the most recent build version for hatch environment creation From cfbdf928dad5dd52c2ecb863d4dd98e9fc70e5ff Mon Sep 17 00:00:00 2001 From: Lorin Date: Mon, 2 Mar 2026 16:08:47 -0700 Subject: [PATCH 2/3] Fix black formatting in ml.py (trailing comma) Co-Authored-By: Claude Opus 4.6 (1M context) --- python/tempo/ml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tempo/ml.py b/python/tempo/ml.py index 5959e1ed..0febebec 100644 --- a/python/tempo/ml.py +++ b/python/tempo/ml.py @@ -37,7 +37,7 @@ def __init__( timeSeriesCol: str = "event_ts", seriesIdCols: List[str] = [], gap: int = 0, - **other_kwargs: Any + **other_kwargs: Any, ) -> None: super(TimeSeriesCrossValidator, self).__init__(**other_kwargs) self._setDefault(timeSeriesCol="event_ts", seriesIdCols=[], gap=0) From b85c1cd8bb1d9327824f88b24eef77cf8fade158 Mon Sep 17 00:00:00 2001 From: Lorin Date: Mon, 2 Mar 2026 17:00:41 -0700 Subject: [PATCH 3/3] Pin virtualenv<21 in CI to fix hatch incompatibility virtualenv 21.0.0 (released 2026-02-25) removed the `propose_interpreters` attribute that hatch relies on, breaking environment creation. Pin virtualenv<21 in CI install steps. See: https://github.com/pypa/hatch/issues/2193 Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/test.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94c26878..5780c815 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install hatch + # Pin virtualenv<21: virtualenv 21.0 removed an API hatch depends on + # https://github.com/pypa/hatch/issues/2193 + python -m pip install hatch 'virtualenv<21' - name: Lint check working-directory: ./python run: make lint LINT_PARAMS="-- --check --diff" @@ -60,7 +62,9 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install semver - python -m pip install hatch + # Pin virtualenv<21: virtualenv 21.0 removed an API hatch depends on + # https://github.com/pypa/hatch/issues/2193 + python -m pip install hatch 'virtualenv<21' - name: Execute hatch envs working-directory: ./python run: make test coverage-report DBR=${{ matrix.config.dbr }}