浏览代码

Merge pull request #200 from takluyver/cmd-installdir

Fix locating installdir in command wrappers
Thomas Kluyver 4 年之前
父节点
当前提交
51fe9a7c50
共有 3 个文件被更改,包括 7 次插入3 次删除
  1. 1 1
      nsist/commands.py
  2. 1 1
      nsist/tests/console_example/installer.cfg
  3. 5 1
      nsist/tests/test_main.py

+ 1 - 1
nsist/commands.py

@@ -8,7 +8,7 @@ from zipfile import ZipFile
 SCRIPT_TEMPLATE = u"""# -*- coding: utf-8 -*-
 SCRIPT_TEMPLATE = u"""# -*- coding: utf-8 -*-
 import sys, os
 import sys, os
 import site
 import site
-installdir = os.path.dirname(os.path.dirname(__file__))
+installdir = os.path.dirname(os.path.dirname(sys.executable))
 pkgdir = os.path.join(installdir, 'pkgs')
 pkgdir = os.path.join(installdir, 'pkgs')
 sys.path.insert(0, pkgdir)
 sys.path.insert(0, pkgdir)
 # Ensure .pth files in pkgdir are handled properly
 # Ensure .pth files in pkgdir are handled properly

+ 1 - 1
nsist/tests/console_example/installer.cfg

@@ -6,7 +6,7 @@ entry_point=sample_printer:main
 console=true
 console=true
 
 
 [Python]
 [Python]
-version=3.6.3
+version=3.8.3
 bitness=64
 bitness=64
 format=bundled
 format=bundled
 
 

+ 5 - 1
nsist/tests/test_main.py

@@ -82,15 +82,19 @@ def test_installer(console_eg_copy, tmp_path):
     res = run([str(inst_python), str(inst_launch_script)],
     res = run([str(inst_python), str(inst_launch_script)],
               check=True, stdout=PIPE)
               check=True, stdout=PIPE)
     json_res = json.loads(res.stdout.decode('utf-8', 'replace'))
     json_res = json.loads(res.stdout.decode('utf-8', 'replace'))
+    print(res.stdout.decode('utf-8', 'replace'))
 
 
     assert json_res['py_executable'] == str(inst_python)
     assert json_res['py_executable'] == str(inst_python)
-    assert json_res['py_version'].startswith('3.6.3')  # Set in installer.cfg
+    assert json_res['py_version'].startswith('3.8.3')  # Set in installer.cfg
     assert json_res['data_file_path'].endswith('data.txt')
     assert json_res['data_file_path'].endswith('data.txt')
     assert json_res['data_file_content'] == 'newt'
     assert json_res['data_file_content'] == 'newt'
 
 
     # Run through command-line wrapper
     # Run through command-line wrapper
     res2 = run([str(inst_exe_wrapper)], check=True, stdout=PIPE)
     res2 = run([str(inst_exe_wrapper)], check=True, stdout=PIPE)
+    print("Command line wrapper -----------------------------------------")
+    print(res2.stdout.decode('utf-8', 'replace'))
     json_res2 = json.loads(res2.stdout.decode('utf-8', 'replace'))
     json_res2 = json.loads(res2.stdout.decode('utf-8', 'replace'))
+
     assert json_res2 == json_res
     assert json_res2 == json_res
 
 
     # Check command-line wrapper is on PATH
     # Check command-line wrapper is on PATH