Commit 0a366602 authored by Jason R. Coombs's avatar Jason R. Coombs

Merge template loader refactoring

parents ca7d4bdf 99475b7b
...@@ -732,23 +732,25 @@ Please make the appropriate changes for your system and try again. ...@@ -732,23 +732,25 @@ Please make the appropriate changes for your system and try again.
spec = str(dist.as_requirement()) spec = str(dist.as_requirement())
is_script = is_python_script(script_text, script_name) is_script = is_python_script(script_text, script_name)
def get_template(filename): if is_script:
script_text = (get_script_header(script_text) +
self._load_template(dev_path) % locals())
self.write_script(script_name, _to_ascii(script_text), 'b')
@staticmethod
def _load_template(dev_path):
""" """
There are a couple of template scripts in the package. This There are a couple of template scripts in the package. This
function loads one of them and prepares it for use. function loads one of them and prepares it for use.
""" """
raw_bytes = resource_string('setuptools', template_name)
return raw_bytes.decode('utf-8')
if is_script:
# See https://bitbucket.org/pypa/setuptools/issue/134 for info # See https://bitbucket.org/pypa/setuptools/issue/134 for info
# on script file naming and downstream issues with SVR4 # on script file naming and downstream issues with SVR4
template_name = 'script.tmpl' name = 'script.tmpl'
if dev_path: if dev_path:
template_name = template_name.replace('.tmpl', ' (dev).tmpl') name = name.replace('.tmpl', ' (dev).tmpl')
script_text = (get_script_header(script_text) +
get_template(template_name) % locals()) raw_bytes = resource_string('setuptools', name)
self.write_script(script_name, _to_ascii(script_text), 'b') return raw_bytes.decode('utf-8')
def write_script(self, script_name, contents, mode="t", blockers=()): def write_script(self, script_name, contents, mode="t", blockers=()):
"""Write an executable file to the scripts directory""" """Write an executable file to the scripts directory"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment