@@ -176,11 +176,11 @@ def test_purposefully_empty(self, tmp_path, config_file, param, circumstance):
176
176
else :
177
177
# Make sure build works with or without setup.cfg
178
178
pyproject = self .PURPOSEFULLY_EMPY ["template-pyproject.toml" ]
179
- (tmp_path / "pyproject.toml" ).write_text (pyproject )
179
+ (tmp_path / "pyproject.toml" ).write_text (pyproject , encoding = "utf-8" )
180
180
template_param = param
181
181
182
182
config = self .PURPOSEFULLY_EMPY [config_file ].format (param = template_param )
183
- (tmp_path / config_file ).write_text (config )
183
+ (tmp_path / config_file ).write_text (config , encoding = "utf-8" )
184
184
185
185
dist = _get_dist (tmp_path , {})
186
186
# When either parameter package or py_modules is an empty list,
@@ -292,11 +292,13 @@ class TestWithAttrDirective:
292
292
def test_setupcfg_metadata (self , tmp_path , folder , opts ):
293
293
files = [f"{ folder } /pkg/__init__.py" , "setup.cfg" ]
294
294
_populate_project_dir (tmp_path , files , opts )
295
- (tmp_path / folder / "pkg/__init__.py" ).write_text ("version = 42" )
296
- (tmp_path / "setup.cfg" ).write_text (
297
- "[metadata]\n version = attr: pkg.version\n "
298
- + (tmp_path / "setup.cfg" ).read_text ()
299
- )
295
+
296
+ config = (tmp_path / "setup.cfg" ).read_text (encoding = "utf-8" )
297
+ overwrite = {
298
+ folder : {"pkg" : {"__init__.py" : "version = 42" }},
299
+ "setup.cfg" : "[metadata]\n version = attr: pkg.version\n " + config ,
300
+ }
301
+ jaraco .path .build (overwrite , prefix = tmp_path )
300
302
301
303
dist = _get_dist (tmp_path , {})
302
304
assert dist .get_name () == "pkg"
@@ -312,11 +314,16 @@ def test_setupcfg_metadata(self, tmp_path, folder, opts):
312
314
313
315
def test_pyproject_metadata (self , tmp_path ):
314
316
_populate_project_dir (tmp_path , ["src/pkg/__init__.py" ], {})
315
- (tmp_path / "src/pkg/__init__.py" ).write_text ("version = 42" )
316
- (tmp_path / "pyproject.toml" ).write_text (
317
- "[project]\n name = 'pkg'\n dynamic = ['version']\n "
318
- "[tool.setuptools.dynamic]\n version = {attr = 'pkg.version'}\n "
319
- )
317
+
318
+ overwrite = {
319
+ "src" : {"pkg" : {"__init__.py" : "version = 42" }},
320
+ "pyproject.toml" : (
321
+ "[project]\n name = 'pkg'\n dynamic = ['version']\n "
322
+ "[tool.setuptools.dynamic]\n version = {attr = 'pkg.version'}\n "
323
+ ),
324
+ }
325
+ jaraco .path .build (overwrite , prefix = tmp_path )
326
+
320
327
dist = _get_dist (tmp_path , {})
321
328
assert dist .get_version () == "42"
322
329
assert dist .package_dir == {"" : "src" }
@@ -354,7 +361,7 @@ def _simulate_package_with_extension(self, tmp_path):
354
361
]
355
362
setup(ext_modules=ext_modules)
356
363
"""
357
- (tmp_path / "setup.py" ).write_text (DALS (setup_script ))
364
+ (tmp_path / "setup.py" ).write_text (DALS (setup_script ), encoding = "utf-8" )
358
365
359
366
def test_skip_discovery_with_setupcfg_metadata (self , tmp_path ):
360
367
"""Ensure that auto-discovery is not triggered when the project is based on
@@ -367,14 +374,14 @@ def test_skip_discovery_with_setupcfg_metadata(self, tmp_path):
367
374
requires = []
368
375
build-backend = 'setuptools.build_meta'
369
376
"""
370
- (tmp_path / "pyproject.toml" ).write_text (DALS (pyproject ))
377
+ (tmp_path / "pyproject.toml" ).write_text (DALS (pyproject ), encoding = "utf-8" )
371
378
372
379
setupcfg = """
373
380
[metadata]
374
381
name = proj
375
382
version = 42
376
383
"""
377
- (tmp_path / "setup.cfg" ).write_text (DALS (setupcfg ))
384
+ (tmp_path / "setup.cfg" ).write_text (DALS (setupcfg ), encoding = "utf-8" )
378
385
379
386
dist = _get_dist (tmp_path , {})
380
387
assert dist .get_name () == "proj"
@@ -399,7 +406,7 @@ def test_dont_skip_discovery_with_pyproject_metadata(self, tmp_path):
399
406
name = 'proj'
400
407
version = '42'
401
408
"""
402
- (tmp_path / "pyproject.toml" ).write_text (DALS (pyproject ))
409
+ (tmp_path / "pyproject.toml" ).write_text (DALS (pyproject ), encoding = "utf-8" )
403
410
with pytest .raises (PackageDiscoveryError , match = "multiple (packages|modules)" ):
404
411
_get_dist (tmp_path , {})
405
412
@@ -416,7 +423,7 @@ def _simulate_package_with_data_files(self, tmp_path, src_root):
416
423
manifest = """
417
424
global-include *.py *.txt
418
425
"""
419
- (tmp_path / "MANIFEST.in" ).write_text (DALS (manifest ))
426
+ (tmp_path / "MANIFEST.in" ).write_text (DALS (manifest ), encoding = "utf-8" )
420
427
421
428
EXAMPLE_SETUPCFG = """
422
429
[metadata]
@@ -564,9 +571,12 @@ def _populate_project_dir(root, files, options):
564
571
# NOTE: Currently pypa/build will refuse to build the project if no
565
572
# `pyproject.toml` or `setup.py` is found. So it is impossible to do
566
573
# completely "config-less" projects.
567
- (root / "setup.py" ).write_text ("import setuptools\n setuptools.setup()" )
568
- (root / "README.md" ).write_text ("# Example Package" )
569
- (root / "LICENSE" ).write_text ("Copyright (c) 2018" )
574
+ basic = {
575
+ "setup.py" : "import setuptools\n setuptools.setup()" ,
576
+ "README.md" : "# Example Package" ,
577
+ "LICENSE" : "Copyright (c) 2018" ,
578
+ }
579
+ jaraco .path .build (basic , prefix = root )
570
580
_write_setupcfg (root , options )
571
581
paths = (root / f for f in files )
572
582
for path in paths :
@@ -594,7 +604,7 @@ def _write_setupcfg(root, options):
594
604
with open (root / "setup.cfg" , "w" , encoding = "utf-8" ) as f :
595
605
setupcfg .write (f )
596
606
print ("~~~~~ setup.cfg ~~~~~" )
597
- print ((root / "setup.cfg" ).read_text ())
607
+ print ((root / "setup.cfg" ).read_text (encoding = "utf-8" ))
598
608
599
609
600
610
def _run_build (path , * flags ):
0 commit comments