@@ -163,39 +163,37 @@ def index_declaration(self) -> str | None:
163
163
}
164
164
165
165
166
- def get_latest_version (project_name : str , client : httpx .Client ) -> Version :
166
+ def get_latest_version (target : str , client : httpx .Client ) -> Version :
167
167
"""Return the latest version on all indexes of the package."""
168
168
# To keep the number of packages small we reuse them across targets, so we have to
169
169
# pick a version that doesn't exist on any target yet
170
170
versions = set ()
171
- for target_config in all_targets .values ():
172
- if target_config .project_name != project_name :
173
- continue
174
- url = target_config .index_url + project_name + "/"
175
-
176
- # Get with retries
177
- error = None
178
- for _ in range (5 ):
179
- try :
180
- versions .update (collect_versions (url , client ))
181
- break
182
- except httpx .HTTPError as err :
183
- error = err
184
- print (
185
- f"Error getting version for { project_name } , sleeping for 1s: { err } " ,
186
- file = sys .stderr ,
187
- )
188
- time .sleep (1 )
189
- except InvalidSdistFilename as err :
190
- # Sometimes there's a link that says "status page"
191
- error = err
192
- print (
193
- f"Invalid index page for { project_name } , sleeping for 1s: { err } " ,
194
- file = sys .stderr ,
195
- )
196
- time .sleep (1 )
197
- else :
198
- raise RuntimeError (f"Failed to fetch { url } " ) from error
171
+ target_config = all_targets [target ]
172
+ url = target_config .index_url + target_config .project_name + "/"
173
+
174
+ # Get with retries
175
+ error = None
176
+ for _ in range (5 ):
177
+ try :
178
+ versions .update (collect_versions (url , client ))
179
+ break
180
+ except httpx .HTTPError as err :
181
+ error = err
182
+ print (
183
+ f"Error getting version for { target_config .project_name } , sleeping for 1s: { err } " ,
184
+ file = sys .stderr ,
185
+ )
186
+ time .sleep (1 )
187
+ except InvalidSdistFilename as err :
188
+ # Sometimes there's a link that says "status page"
189
+ error = err
190
+ print (
191
+ f"Invalid index page for { target_config .project_name } , sleeping for 1s: { err } " ,
192
+ file = sys .stderr ,
193
+ )
194
+ time .sleep (1 )
195
+ else :
196
+ raise RuntimeError (f"Failed to fetch { url } " ) from error
199
197
return max (versions )
200
198
201
199
@@ -223,7 +221,7 @@ def get_filenames(url: str, client: httpx.Client) -> list[str]:
223
221
response = client .get (url )
224
222
data = response .text
225
223
# Works for the indexes in the list
226
- href_text = r"<a(?: + [\w-]+=(?:'[^']+'|\"[^\"]+\"))* *>([^<>]+)</a>"
224
+ href_text = r"<a(?:\s* [\w-]+=(?:'[^']+'|\"[^\"]+\"))* *>([^<>]+)</a>"
227
225
return [m .group (1 ) for m in re .finditer (href_text , data )]
228
226
229
227
@@ -363,7 +361,7 @@ def publish_project(target: str, uv: Path, client: httpx.Client):
363
361
print (f"\n Publish { project_name } for { target } " , file = sys .stderr )
364
362
365
363
# The distributions are build to the dist directory of the project.
366
- previous_version = get_latest_version (project_name , client )
364
+ previous_version = get_latest_version (target , client )
367
365
version = get_new_version (previous_version )
368
366
project_dir = build_project_at_version (target , version , uv )
369
367
0 commit comments