Skip to content

Conversation

evertlammerts
Copy link
Contributor

@Mytherin
Copy link
Collaborator

Thanks for the PR! Should this go into the v1.3 branch?

@evertlammerts evertlammerts changed the base branch from main to v1.3-ossivalis May 23, 2025 09:33
…nction

Move version parsing and bumping logic to top of file and consolidate
version handling through a single bump_version function. Replace complex
setuptools_scm parsing and version_scheme with streamlined implementation
using OVERRIDE_GIT_DESCRIBE environment variable handling.
@evertlammerts
Copy link
Contributor Author

Tl;dr: version bumping should now work correctly and installing from an sdist should work again when this lands.

Background

If we don't pass in a parse function then setuptools_scm has the following precedence order:

  • The SETUPTOOLS_SCM_PRETEND_VERSION[_FOR_X] env var. Will not bump the version, returns the version string directly. This is not what we want: That is, we want to use OVERRIDE_GIT_DESCRIBE to manually set the <version>-<distance>-g<commit> string.
  • Git repository (with git describe) Used if .git/ exists and git describe succeeds. Builds a full ScmVersion object and will bump the version (either with a built-in scheme or whatever we pass in version_scheme. This is what we want
  • PKG-INFO. Used only if no Git repository is found, or git describe fails, and PKG-INFO file exists and contains a valid Version field. No ScmVersion is created and will not bump the version. This is what we want (this only happens when we're building from an sdist and when we do that, the version was already bumped)
  • fallback_version Used only if: no Git repo, no PKG-INFO, no SETUPTOOLS_SCM_PRETEND_VERSION[_FOR_X] Passed directly through as the final version string, i.e. will not bump the version. We don't care about this

If we do pass in a parse function, then none of the above will happen (no overrides, no git describe, no PKG-INFO, no fallback version). The version bumping logic will be called every time. This is what we did and so we had to replicate the git describe, override and PKG-INFO logic, and carefully choose in which cases we want to bump the version.

Since setuptools_scm does only one thing different from how we want it, I just fixed that. In this pr:

  • we disallow passing in SETUPTOOLS_SCM_PRETEND_VERSION and SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DUCKDB manually
  • we allow passing OVERRIDE_GIT_DESCRIBE, parse and bump it, and pass it to setuptools_scm in SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DUCKDB.
  • we make sure the version gets bumped correctly when git describe is used by setuptools_scm.

@evertlammerts evertlammerts marked this pull request as ready for review May 27, 2025 08:44
@evertlammerts evertlammerts requested a review from Tishj May 27, 2025 08:44
Copy link
Contributor

@Tishj Tishj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this makes sense to me 👍
As far as I can tell the biggest changes are:

  • That we don't allow SETUPTOOLS_SCM_PRETEND_VERSION[_FOR_DUCKDB]
  • We use a generated SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DUCKDB to forward the intention of the OVERRIDE_GIT_DESCRIBE functionality.

Removing the hacky (and problematic) parse method override in the process 🎉

One question popped up though, about SETUPTOOLS_SCM_PRETEND_VERSION, is it not possible that this is set for a different package, where duckdb is somehow part of the build process?
If we delete the env, it might cause a problem for that package (if this scenario even exists)
Perhaps we can save it and restore it after we're done?

@evertlammerts
Copy link
Contributor Author

evertlammerts commented May 27, 2025

Thanks, this makes sense to me 👍 As far as I can tell the biggest changes are:

  • That we don't allow SETUPTOOLS_SCM_PRETEND_VERSION[_FOR_DUCKDB]
  • We use a generated SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DUCKDB to forward the intention of the OVERRIDE_GIT_DESCRIBE functionality.

Removing the hacky (and problematic) parse method override in the process 🎉

One question popped up though, about SETUPTOOLS_SCM_PRETEND_VERSION, is it not possible that this is set for a different package, where duckdb is somehow part of the build process? If we delete the env, it might cause a problem for that package (if this scenario even exists) Perhaps we can save it and restore it after we're done?

That's a good point, i'll add that!

Edit: When building a package pip spawns off a child process for each package, so changing the environment in one building process won't affect the environment for another process. This also happens when you use --no-build-isolation. So no need to re-set SETUPTOOLS_SCM_PRETEND_VERSION.

@carlopi
Copy link
Contributor

carlopi commented May 28, 2025

This looks ready to me, should this also go in?

@Mytherin Mytherin merged commit 96927ed into duckdb:v1.3-ossivalis May 28, 2025
19 checks passed
@Mytherin
Copy link
Collaborator

Thanks!

@Tishj Tishj mentioned this pull request Jun 2, 2025
2 tasks
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Jun 2, 2025
Bugfixes (duckdb/duckdb#17695)
Fix version detection for sdist builds without git info (duckdb/duckdb#17605)
@Mytherin Mytherin mentioned this pull request Jun 5, 2025
Mytherin added a commit that referenced this pull request Jun 5, 2025
@evertlammerts @carlopi I had to reconcile a merge conflict between
#17708 and
#17605 - could you double check
that the code in `setup.py` is still correct?
@evertlammerts evertlammerts deleted the 130_py_sdist branch June 12, 2025 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants