From f51b6df1d6b9e6fc239d24e217ecfe51e64b5113 Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Thu, 28 Dec 2023 13:43:36 +0100 Subject: [PATCH] Switch to hatchling build backend --- .github/workflows/release.yml | 7 +++--- pyproject.toml | 42 ++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97c787cfe..70afc957d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install --upgrade build setuptools setuptools_scm twine + python -m pip install --upgrade build hatch twine # if this is a release, upload to PyPI - name: Build and publish release @@ -28,7 +28,7 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - PACKAGE_VERSION=$(python -m setuptools_scm) + PACKAGE_VERSION=$(hatch version) echo "Creating package with version $PACKAGE_VERSION" python -m build twine upload dist/* @@ -41,9 +41,8 @@ jobs: TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN}} # override setuptools_scm config to remove local version, else PyPI will not accept the package # this allows to push development releases to the test index from any repository state - SETUPTOOLS_SCM_OVERRIDES_FOR_FASTF1: local_scheme="no-local-version" run: | - PACKAGE_VERSION=$(python -m setuptools_scm) + PACKAGE_VERSION=$(hatch version) echo "Creating package with version $PACKAGE_VERSION" python -m build twine upload --repository testpypi dist/* \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index b7595ea08..c4e87b304 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,19 +32,41 @@ dependencies = [ "Documentation" = "https://docs.fastf1.dev" [build-system] -requires = ["setuptools", "setuptools-scm"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" -[tool.setuptools.packages.find] -where = [""] -include = ["fastf1*"] -exclude = ["fastf1/testing*"] -namespaces = false +[tool.hatch.version] +source = "vcs" -[tool.setuptools_scm] -version_file = "fastf1/_version.py" +[tool.hatch.build.targets.wheel] +ignore-vcs = true +include = [ + "fastf1/**", +] +exclude = [ + "fastf1/tests/**", + "fastf1/testing/**", +] + +[tool.hatch.build.targets.sdist] +ignore-vcs = true +include = [ + "fastf1/**", + "requirements/**", + "examples/**" +] +exclude = [ + "fastf1/tests/**", + "fastf1/testing/**", +] + +[tool.hatch.build.hooks.vcs] +version-file = "fastf1/_version.py" + +[tool.hatch.version.raw-options] +# configures setuptools_scm within the hatchling build backend version_scheme = "release-branch-semver" -local_scheme = "node-and-date" +local_scheme = "no-local-version" # needed for PyPI support for dev releases; hatch-vcs ignores setuptools_scm overrides through env vars fallback_version = "0.0+UNKNOWN" [tool.ruff]