@@ -163,19 +163,19 @@ def _build(self, wheel: zipfile.ZipFile) -> None:
163
163
# we assume that the build script will build and copy the files
164
164
# directly.
165
165
# That way they will be picked up when adding files to the wheel.
166
- current_path = os . getcwd ()
166
+ current_path = Path . cwd ()
167
167
try :
168
- os .chdir (str ( self ._path ) )
168
+ os .chdir (self ._path )
169
169
self ._run_build_script (self ._package .build_script )
170
170
finally :
171
171
os .chdir (current_path )
172
172
else :
173
173
with SdistBuilder (poetry = self ._poetry ).setup_py () as setup :
174
174
# We need to place ourselves in the temporary
175
175
# directory in order to build the package
176
- current_path = os . getcwd ()
176
+ current_path = Path . cwd ()
177
177
try :
178
- os .chdir (str ( self ._path ) )
178
+ os .chdir (self ._path )
179
179
self ._run_build_command (setup )
180
180
finally :
181
181
os .chdir (current_path )
@@ -194,9 +194,9 @@ def _build(self, wheel: zipfile.ZipFile) -> None:
194
194
if pkg .is_dir () or self .is_excluded (pkg ):
195
195
continue
196
196
197
- rel_path = str ( pkg .relative_to (lib ) )
197
+ rel_path = pkg .relative_to (lib )
198
198
199
- if rel_path in wheel .namelist ():
199
+ if rel_path . as_posix () in wheel .namelist ():
200
200
continue
201
201
202
202
logger .debug (f"Adding: { rel_path } " )
@@ -210,7 +210,7 @@ def _copy_file_scripts(self, wheel: zipfile.ZipFile) -> None:
210
210
self ._add_file (
211
211
wheel ,
212
212
abs_path ,
213
- Path . joinpath ( Path ( self .wheel_data_folder ), "scripts" , abs_path .name ) ,
213
+ Path ( self .wheel_data_folder ) / "scripts" / abs_path .name ,
214
214
)
215
215
216
216
def _run_build_command (self , setup : Path ) -> None :
@@ -268,7 +268,7 @@ def prepare_metadata(self, metadata_directory: Path) -> Path:
268
268
continue
269
269
270
270
dest = dist_info / license_file .relative_to (self ._path )
271
- os . makedirs ( dest .parent , exist_ok = True )
271
+ dest .parent . mkdir ( parents = True , exist_ok = True )
272
272
shutil .copy (license_file , dest )
273
273
274
274
return dist_info
@@ -345,19 +345,15 @@ def tag(self) -> str:
345
345
def _add_file (
346
346
self ,
347
347
wheel : zipfile .ZipFile ,
348
- full_path : Path | str ,
349
- rel_path : Path | str ,
348
+ full_path : Path ,
349
+ rel_path : Path ,
350
350
) -> None :
351
- full_path , rel_path = str (full_path ), str (rel_path )
352
- if os .sep != "/" :
353
- # We always want to have /-separated paths in the zip file and in
354
- # RECORD
355
- rel_path = rel_path .replace (os .sep , "/" )
356
-
357
- zinfo = zipfile .ZipInfo (rel_path )
351
+ # We always want to have /-separated paths in the zip file and in RECORD
352
+ rel_path_name = rel_path .as_posix ()
353
+ zinfo = zipfile .ZipInfo (rel_path_name )
358
354
359
355
# Normalize permission bits to either 755 (executable) or 644
360
- st_mode = os .stat (full_path ).st_mode
356
+ st_mode = full_path .stat ().st_mode
361
357
new_mode = normalize_file_permissions (st_mode )
362
358
zinfo .external_attr = (new_mode & 0xFFFF ) << 16 # Unix attributes
363
359
@@ -375,10 +371,10 @@ def _add_file(
375
371
src .seek (0 )
376
372
wheel .writestr (zinfo , src .read (), compress_type = zipfile .ZIP_DEFLATED )
377
373
378
- size = os .stat (full_path ).st_size
374
+ size = full_path .stat ().st_size
379
375
hash_digest = urlsafe_b64encode (hashsum .digest ()).decode ("ascii" ).rstrip ("=" )
380
376
381
- self ._records .append ((rel_path , hash_digest , size ))
377
+ self ._records .append ((rel_path_name , hash_digest , size ))
382
378
383
379
@contextlib .contextmanager
384
380
def _write_to_zip (
0 commit comments