Skip to content

Commit f905bff

Browse files
authored
Fix nightly (#2227)
If the original version has a .dev suffix on it, we were trying to create a nightly with .devX.devY, which is invalid. We have a dev suffix on the master branch to stop accidentally releasing a stable version from the master branch (which we've done a few times).
1 parent 07b893d commit f905bff

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pip_build.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def copy_source_to_build_directory(root_path, package):
8181
shutil.copy(root_path / fname, root_path / build_directory / fname)
8282

8383

84-
def build_wheel(build_path, dist_path, __version__):
84+
def build_wheel(build_path, dist_path, version):
8585
# Build the package
8686
os.chdir(build_path)
8787
os.system("python3 -m build")
@@ -94,7 +94,7 @@ def build_wheel(build_path, dist_path, __version__):
9494

9595
# Find the .whl file path
9696
for fname in os.listdir(dist_path):
97-
if __version__ in fname and fname.endswith(".whl"):
97+
if version in fname and fname.endswith(".whl"):
9898
whl_path = dist_path / fname
9999
print(f"Build successful. Wheel file available at {whl_path}")
100100
return whl_path
@@ -110,7 +110,13 @@ def build(root_path, is_nightly=False, keras_nlp=True):
110110

111111
if is_nightly:
112112
date = datetime.datetime.now()
113-
__version__ += f".dev{date:%Y%m%d%H%M}"
113+
version = re.sub(
114+
r"([0-9]+\.[0-9]+\.[0-9]+).*", # Match version without suffix.
115+
r"\1.dev" + date.strftime("%Y%m%d%H%M"), # Add dev{date} suffix.
116+
__version__,
117+
)
118+
else:
119+
version = __version__
114120

115121
try:
116122
whls = []
@@ -119,17 +125,17 @@ def build(root_path, is_nightly=False, keras_nlp=True):
119125
os.mkdir(build_path)
120126

121127
copy_source_to_build_directory(root_path, hub_package)
122-
update_build_files(build_path, hub_package, __version__, is_nightly)
123-
whl = build_wheel(build_path, dist_path, __version__)
128+
update_build_files(build_path, hub_package, version, is_nightly)
129+
whl = build_wheel(build_path, dist_path, version)
124130
whls.append(whl)
125131

126132
if keras_nlp:
127133
build_path = root_path / build_directory / nlp_package
128134
dist_path = root_path / nlp_package / dist_directory
129135

130136
copy_source_to_build_directory(root_path, nlp_package)
131-
update_build_files(build_path, nlp_package, __version__, is_nightly)
132-
whl = build_wheel(build_path, dist_path, __version__)
137+
update_build_files(build_path, nlp_package, version, is_nightly)
138+
whl = build_wheel(build_path, dist_path, version)
133139
whls.append(whl)
134140

135141
return whls

pyproject.toml

-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ filterwarnings = [
7878
"ignore::PendingDeprecationWarning",
7979
"ignore::FutureWarning",
8080
"ignore::UserWarning",
81-
# Ignore a spurious warning on tf-nightly related to save model changes.
82-
"ignore:Custom mask layers require a config",
8381
]
8482
addopts = "-vv"
8583

0 commit comments

Comments
 (0)