mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
fix xon.sh to make it take the current python and not a generic python3
This commit is contained in:
parent
4f472fc035
commit
1d71395f6b
1 changed files with 27 additions and 3 deletions
30
setup.py
30
setup.py
|
@ -181,7 +181,7 @@ class xinstall(install):
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
print('Installing Jupyter hook failed.')
|
||||
install.run(self)
|
||||
super().run()
|
||||
if dirty:
|
||||
restore_version()
|
||||
|
||||
|
@ -193,7 +193,7 @@ class xsdist(sdist):
|
|||
build_tables()
|
||||
amalgamate_source()
|
||||
dirty = dirty_version()
|
||||
sdist.make_release_tree(self, basedir, files)
|
||||
super().make_release_tree(basedir, files)
|
||||
if dirty:
|
||||
restore_version()
|
||||
|
||||
|
@ -213,11 +213,30 @@ class install_scripts_quoted_shebang(install_scripts):
|
|||
contents = contents.replace(shebang, quoted_shebang)
|
||||
super().write_script(script_name, contents, mode, *ignored)
|
||||
|
||||
|
||||
class install_scripts_rewrite(install_scripts):
|
||||
"""Rewrite python3 to the current python executable"""
|
||||
def run(self):
|
||||
super().run()
|
||||
if os.name == 'posix' and not self.dry_run:
|
||||
for file in self.get_outputs():
|
||||
if file.endswith('xon.sh'):
|
||||
bs_cmd = self.get_finalized_command('build_scripts')
|
||||
exec_param = getattr(bs_cmd, 'executable', None)
|
||||
|
||||
with open(file, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
processed = content.replace(' python3 ', ' {} '.format(exec_param))
|
||||
|
||||
with open(file, 'w') as f:
|
||||
f.write(processed)
|
||||
|
||||
# The custom install needs to be used on Windows machines
|
||||
if os.name == 'nt':
|
||||
cmdclass = {'install': xinstall, 'sdist': xsdist, 'install_scripts': install_scripts_quoted_shebang}
|
||||
else:
|
||||
cmdclass = {'install': xinstall, 'sdist': xsdist}
|
||||
cmdclass = {'install': xinstall, 'sdist': xsdist, 'install_scripts': install_scripts_rewrite}
|
||||
|
||||
|
||||
if HAVE_SETUPTOOLS:
|
||||
|
@ -231,6 +250,11 @@ if HAVE_SETUPTOOLS:
|
|||
if dirty:
|
||||
restore_version()
|
||||
|
||||
def install_script(self, dist, script_name, script_text, dev_path=None):
|
||||
if script_name == 'xon.sh':
|
||||
script_text = script_text.replace(' python3 ', ' {} '.format(sys.executable))
|
||||
super().install_script(dist, script_name, script_text, dev_path)
|
||||
|
||||
|
||||
def main():
|
||||
"""The main entry point."""
|
||||
|
|
Loading…
Add table
Reference in a new issue