Python 3.4 编译器?
自从我开始学习Python以来,我就想把自己做的一些小程序分享给朋友,但不想把我的源代码给他们。我的问题是,Python 3.4有哪些编译器?我听说过cx_freeze并试过,但对我来说不太好用。我在Windows上,它却把我的代码编译成了Mac用的。有没有什么编译器推荐,或者怎么编译呢?
请注意:我还是Python的初学者,对这门语言和它的工作原理了解得不多。
1 个回答
0
看看这个页面,它应该能回答你的问题。
https://wiki.python.org/moin/DistributionUtilities
INNO是一种比较直接的方法,可以确保所有需要的Python文件都被安装。INNO的界面看起来像是Windows用户熟悉的传统安装程序。
这是INNO的链接:http://www.jrsoftware.org/isinfo.php
下面是一个INNO脚本,它会先安装Python,然后再安装你的Python脚本。显然,你需要根据自己的系统调整路径,并且需要下载python-x.y.z.msi文件。
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "PythonTest"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "PythonTest.py"
[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={{72A57135-5C83-4A70-83F6-965EBE7DA65C}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\engineering12\Desktop\PythonTest.py"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\engineering12\Downloads\python-2.7.8.msi"; DestDir: "{app}"; Flags: nocompression
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{app}\python-2.7.8.msi"""
这是脚本PythonTest.py:
import time
for i in range(100):
print i
time.sleep(2)
INNO会生成一个叫做setup.exe的文件,你可以把它发给你的朋友。你的Python脚本会在开始菜单中可用。