17
17
18
18
"""A command line tool for building and verifying releases
19
19
Can be used for building both 'elasticsearch' and 'elasticsearchX' dists.
20
- Only requires 'name' in 'setup.py ' and the directory to be changed.
20
+ Only requires 'name' in 'pyproject.toml ' and the directory to be changed.
21
21
"""
22
22
23
23
import contextlib
@@ -65,7 +65,9 @@ def run(*argv, expect_exit_code=0):
65
65
66
66
def test_dist (dist ):
67
67
with set_tmp_dir () as tmp_dir :
68
- dist_name = re .match (r"^(elasticsearch\d*)-" , os .path .basename (dist )).group (1 )
68
+ dist_name = re .match (
69
+ r"^(elasticsearch_serverless\d*)-" , os .path .basename (dist )
70
+ ).group (1 )
69
71
70
72
# Build the venv and install the dist
71
73
run ("python" , "-m" , "venv" , os .path .join (tmp_dir , "venv" ))
@@ -80,6 +82,7 @@ def test_dist(dist):
80
82
"mypy" ,
81
83
"numpy" ,
82
84
"pandas-stubs" ,
85
+ "opentelemetry-api" ,
83
86
)
84
87
run (venv_python , "-m" , "pip" , "install" , dist )
85
88
@@ -127,7 +130,7 @@ def test_dist(dist):
127
130
128
131
# Ensure that the namespaces are correct for the dist
129
132
for suffix in ("" , "1" , "2" , "5" , "6" , "7" , "8" , "9" , "10" ):
130
- distx_name = f"elasticsearch { suffix } "
133
+ distx_name = f"elasticsearch_serverless { suffix } "
131
134
run (
132
135
venv_python ,
133
136
"-c" ,
@@ -136,7 +139,7 @@ def test_dist(dist):
136
139
)
137
140
138
141
# Check that sync types work for 'elasticsearch_serverless' and
139
- # that aliased types work for 'elasticsearchX '
142
+ # that aliased types work for 'elasticsearch_serverlessX '
140
143
if dist_name == "elasticsearch_serverless" :
141
144
run (
142
145
venv_python ,
@@ -174,16 +177,16 @@ def test_dist(dist):
174
177
175
178
176
179
def main ():
177
- run ("git" , "checkout" , "--" , "setup.py " , "elasticsearch_serverless/" )
178
- run ("rm" , "-rf" , "build/" , " dist/*" , "*.egg-info" , ".eggs " )
180
+ run ("git" , "checkout" , "--" , "pyproject.toml " , "elasticsearch_serverless/" )
181
+ run ("rm" , "-rf" , "dist" )
179
182
180
183
# Grab the major version to be used as a suffix.
181
184
version_path = os .path .join (base_dir , "elasticsearch_serverless/_version.py" )
182
185
with open (version_path ) as f :
183
186
version = re .search (
184
187
r"^__versionstr__\s+=\s+[\"\']([^\"\']+)[\"\']" , f .read (), re .M
185
188
).group (1 )
186
- major_version = version .split ("." )[0 ]
189
+ # major_version = version.split(".")[0]
187
190
188
191
# If we're handed a version from the build manager we
189
192
# should check that the version is correct or write
@@ -231,17 +234,19 @@ def main():
231
234
)
232
235
exit (1 )
233
236
234
- for suffix in ("" , major_version ):
237
+ for suffix in ("" ,):
235
238
run ("rm" , "-rf" , "build/" , "*.egg-info" , ".eggs" )
236
239
237
240
# Rename the module to fit the suffix.
238
241
shutil .move (
239
242
os .path .join (base_dir , "elasticsearch_serverless" ),
240
- os .path .join (base_dir , f"elasticsearch { suffix } " ),
243
+ os .path .join (base_dir , f"elasticsearch_serverless { suffix } " ),
241
244
)
242
245
243
246
# Ensure that the version within 'elasticsearch_serverless/_version.py' is correct.
244
- version_path = os .path .join (base_dir , f"elasticsearch{ suffix } /_version.py" )
247
+ version_path = os .path .join (
248
+ base_dir , f"elasticsearch_serverless{ suffix } /_version.py"
249
+ )
245
250
with open (version_path ) as f :
246
251
version_data = f .read ()
247
252
version_data = re .sub (
@@ -253,31 +258,29 @@ def main():
253
258
f .truncate ()
254
259
f .write (version_data )
255
260
256
- # Rewrite setup.py with the new name.
257
- setup_py_path = os .path .join (base_dir , "setup.py " )
258
- with open (setup_py_path ) as f :
259
- setup_py = f .read ()
260
- with open (setup_py_path , "w" ) as f :
261
+ # Rewrite pyproject.toml with the new name.
262
+ pyproject_toml_path = os .path .join (base_dir , "pyproject.toml " )
263
+ with open (pyproject_toml_path ) as f :
264
+ pyproject_toml = f .read ()
265
+ with open (pyproject_toml_path , "w" ) as f :
261
266
f .truncate ()
262
- assert 'package_name = "elasticsearch_serverless"' in setup_py
263
267
f .write (
264
- setup_py .replace (
265
- 'package_name = "elasticsearch_serverless"' ,
266
- f'package_name = "elasticsearch{ suffix } "' ,
268
+ pyproject_toml .replace (
269
+ "elasticsearch_serverless" , f"elasticsearch_serverless{ suffix } "
267
270
)
268
271
)
269
272
270
273
# Build the sdist/wheels
271
274
run ("python" , "-m" , "build" )
272
275
273
276
# Clean up everything.
274
- run ("git" , "checkout" , "--" , "setup.py " , "elasticsearch_serverless/" )
277
+ run ("git" , "checkout" , "--" , "pyproject.toml " , "elasticsearch_serverless/" )
275
278
if suffix :
276
- run ("rm" , "-rf" , f"elasticsearch { suffix } /" )
279
+ run ("rm" , "-rf" , f"elasticsearch_serverless { suffix } /" )
277
280
278
281
# Test everything that got created
279
282
dists = os .listdir (os .path .join (base_dir , "dist" ))
280
- assert len (dists ) == 4
283
+ assert len (dists ) == 2
281
284
for dist in dists :
282
285
test_dist (os .path .join (base_dir , "dist" , dist ))
283
286
os .system ('bash -c "chmod a+w dist/*"' )
0 commit comments