From f1a22fc4864b312a0a1500e6efdefad5eed6c8d8 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 5 Mar 2025 15:49:15 +0100 Subject: [PATCH] use UnixNano() for time --- acceptance/cmd/patchwhl/output.txt | 22 +++++++++---------- .../METADATA | 2 +- .../RECORD | 7 ++++++ .../WHEEL | 0 .../entry_points.txt | 0 .../top_level.txt | 0 .../RECORD | 7 ------ acceptance/cmd/patchwhl/script | 6 ++--- libs/patchwheel/parse.go | 5 ++--- libs/patchwheel/parse_test.go | 16 +++++++------- libs/patchwheel/patch_test.go | 1 - 11 files changed, 32 insertions(+), 34 deletions(-) rename acceptance/cmd/patchwhl/output/{my_test_code-0.0.1+2025030514073312.dist-info => my_test_code-0.0.1+1741183653123456789.dist-info}/METADATA (83%) create mode 100644 acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/RECORD rename acceptance/cmd/patchwhl/output/{my_test_code-0.0.1+2025030514073312.dist-info => my_test_code-0.0.1+1741183653123456789.dist-info}/WHEEL (100%) rename acceptance/cmd/patchwhl/output/{my_test_code-0.0.1+2025030514073312.dist-info => my_test_code-0.0.1+1741183653123456789.dist-info}/entry_points.txt (100%) rename acceptance/cmd/patchwhl/output/{my_test_code-0.0.1+2025030514073312.dist-info => my_test_code-0.0.1+1741183653123456789.dist-info}/top_level.txt (100%) delete mode 100644 acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/RECORD diff --git a/acceptance/cmd/patchwhl/output.txt b/acceptance/cmd/patchwhl/output.txt index 168fa93b1..aeefaaed7 100644 --- a/acceptance/cmd/patchwhl/output.txt +++ b/acceptance/cmd/patchwhl/output.txt @@ -3,20 +3,20 @@ >>> setmtime.py 2025-03-05 15:07:33.123456789 my_test_code-0.0.1-py3-none-any.whl >>> [CLI] selftest patchwhl my_test_code-0.0.1-py3-none-any.whl -Warn: Patched whl: my_test_code-0.0.1-py3-none-any.whl -> my_test_code-0.0.1+2025030514073312-py3-none-any.whl +Warn: Patched whl: my_test_code-0.0.1-py3-none-any.whl -> my_test_code-0.0.1+1741183653123456789-py3-none-any.whl >>> diff.py original output ---- original/my_test_code-0.0.1+2025030514073312.dist-info/METADATA -+++ output/my_test_code-0.0.1+2025030514073312.dist-info/METADATA +--- original/my_test_code-0.0.1+1741183653123456789.dist-info/METADATA ++++ output/my_test_code-0.0.1+1741183653123456789.dist-info/METADATA @@ -1,5 +1,5 @@ Metadata-Version: 2.1 Name: my-test-code -Version: 0.0.1 -+Version: 0.0.1+2025030514073312 ++Version: 0.0.1+1741183653123456789 Summary: my test wheel Home-page: https://databricks.com ---- original/my_test_code-0.0.1+2025030514073312.dist-info/RECORD -+++ output/my_test_code-0.0.1+2025030514073312.dist-info/RECORD +--- original/my_test_code-0.0.1+1741183653123456789.dist-info/RECORD ++++ output/my_test_code-0.0.1+1741183653123456789.dist-info/RECORD @@ -1,7 +1,7 @@ src/__init__.py,sha256=BRmKeYehopKv4NG_SFa7t6wn248RrPHJivu7DM1R-Rw,48 src/__main__.py,sha256=8TtsnLsaJEM35Y4L8ocrv-qfxusgYpRL2HPyYiabHng,242 @@ -25,8 +25,8 @@ Warn: Patched whl: my_test_code-0.0.1-py3-none-any.whl -> my_test_code-0.0.1+202 -my_test_code-0.0.1.dist-info/entry_points.txt,sha256=oDWOW9SsBlk4Uejj1ftYPBxfhJ5ZJctb4JOUIG1rc-4,34 -my_test_code-0.0.1.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4 -my_test_code-0.0.1.dist-info/RECORD,, -+my_test_code-0.0.1+2025030514073312.dist-info/METADATA,sha256=nidQMSt6OxDHKdNCQGq1Kv_AmJa1ldwCMHRqPk2TFD8,214 -+my_test_code-0.0.1+2025030514073312.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92 -+my_test_code-0.0.1+2025030514073312.dist-info/entry_points.txt,sha256=oDWOW9SsBlk4Uejj1ftYPBxfhJ5ZJctb4JOUIG1rc-4,34 -+my_test_code-0.0.1+2025030514073312.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4 -+my_test_code-0.0.1+2025030514073312.dist-info/RECORD,, ++my_test_code-0.0.1+1741183653123456789.dist-info/METADATA,sha256=ZDt3WC6oDIUk0pty4-t07jXm7E9CPgVveGLhPsZFa64,217 ++my_test_code-0.0.1+1741183653123456789.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92 ++my_test_code-0.0.1+1741183653123456789.dist-info/entry_points.txt,sha256=oDWOW9SsBlk4Uejj1ftYPBxfhJ5ZJctb4JOUIG1rc-4,34 ++my_test_code-0.0.1+1741183653123456789.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4 ++my_test_code-0.0.1+1741183653123456789.dist-info/RECORD,, diff --git a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/METADATA b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/METADATA similarity index 83% rename from acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/METADATA rename to acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/METADATA index c1ba293e1..a715f4eb7 100644 --- a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/METADATA +++ b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: my-test-code -Version: 0.0.1+2025030514073312 +Version: 0.0.1+1741183653123456789 Summary: my test wheel Home-page: https://databricks.com Author: Databricks diff --git a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/RECORD b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/RECORD new file mode 100644 index 000000000..ec765c71e --- /dev/null +++ b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/RECORD @@ -0,0 +1,7 @@ +src/__init__.py,sha256=BRmKeYehopKv4NG_SFa7t6wn248RrPHJivu7DM1R-Rw,48 +src/__main__.py,sha256=8TtsnLsaJEM35Y4L8ocrv-qfxusgYpRL2HPyYiabHng,242 +my_test_code-0.0.1+1741183653123456789.dist-info/METADATA,sha256=ZDt3WC6oDIUk0pty4-t07jXm7E9CPgVveGLhPsZFa64,217 +my_test_code-0.0.1+1741183653123456789.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92 +my_test_code-0.0.1+1741183653123456789.dist-info/entry_points.txt,sha256=oDWOW9SsBlk4Uejj1ftYPBxfhJ5ZJctb4JOUIG1rc-4,34 +my_test_code-0.0.1+1741183653123456789.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4 +my_test_code-0.0.1+1741183653123456789.dist-info/RECORD,, diff --git a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/WHEEL b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/WHEEL similarity index 100% rename from acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/WHEEL rename to acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/WHEEL diff --git a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/entry_points.txt b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/entry_points.txt similarity index 100% rename from acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/entry_points.txt rename to acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/entry_points.txt diff --git a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/top_level.txt b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/top_level.txt similarity index 100% rename from acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/top_level.txt rename to acceptance/cmd/patchwhl/output/my_test_code-0.0.1+1741183653123456789.dist-info/top_level.txt diff --git a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/RECORD b/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/RECORD deleted file mode 100644 index d081a10f7..000000000 --- a/acceptance/cmd/patchwhl/output/my_test_code-0.0.1+2025030514073312.dist-info/RECORD +++ /dev/null @@ -1,7 +0,0 @@ -src/__init__.py,sha256=BRmKeYehopKv4NG_SFa7t6wn248RrPHJivu7DM1R-Rw,48 -src/__main__.py,sha256=8TtsnLsaJEM35Y4L8ocrv-qfxusgYpRL2HPyYiabHng,242 -my_test_code-0.0.1+2025030514073312.dist-info/METADATA,sha256=nidQMSt6OxDHKdNCQGq1Kv_AmJa1ldwCMHRqPk2TFD8,214 -my_test_code-0.0.1+2025030514073312.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92 -my_test_code-0.0.1+2025030514073312.dist-info/entry_points.txt,sha256=oDWOW9SsBlk4Uejj1ftYPBxfhJ5ZJctb4JOUIG1rc-4,34 -my_test_code-0.0.1+2025030514073312.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4 -my_test_code-0.0.1+2025030514073312.dist-info/RECORD,, diff --git a/acceptance/cmd/patchwhl/script b/acceptance/cmd/patchwhl/script index ec86732c9..61dabeadc 100644 --- a/acceptance/cmd/patchwhl/script +++ b/acceptance/cmd/patchwhl/script @@ -4,11 +4,11 @@ trace setmtime.py "2025-03-05 15:07:33.123456789" my_test_code-0.0.1-py3-none-an trace $CLI selftest patchwhl my_test_code-0.0.1-py3-none-any.whl mkdir output original -unzip -q my_test_code-0.0.1+2025030514073312-py3-none-any.whl -d output +unzip -q my_test_code-0.0.1+1741183653123456789-py3-none-any.whl -d output unzip -q my_test_code-0.0.1-py3-none-any.whl -d original -rm my_test_code-0.0.1+2025030514073312-py3-none-any.whl +rm my_test_code-0.0.1+1741183653123456789-py3-none-any.whl # rename directory to match so that we can compare contents -mv original/my_test_code-0.0.1.dist-info original/my_test_code-0.0.1+2025030514073312.dist-info +mv original/my_test_code-0.0.1.dist-info original/my_test_code-0.0.1+1741183653123456789.dist-info trace diff.py original output rm -fr original diff --git a/libs/patchwheel/parse.go b/libs/patchwheel/parse.go index b57aafe68..369ff57fb 100644 --- a/libs/patchwheel/parse.go +++ b/libs/patchwheel/parse.go @@ -2,6 +2,7 @@ package patchwheel import ( "fmt" + "strconv" "strings" "time" ) @@ -22,9 +23,7 @@ type WheelInfo struct { func calculateNewVersion(info WheelInfo, mtime time.Time) (newVersion, newFilename string) { baseVersion, _, _ := strings.Cut(info.Version, "+") - dt := mtime.Format("20060102150405.00") - dt = strings.Replace(dt, ".", "", 1) - newVersion = baseVersion + "+" + dt + newVersion = baseVersion + "+" + strconv.FormatInt(mtime.UnixNano(), 10) newFilename = fmt.Sprintf("%s-%s-%s.whl", info.Distribution, diff --git a/libs/patchwheel/parse_test.go b/libs/patchwheel/parse_test.go index 2f5580d39..99eac4281 100644 --- a/libs/patchwheel/parse_test.go +++ b/libs/patchwheel/parse_test.go @@ -22,9 +22,9 @@ func TestCalculateNewVersion(t *testing.T) { Version: "1.2.3", Tags: []string{"py3", "none", "any"}, }, - mtime: time.Date(2025, 3, 4, 12, 34, 56, 780_000_000, time.UTC), - expectedVersion: "1.2.3+2025030412345678", - expectedFilename: "mypkg-1.2.3+2025030412345678-py3-none-any.whl", + mtime: time.Date(2025, 3, 4, 12, 34, 56, 780_123_321, time.UTC), + expectedVersion: "1.2.3+1741091696780123321", + expectedFilename: "mypkg-1.2.3+1741091696780123321-py3-none-any.whl", }, { name: "existing plus version", @@ -33,9 +33,9 @@ func TestCalculateNewVersion(t *testing.T) { Version: "1.2.3+local", Tags: []string{"py3", "none", "any"}, }, - mtime: time.Date(2025, 3, 4, 12, 34, 56, 100_000_000, time.UTC), - expectedVersion: "1.2.3+2025030412345610", - expectedFilename: "mypkg-1.2.3+2025030412345610-py3-none-any.whl", + mtime: time.Date(2025, 3, 4, 12, 34, 56, 100_000_005, time.UTC), + expectedVersion: "1.2.3+1741091696100000005", + expectedFilename: "mypkg-1.2.3+1741091696100000005-py3-none-any.whl", }, { name: "complex distribution name", @@ -45,8 +45,8 @@ func TestCalculateNewVersion(t *testing.T) { Tags: []string{"py3", "none", "any"}, }, mtime: time.Date(2025, 3, 4, 12, 34, 56, 0, time.UTC), - expectedVersion: "1.2.3+2025030412345600", - expectedFilename: "my-pkg-name-1.2.3+2025030412345600-py3-none-any.whl", + expectedVersion: "1.2.3+1741091696000000000", + expectedFilename: "my-pkg-name-1.2.3+1741091696000000000-py3-none-any.whl", }, } diff --git a/libs/patchwheel/patch_test.go b/libs/patchwheel/patch_test.go index 822c3d643..8022ec66d 100644 --- a/libs/patchwheel/patch_test.go +++ b/libs/patchwheel/patch_test.go @@ -47,7 +47,6 @@ func verifyVersion(t *testing.T, tempDir, wheelPath string) { cmdOut := captureOutput(t, tempDir, pyExec, "-c", "import myproj; myproj.print_version()") actualVersion := strings.TrimSpace(cmdOut) t.Logf("Verified installed version: %s", actualVersion) - assert.True(t, strings.HasPrefix(actualVersion, "0.1.0+20"), "Version should start with 0.1.0+20, got %s", actualVersion) assert.Equal(t, expectedVersion, actualVersion, "Installed version doesn't match expected version from wheel filename") }