首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Inno安装程序的Python分发模块

使用Inno安装程序的Python分发模块
EN

Stack Overflow用户
提问于 2013-04-22 22:19:39
回答 1查看 942关注 0票数 2

我使用Inno安装程序而不是Python发布Python库是否可行?我说的是distutils Windows安装程序。如果是这样的话,是怎么做的?模块位于https://code.google.com/p/mathworks/

编辑:我在谷歌上取得了一些进展。这是我的安装脚本,但它无法定位Python。也许有人能帮忙。

代码语言:javascript
运行
复制
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{3B6685C2-D478-4410-B973-57FA36A6DA6D}
AppName=Mathworks
AppVersion=1.3
;AppVerName=Mathworks 1.3
AppPublisherURL=https://code.google.com/p/mathworks/
AppSupportURL=https://code.google.com/p/mathworks/
AppUpdatesURL=https://code.google.com/p/mathworks/
DefaultDirName={code:GetDirName}
DisableDirPage=yes
DefaultGroupName=My Program
DisableProgramGroupPage=yes
LicenseFile=C:\Users\Ryan\Documents\mathworks-git\LICENSE_1_0.txt
OutputDir=C:\Users\Ryan\Desktop
OutputBaseFilename=mathworks-mwver
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "C:\Users\Ryan\Documents\mathworks-git\__init__.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\exponent.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\LICENSE_1_0.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\multiples.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\ptheorem.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\shapes.py"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Code]
var CancelWithoutPrompt: boolean;

function InitializeSetup() : Boolean;
begin
  CancelWithoutPrompt := false;
  result := true;
end;

function GetDirName(Value: string): string;
var          
  InstallPath: string;
begin
  if RegQueryStringValue(HKLM, 'SOFTWARE\Python\PythonCore\2.7\InstallPath', '(Default)', InstallPath) then
    BEGIN
    Result := InstallPath
  END else
  if RegQueryStringValue(HKCU, 'SOFTWARE\Python\PythonCore\2.7\InstallPath', '(Default)', InstallPath) then
    BEGIN
    Result := InstallPath;
  END else
  if RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Python\PythonCore\2.7', '(Default)', InstallPath) then
    BEGIN
    Result := InstallPath;
  END else
    MsgBox('Could not find Python',mbError,MB_OK);
    CancelWithoutPrompt := true;
    WizardForm.Close;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  if CurPageID=wpInstalling then
    Confirm := not CancelWithoutPrompt;
end;

我从Inno Setup - Setting DefaultDir using wildcard registry entry?Inno Setup: How to Abort/Terminate Setup During Install?那里得到了代码。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-30 21:23:05

我想出来了!我的代码:

代码语言:javascript
运行
复制
#define AppName "Mathworks"
#define AppDir "mathworks"
#define PyVer "2.7"
#define AppVer "1.3:

[Setup]
AppId={{3B6685C2-D478-4410-B973-57FA36A6DA6D}
AppName={#AppName}
AppVersion={#AppVer}
AppVerName=Mathworks {#AppVer}
AppPublisherURL=https://code.google.com/p/mathworks/
AppSupportURL=https://code.google.com/p/mathworks/
AppUpdatesURL=https://code.google.com/p/mathworks/
DefaultDirName={code:GetDirName}
DefaultGroupName={#AppName}
DisableProgramGroupPage=yes
LicenseFile=C:\Users\Ryan\Documents\mathworks-git\LICENSE_1_0.txt
OutputDir=C:\Users\Ryan\Desktop\Inno Setup
OutputBaseFilename=mathworks-{#AppVer}-python-{#PyVer}
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "C:\Users\Ryan\Documents\mathworks-git\__init__.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\exponent.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\LICENSE_1_0.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\multiples.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\ptheorem.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ryan\Documents\mathworks-git\shapes.py"; DestDir: "{app}"; Flags: ignoreversion

[Code]
procedure ExitProcess(exitCode:integer);
  external 'ExitProcess@kernel32.dll stdcall';

function GetDirName(Value: string): string;
var          
  InstallPath: string;
  reg1 : string;
  reg2 : string;
begin
  reg1 := 'SOFTWARE\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
  reg2 := 'SOFTWARE\Python\PythonCore\Wow6432Node\' + '{#PyVer}' + '\InstallPath';
  if RegQueryStringValue(HKLM, reg1, '', InstallPath) then
    BEGIN
    Result := InstallPath + 'Lib\site-packages\' + '{#AppDir}';
  END else
  if RegQueryStringValue(HKCU, reg1, '', InstallPath) then
    BEGIN
    Result := InstallPath + 'Lib\site-packages\' + '{#AppDir}';
  END else
  if RegQueryStringValue(HKLM, reg2, '', InstallPath) then
    BEGIN
    Result := InstallPath + 'Lib\site-packages\' + '{#AppDir}';
  END else
    BEGIN
    MsgBox('Could not find Python',mbError,MB_OK);
    ExitProcess(1);
   END
end;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16157700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档