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
@@ -50,7 +50,7 @@ def run(*argv, expect_exit_code=0):
50
50
else :
51
51
os .chdir (tmp_dir )
52
52
53
- cmd = " " .join (shlex . quote ( x ) for x in argv )
53
+ cmd = shlex .join (argv )
54
54
print ("$ " + cmd )
55
55
exit_code = os .system (cmd )
56
56
if exit_code != expect_exit_code :
@@ -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
@@ -120,14 +123,15 @@ def test_dist(dist):
120
123
"--strict" ,
121
124
"--install-types" ,
122
125
"--non-interactive" ,
126
+ "--ignore-missing-imports" ,
123
127
os .path .join (
124
128
base_dir , "test_elasticsearch_serverless/test_types/async_types.py"
125
129
),
126
130
)
127
131
128
132
# Ensure that the namespaces are correct for the dist
129
133
for suffix in ("" , "1" , "2" , "5" , "6" , "7" , "8" , "9" , "10" ):
130
- distx_name = f"elasticsearch { suffix } "
134
+ distx_name = f"elasticsearch_serverless { suffix } "
131
135
run (
132
136
venv_python ,
133
137
"-c" ,
@@ -136,7 +140,7 @@ def test_dist(dist):
136
140
)
137
141
138
142
# Check that sync types work for 'elasticsearch_serverless' and
139
- # that aliased types work for 'elasticsearchX '
143
+ # that aliased types work for 'elasticsearch_serverlessX '
140
144
if dist_name == "elasticsearch_serverless" :
141
145
run (
142
146
venv_python ,
@@ -145,6 +149,7 @@ def test_dist(dist):
145
149
"--strict" ,
146
150
"--install-types" ,
147
151
"--non-interactive" ,
152
+ "--ignore-missing-imports" ,
148
153
os .path .join (
149
154
base_dir , "test_elasticsearch_serverless/test_types/sync_types.py"
150
155
),
@@ -174,16 +179,16 @@ def test_dist(dist):
174
179
175
180
176
181
def main ():
177
- run ("git" , "checkout" , "--" , "setup.py " , "elasticsearch_serverless/" )
178
- run ("rm" , "-rf" , "build/" , " dist/*" , "*.egg-info" , ".eggs " )
182
+ run ("git" , "checkout" , "--" , "pyproject.toml " , "elasticsearch_serverless/" )
183
+ run ("rm" , "-rf" , "dist" )
179
184
180
185
# Grab the major version to be used as a suffix.
181
186
version_path = os .path .join (base_dir , "elasticsearch_serverless/_version.py" )
182
187
with open (version_path ) as f :
183
188
version = re .search (
184
189
r"^__versionstr__\s+=\s+[\"\']([^\"\']+)[\"\']" , f .read (), re .M
185
190
).group (1 )
186
- major_version = version .split ("." )[0 ]
191
+ # major_version = version.split(".")[0]
187
192
188
193
# If we're handed a version from the build manager we
189
194
# should check that the version is correct or write
@@ -231,17 +236,19 @@ def main():
231
236
)
232
237
exit (1 )
233
238
234
- for suffix in ("" , major_version ):
239
+ for suffix in ("" ,):
235
240
run ("rm" , "-rf" , "build/" , "*.egg-info" , ".eggs" )
236
241
237
242
# Rename the module to fit the suffix.
238
243
shutil .move (
239
244
os .path .join (base_dir , "elasticsearch_serverless" ),
240
- os .path .join (base_dir , f"elasticsearch { suffix } " ),
245
+ os .path .join (base_dir , f"elasticsearch_serverless { suffix } " ),
241
246
)
242
247
243
248
# Ensure that the version within 'elasticsearch_serverless/_version.py' is correct.
244
- version_path = os .path .join (base_dir , f"elasticsearch{ suffix } /_version.py" )
249
+ version_path = os .path .join (
250
+ base_dir , f"elasticsearch_serverless{ suffix } /_version.py"
251
+ )
245
252
with open (version_path ) as f :
246
253
version_data = f .read ()
247
254
version_data = re .sub (
@@ -253,31 +260,29 @@ def main():
253
260
f .truncate ()
254
261
f .write (version_data )
255
262
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 :
263
+ # Rewrite pyproject.toml with the new name.
264
+ pyproject_toml_path = os .path .join (base_dir , "pyproject.toml " )
265
+ with open (pyproject_toml_path ) as f :
266
+ pyproject_toml = f .read ()
267
+ with open (pyproject_toml_path , "w" ) as f :
261
268
f .truncate ()
262
- assert 'package_name = "elasticsearch_serverless"' in setup_py
263
269
f .write (
264
- setup_py .replace (
265
- 'package_name = "elasticsearch_serverless"' ,
266
- f'package_name = "elasticsearch{ suffix } "' ,
270
+ pyproject_toml .replace (
271
+ "elasticsearch_serverless" , f"elasticsearch_serverless{ suffix } "
267
272
)
268
273
)
269
274
270
275
# Build the sdist/wheels
271
276
run ("python" , "-m" , "build" )
272
277
273
278
# Clean up everything.
274
- run ("git" , "checkout" , "--" , "setup.py " , "elasticsearch_serverless/" )
279
+ run ("git" , "checkout" , "--" , "pyproject.toml " , "elasticsearch_serverless/" )
275
280
if suffix :
276
- run ("rm" , "-rf" , f"elasticsearch { suffix } /" )
281
+ run ("rm" , "-rf" , f"elasticsearch_serverless { suffix } /" )
277
282
278
283
# Test everything that got created
279
284
dists = os .listdir (os .path .join (base_dir , "dist" ))
280
- assert len (dists ) == 4
285
+ assert len (dists ) == 2
281
286
for dist in dists :
282
287
test_dist (os .path .join (base_dir , "dist" , dist ))
283
288
os .system ('bash -c "chmod a+w dist/*"' )
0 commit comments