Esempio n. 1
0
    def test_egginst_script_untouched(self):
        """
        Ensure we don't touch a script which has already been written by
        egginst.
        """
        simple_script = """\
#!/home/davidc/src/enthought/enstaller/.env/bin/python
# This script was created by egginst when installing:
#
#   enstaller-4.6.3.dev1-py2.7.egg
#
if __name__ == '__main__':
    import sys
    from enstaller.patch import main

    sys.exit(main())
"""

        with mkdtemp() as d:
            path = op.join(d, "script")
            with open(path, "wt") as fp:
                fp.write(simple_script)

            fix_script(path)

            with open(path, "rt") as fp:
                self.assertEqual(fp.read(), simple_script)
Esempio n. 2
0
    def test_egginst_script_untouched(self):
        """
        Ensure we don't touch a script which has already been written by
        egginst.
        """
        simple_script = """\
#!/home/davidc/src/enthought/enstaller/.env/bin/python
# This script was created by egginst when installing:
#
#   enstaller-4.6.3.dev1-py2.7.egg
#
if __name__ == '__main__':
    import sys
    from enstaller.patch import main

    sys.exit(main())
"""

        with mkdtemp() as d:
            path = os.path.join(d, "script")
            with open(path, "wt") as fp:
                fp.write(simple_script)

            fix_script(path)

            with open(path, "rt") as fp:
                self.assertEqual(fp.read(), simple_script)
Esempio n. 3
0
    def test_setuptools_script_fixed(self):
        """
        Ensure a script generated by setuptools is fixed.
        """
        setuptools_script = """\
#!/dummy_path/.env/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'enstaller==4.6.3.dev1','console_scripts','enpkg'
__requires__ = 'enstaller==4.6.3.dev1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('enstaller==4.6.3.dev1', 'console_scripts', 'enpkg')()
    )
"""
        if sys.platform == "win32":
            quoted_executable = '"' + sys.executable + '"'
        else:
            quoted_executable = sys.executable
        r_egginst_script = """\
#!{executable}
# EASY-INSTALL-ENTRY-SCRIPT: 'enstaller==4.6.3.dev1','console_scripts','enpkg'
__requires__ = 'enstaller==4.6.3.dev1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('enstaller==4.6.3.dev1', 'console_scripts', 'enpkg')()
    )
""".format(executable=quoted_executable)

        with mkdtemp() as d:
            path = os.path.join(d, "script")
            with open(path, "wt") as fp:
                fp.write(setuptools_script)

            fix_script(path, sys.executable)

            with open(path, "rt") as fp:
                self.assertMultiLineEqual(fp.read(), r_egginst_script)
Esempio n. 4
0
    def test_setuptools_script_fixed(self):
        """
        Ensure a script generated by setuptools is fixed.
        """
        setuptools_script = """\
#!/dummy_path/.env/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'enstaller==4.6.3.dev1','console_scripts','enpkg'
__requires__ = 'enstaller==4.6.3.dev1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('enstaller==4.6.3.dev1', 'console_scripts', 'enpkg')()
    )
"""
        if sys.platform == "win32":
            executable = '"' + sys.executable + '"'
        else:
            executable = sys.executable
        r_egginst_script = """\
#!{executable}
# EASY-INSTALL-ENTRY-SCRIPT: 'enstaller==4.6.3.dev1','console_scripts','enpkg'
__requires__ = 'enstaller==4.6.3.dev1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('enstaller==4.6.3.dev1', 'console_scripts', 'enpkg')()
    )
""".format(executable=executable)

        with mkdtemp() as d:
            path = os.path.join(d, "script")
            with open(path, "wt") as fp:
                fp.write(setuptools_script)

            fix_script(path)

            with open(path, "rt") as fp:
                self.assertMultiLineEqual(fp.read(), r_egginst_script)