File tree 2 files changed +34
-5
lines changed
2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 26
26
Again, this is not a formal definition! Just a "taste" of the module.
27
27
"""
28
28
29
+ import io
29
30
import os
30
31
import sys
31
32
import tokenize
@@ -95,6 +96,14 @@ def _file_with_extension(directory, extension):
95
96
return file
96
97
97
98
99
+ def _open_setup_script (setup_script ):
100
+ if not os .path .exists (setup_script ):
101
+ # Supply a default setup.py
102
+ return io .StringIO (u"from setuptools import setup; setup()" )
103
+
104
+ return getattr (tokenize , 'open' , open )(setup_script )
105
+
106
+
98
107
class _BuildMetaBackend (object ):
99
108
100
109
def _fix_config (self , config_settings ):
@@ -120,9 +129,10 @@ def run_setup(self, setup_script='setup.py'):
120
129
# Correctness comes first, then optimization later
121
130
__file__ = setup_script
122
131
__name__ = '__main__'
123
- f = getattr (tokenize , 'open' , open )(__file__ )
124
- code = f .read ().replace ('\\ r\\ n' , '\\ n' )
125
- f .close ()
132
+
133
+ with _open_setup_script (__file__ ) as f :
134
+ code = f .read ().replace (r'\r\n' , r'\n' )
135
+
126
136
exec (compile (code , __file__ , 'exec' ), locals ())
127
137
128
138
def get_requires_for_build_wheel (self , config_settings = None ):
Original file line number Diff line number Diff line change @@ -110,6 +110,21 @@ def run():
110
110
print('hello')
111
111
""" ),
112
112
},
113
+ {
114
+ 'setup.cfg' : DALS ("""
115
+ [metadata]
116
+ name = foo
117
+ version='0.0.0'
118
+
119
+ [options]
120
+ py_modules=hello
121
+ setup_requires=six
122
+ """ ),
123
+ 'hello.py' : DALS ("""
124
+ def run():
125
+ print('hello')
126
+ """ )
127
+ },
113
128
]
114
129
115
130
@@ -183,9 +198,13 @@ def test_build_sdist_version_change(self, build_backend):
183
198
# if the setup.py changes subsequent call of the build meta
184
199
# should still succeed, given the
185
200
# sdist_directory the frontend specifies is empty
186
- with open (os .path .abspath ("setup.py" ), 'rt' ) as file_handler :
201
+ setup_loc = os .path .abspath ("setup.py" )
202
+ if not os .path .exists (setup_loc ):
203
+ setup_loc = os .path .abspath ("setup.cfg" )
204
+
205
+ with open (setup_loc , 'rt' ) as file_handler :
187
206
content = file_handler .read ()
188
- with open (os . path . abspath ( "setup.py" ) , 'wt' ) as file_handler :
207
+ with open (setup_loc , 'wt' ) as file_handler :
189
208
file_handler .write (
190
209
content .replace ("version='0.0.0'" , "version='0.0.1'" ))
191
210
You can’t perform that action at this time.
0 commit comments