File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class Extension:
26
26
name : string
27
27
the full name of the extension, including any packages -- ie.
28
28
*not* a filename or pathname, but Python dotted name
29
- sources : [string]
29
+ sources : [string | os.PathLike ]
30
30
list of source filenames, relative to the distribution root
31
31
(where the setup script lives), in Unix form (slash-separated)
32
32
for portability. Source files may be C, C++, SWIG (.i),
@@ -106,8 +106,13 @@ def __init__(
106
106
):
107
107
if not isinstance (name , str ):
108
108
raise AssertionError ("'name' must be a string" )
109
- if not (isinstance (sources , list ) and all (isinstance (v , str ) for v in sources )):
110
- raise AssertionError ("'sources' must be a list of strings" )
109
+ if not (
110
+ isinstance (sources , list )
111
+ and all (isinstance (v , (str , os .PathLike )) for v in sources )
112
+ ):
113
+ raise AssertionError (
114
+ "'sources' must be a list of strings or PathLike objects."
115
+ )
111
116
112
117
self .name = name
113
118
self .sources = sources
Original file line number Diff line number Diff line change 2
2
3
3
import os
4
4
import warnings
5
+ from pathlib import Path
5
6
6
7
from distutils .extension import read_setup_file , Extension
7
8
@@ -68,13 +69,15 @@ def test_extension_init(self):
68
69
assert ext .name == 'name'
69
70
70
71
# the second argument, which is the list of files, must
71
- # be a list of strings
72
+ # be a list of strings or PathLike objects
72
73
with pytest .raises (AssertionError ):
73
74
Extension ('name' , 'file' )
74
75
with pytest .raises (AssertionError ):
75
76
Extension ('name' , ['file' , 1 ])
76
77
ext = Extension ('name' , ['file1' , 'file2' ])
77
78
assert ext .sources == ['file1' , 'file2' ]
79
+ ext = Extension ('name' , [Path ('file1' ), Path ('file2' )])
80
+ assert ext .sources == ['file1' , 'file2' ]
78
81
79
82
# others arguments have defaults
80
83
for attr in (
You can’t perform that action at this time.
0 commit comments