mirror of https://github.com/databricks/cli.git
use UnixNano() for time
This commit is contained in:
parent
106ce9438e
commit
f1a22fc486
|
@ -3,20 +3,20 @@
|
||||||
>>> setmtime.py 2025-03-05 15:07:33.123456789 my_test_code-0.0.1-py3-none-any.whl
|
>>> 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
|
>>> [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
|
>>> diff.py original output
|
||||||
--- original/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+2025030514073312.dist-info/METADATA
|
+++ output/my_test_code-0.0.1+1741183653123456789.dist-info/METADATA
|
||||||
@@ -1,5 +1,5 @@
|
@@ -1,5 +1,5 @@
|
||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: my-test-code
|
Name: my-test-code
|
||||||
-Version: 0.0.1
|
-Version: 0.0.1
|
||||||
+Version: 0.0.1+2025030514073312
|
+Version: 0.0.1+1741183653123456789
|
||||||
Summary: my test wheel
|
Summary: my test wheel
|
||||||
Home-page: https://databricks.com
|
Home-page: https://databricks.com
|
||||||
--- original/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+2025030514073312.dist-info/RECORD
|
+++ output/my_test_code-0.0.1+1741183653123456789.dist-info/RECORD
|
||||||
@@ -1,7 +1,7 @@
|
@@ -1,7 +1,7 @@
|
||||||
src/__init__.py,sha256=BRmKeYehopKv4NG_SFa7t6wn248RrPHJivu7DM1R-Rw,48
|
src/__init__.py,sha256=BRmKeYehopKv4NG_SFa7t6wn248RrPHJivu7DM1R-Rw,48
|
||||||
src/__main__.py,sha256=8TtsnLsaJEM35Y4L8ocrv-qfxusgYpRL2HPyYiabHng,242
|
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/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/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
|
||||||
-my_test_code-0.0.1.dist-info/RECORD,,
|
-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+1741183653123456789.dist-info/METADATA,sha256=ZDt3WC6oDIUk0pty4-t07jXm7E9CPgVveGLhPsZFa64,217
|
||||||
+my_test_code-0.0.1+2025030514073312.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
+my_test_code-0.0.1+1741183653123456789.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+1741183653123456789.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+1741183653123456789.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/RECORD,,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: my-test-code
|
Name: my-test-code
|
||||||
Version: 0.0.1+2025030514073312
|
Version: 0.0.1+1741183653123456789
|
||||||
Summary: my test wheel
|
Summary: my test wheel
|
||||||
Home-page: https://databricks.com
|
Home-page: https://databricks.com
|
||||||
Author: Databricks
|
Author: Databricks
|
|
@ -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,,
|
|
@ -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,,
|
|
|
@ -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
|
trace $CLI selftest patchwhl my_test_code-0.0.1-py3-none-any.whl
|
||||||
|
|
||||||
mkdir output original
|
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
|
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
|
# 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
|
trace diff.py original output
|
||||||
rm -fr original
|
rm -fr original
|
||||||
|
|
|
@ -2,6 +2,7 @@ package patchwheel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -22,9 +23,7 @@ type WheelInfo struct {
|
||||||
func calculateNewVersion(info WheelInfo, mtime time.Time) (newVersion, newFilename string) {
|
func calculateNewVersion(info WheelInfo, mtime time.Time) (newVersion, newFilename string) {
|
||||||
baseVersion, _, _ := strings.Cut(info.Version, "+")
|
baseVersion, _, _ := strings.Cut(info.Version, "+")
|
||||||
|
|
||||||
dt := mtime.Format("20060102150405.00")
|
newVersion = baseVersion + "+" + strconv.FormatInt(mtime.UnixNano(), 10)
|
||||||
dt = strings.Replace(dt, ".", "", 1)
|
|
||||||
newVersion = baseVersion + "+" + dt
|
|
||||||
|
|
||||||
newFilename = fmt.Sprintf("%s-%s-%s.whl",
|
newFilename = fmt.Sprintf("%s-%s-%s.whl",
|
||||||
info.Distribution,
|
info.Distribution,
|
||||||
|
|
|
@ -22,9 +22,9 @@ func TestCalculateNewVersion(t *testing.T) {
|
||||||
Version: "1.2.3",
|
Version: "1.2.3",
|
||||||
Tags: []string{"py3", "none", "any"},
|
Tags: []string{"py3", "none", "any"},
|
||||||
},
|
},
|
||||||
mtime: time.Date(2025, 3, 4, 12, 34, 56, 780_000_000, time.UTC),
|
mtime: time.Date(2025, 3, 4, 12, 34, 56, 780_123_321, time.UTC),
|
||||||
expectedVersion: "1.2.3+2025030412345678",
|
expectedVersion: "1.2.3+1741091696780123321",
|
||||||
expectedFilename: "mypkg-1.2.3+2025030412345678-py3-none-any.whl",
|
expectedFilename: "mypkg-1.2.3+1741091696780123321-py3-none-any.whl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "existing plus version",
|
name: "existing plus version",
|
||||||
|
@ -33,9 +33,9 @@ func TestCalculateNewVersion(t *testing.T) {
|
||||||
Version: "1.2.3+local",
|
Version: "1.2.3+local",
|
||||||
Tags: []string{"py3", "none", "any"},
|
Tags: []string{"py3", "none", "any"},
|
||||||
},
|
},
|
||||||
mtime: time.Date(2025, 3, 4, 12, 34, 56, 100_000_000, time.UTC),
|
mtime: time.Date(2025, 3, 4, 12, 34, 56, 100_000_005, time.UTC),
|
||||||
expectedVersion: "1.2.3+2025030412345610",
|
expectedVersion: "1.2.3+1741091696100000005",
|
||||||
expectedFilename: "mypkg-1.2.3+2025030412345610-py3-none-any.whl",
|
expectedFilename: "mypkg-1.2.3+1741091696100000005-py3-none-any.whl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "complex distribution name",
|
name: "complex distribution name",
|
||||||
|
@ -45,8 +45,8 @@ func TestCalculateNewVersion(t *testing.T) {
|
||||||
Tags: []string{"py3", "none", "any"},
|
Tags: []string{"py3", "none", "any"},
|
||||||
},
|
},
|
||||||
mtime: time.Date(2025, 3, 4, 12, 34, 56, 0, time.UTC),
|
mtime: time.Date(2025, 3, 4, 12, 34, 56, 0, time.UTC),
|
||||||
expectedVersion: "1.2.3+2025030412345600",
|
expectedVersion: "1.2.3+1741091696000000000",
|
||||||
expectedFilename: "my-pkg-name-1.2.3+2025030412345600-py3-none-any.whl",
|
expectedFilename: "my-pkg-name-1.2.3+1741091696000000000-py3-none-any.whl",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ func verifyVersion(t *testing.T, tempDir, wheelPath string) {
|
||||||
cmdOut := captureOutput(t, tempDir, pyExec, "-c", "import myproj; myproj.print_version()")
|
cmdOut := captureOutput(t, tempDir, pyExec, "-c", "import myproj; myproj.print_version()")
|
||||||
actualVersion := strings.TrimSpace(cmdOut)
|
actualVersion := strings.TrimSpace(cmdOut)
|
||||||
t.Logf("Verified installed version: %s", actualVersion)
|
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")
|
assert.Equal(t, expectedVersion, actualVersion, "Installed version doesn't match expected version from wheel filename")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue