Exemplo n.º 1
0
 def test_custom_executable(self):
     fn = os.path.join(HERE, "dummy-0.1-py27-none-any.whl")
     for executable in "mypython", None:
         dstdir = tempfile.mkdtemp()
         self.addCleanup(shutil.rmtree, dstdir)
         w = Wheel(fn)
         paths = {"prefix": dstdir}
         for key in ("purelib", "platlib", "headers", "scripts", "data"):
             paths[key] = os.path.join(dstdir, key)
         maker = ScriptMaker(None, None)
         maker.variants = set([""])
         maker.executable = executable
         w.install(paths, maker)
         # On Windows there will be an exe file, and on POSIX a text file.
         # The test is structured to not care.
         p = paths["scripts"]
         # there should be just one file in the directory - dummy.py/dummy.exe
         p = os.path.join(p, os.listdir(p)[0])
         with open(p, "rb") as f:
             data = f.read()
         if executable is None:
             expected = fsencode(get_executable())
         else:
             expected = executable.encode("utf-8")
         expected = b"#!" + expected + b" -E"
         if not sysconfig.is_python_build():
             self.assertIn(expected, data)
Exemplo n.º 2
0
 def test_custom_executable(self):
     fn = os.path.join(HERE, 'dummy-0.1-py27-none-any.whl')
     for executable in 'mypython', None:
         dstdir = tempfile.mkdtemp()
         self.addCleanup(shutil.rmtree, dstdir)
         w = Wheel(fn)
         paths = {'prefix': dstdir}
         for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
             paths[key] = os.path.join(dstdir, key)
         maker = ScriptMaker(None, None)
         maker.variants = set([''])
         maker.executable = executable
         w.install(paths, maker)
         # On Windows there will be an exe file, and on POSIX a text file.
         # The test is structured to not care.
         p = paths['scripts']
         # there should be just one file in the directory - dummy.py/dummy.exe
         p = os.path.join(p, os.listdir(p)[0])
         with open(p, 'rb') as f:
             data = f.read()
         if executable is None:
             expected = fsencode(get_executable())
         else:
             expected = executable.encode('utf-8')
         expected = b'#!' + expected + b' -E'
         if not sysconfig.is_python_build():
             self.assertIn(expected, data)
Exemplo n.º 3
0
 def test_custom_executable(self):
     fn = os.path.join(HERE, 'dummy-0.1-py27-none-any.whl')
     for executable in 'mypython', None:
         dstdir = tempfile.mkdtemp()
         self.addCleanup(shutil.rmtree, dstdir)
         w = Wheel(fn)
         paths = {'prefix': dstdir}
         for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
             paths[key] = os.path.join(dstdir, key)
         maker = ScriptMaker(None, None)
         maker.variants = set([''])
         maker.executable = executable
         w.install(paths, maker)
         # On Windows there will be an exe file, and on POSIX a text file.
         # The test is structured to not care.
         p = paths['scripts']
         # there should be just one file in the directory - dummy.py/dummy.exe
         p = os.path.join(p, os.listdir(p)[0])
         with open(p, 'rb') as f:
             data = f.read()
         if executable is None:
             expected = fsencode(get_executable())
         else:
             expected = executable.encode('utf-8')
         expected = b'#!' + expected + b' -E'
         self.assertIn(expected, data)
Exemplo n.º 4
0
 def test_interpreter_args(self):
     executable = fsencode(get_executable())
     options = {'interpreter_args': ['-E', '"foo bar"', 'baz frobozz']}
     self.maker.variants = set([''])
     files = self.maker.make('foo = bar:baz', options=options)
     self.assertEqual(len(files), 1)
     with open(files[0], 'rb') as f:
         shebang_line = f.readline()
     self.assertIn(executable, shebang_line)
     self.assertIn(b' -E "foo bar" baz frobozz', shebang_line)
Exemplo n.º 5
0
 def test_interpreter_args(self):
     executable = fsencode(get_executable())
     options = {
         'interpreter_args': ['-E', '"foo bar"', 'baz frobozz']
     }
     self.maker.variants = set([''])
     files = self.maker.make('foo = bar:baz', options=options)
     self.assertEqual(len(files), 1)
     with open(files[0], 'rb') as f:
         shebang_line = f.readline()
     self.assertIn(executable, shebang_line)
     self.assertIn(b' -E "foo bar" baz frobozz', shebang_line)
Exemplo n.º 6
0
 def test_shebangs(self):
     executable = fsencode(get_executable())
     for fn in ('foo.py', 'script1.py', 'script2.py', 'script3.py',
                'shell.sh'):
         files = self.maker.make(fn)
         self.assertEqual(len(files), 1)
         d, f = os.path.split(files[0])
         self.assertEqual(f, fn)
         self.assertEqual(d, self.maker.target_dir)
         if fn.endswith('.py') and fn != 'foo.py':   # no shebang in foo.py
             with open(files[0], 'rb') as f:
                 first_line = f.readline()
             self.assertIn(executable, first_line)
Exemplo n.º 7
0
 def test_shebangs(self):
     executable = fsencode(get_executable())
     for fn in ('foo.py', 'script1.py', 'script2.py', 'script3.py',
                'shell.sh'):
         files = self.maker.make(fn)
         self.assertEqual(len(files), 1)
         d, f = os.path.split(files[0])
         self.assertEqual(f, fn)
         self.assertEqual(d, self.maker.target_dir)
         if fn.endswith('.py') and fn != 'foo.py':  # no shebang in foo.py
             with open(files[0], 'rb') as f:
                 first_line = f.readline()
             self.assertIn(executable, first_line)