Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate unstable package versions which can be ordered by timestamp in release.sh #7399

Closed
cosmicexplorer opened this issue Mar 18, 2019 · 2 comments · Fixed by #19179
Closed

Comments

@cosmicexplorer
Copy link
Contributor

cosmicexplorer commented Mar 18, 2019

CI on master was broken after merging 0672383, because when building wheels, our release script sets PANTS_UNSTABLE_VERSION to be the version in src/python/pants/VERSION, along with the first 8 characters of the commit sha. This should be fine, but not mentioned in https://www.python.org/dev/peps/pep-0440/#local-version-identifiers is that local build tags which consist of only numbers will have leading zeroes truncated, e.g.:

X> pex packaging setuptools
Python 2.7.15 (default, Jun 20 2018, 17:40:09)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from packaging.version import Version
>>> Version('1.15.0.dev4+06723833')
<Version('1.15.0.dev4+6723833')>
>>> str(Version('1.15.0.dev4+06723833'))
'1.15.0.dev4+6723833'

This required a fix in #7400 by prefacing the sha with a constant non-numeric string to avoid it getting parsed as a number.

While that was fixed, it might also be pretty useful to further modify the PANTS_UNSTABLE_VERSION, to add a timestamp before the SHA. This would allow ls to ensure the most recently produced wheel would always be at the bottom of the output.

@cosmicexplorer
Copy link
Contributor Author

cosmicexplorer commented Mar 19, 2019

Note that the timestamp component should be relatively easy to generate, but may require coordination between wheel shards in CI to work: see #7400 (comment). This might not be too difficult though.

cosmicexplorer added a commit that referenced this issue Mar 19, 2019
… parsed and truncated as a number (#7400)

### Problem

See #7399. The commit 0672383 experienced CI failures, because our current method of generating the "unstable" pants version to build wheels puts the hexadecimal sha as its own version component: if the sha happens to be completely numeric and begins with any zeroes, `packaging.version.Version()` will helpfully truncate it -- but our `release.sh` script wasn't aware of that.

### Solution

- Add a non-numeric prefix before the sha to generate `PANTS_UNSTABLE_VERSION` in `release.sh` to avoid possible truncation.
  - The prefix chosen was `git`.

### Result

Commit shas starting with zero and containing only numbers for the first 8 characters will no longer fail in CI.
stuhood pushed a commit that referenced this issue Mar 20, 2019
… parsed and truncated as a number (#7400)

### Problem

See #7399. The commit 0672383 experienced CI failures, because our current method of generating the "unstable" pants version to build wheels puts the hexadecimal sha as its own version component: if the sha happens to be completely numeric and begins with any zeroes, `packaging.version.Version()` will helpfully truncate it -- but our `release.sh` script wasn't aware of that.

### Solution

- Add a non-numeric prefix before the sha to generate `PANTS_UNSTABLE_VERSION` in `release.sh` to avoid possible truncation.
  - The prefix chosen was `git`.

### Result

Commit shas starting with zero and containing only numbers for the first 8 characters will no longer fail in CI.
@stuhood
Copy link
Member

stuhood commented Apr 7, 2019

Thinking about this again, it should be possible to deterministically extract the commit timestamp to use here, which avoid needing to coordinate between shards.

@benjyw benjyw removed the releases label Sep 9, 2021
huonw added a commit that referenced this issue May 31, 2023
…#19179)

Fixes #7399 by adjusting the local version identifier of 'unstable'
wheels to also include a timestamp, so that builds with the same stable
version can be sorted in a vaguely sensible way, without having to
dereference the git hash manually.

The timestamp chosen is the committer date of the commit in question,
formatted as a vaguely human readable number (`yyyymmddHHMM`). For
example, this PR's CI built
`pantsbuild.pants-2.18.0.dev0+202305302357.git111f44db-cp39-cp39-macosx_11_0_arm64.whl`,
corresponding to 2023-05-30 23:57.
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 a pull request may close this issue.

3 participants