Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating windows installer for 0.17 #427

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions windows/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@

# Compiled executable
KALiteSetup.exe

# KA Lite source folder
ka-lite/
7 changes: 3 additions & 4 deletions windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ To build in Linux, first install `wine`. These directions assume you're building
skip using msys and use bash instead.

* Clone this repository;
* Clone `ka-lite` repository from https://github.com/learningequality/ka-lite to this directory.
* Download ka-lite-static sdist zipfile from https://pypi.python.org/pypi/ka-lite-static/ to this directory.
* Download ka-lite-static sdist whl file from https://pypi.python.org/pypi/ka-lite-static/ to this directory.
* Download the English content pack `en.zip` file to this directory. Look for it in [the pantry](http://pantry.learningequality.org/downloads/).
* Set the environment variable KALITE_BUILD_VERSION to the desired version for the installer, e.g. `0.16.0`.
This should match the version in the sdist *exactly*, so `ka-lite-static-0.17.3` means that `KALITE_BUILD_VERSION`
Expand Down Expand Up @@ -65,11 +64,11 @@ After adding both binaries to your path, you're ready to run `npm install` in th
---
### Build server instructions
Our bamboo build server basically follows the above instructions. The primary difference is that instead of getting
a KA Lite sdist from PyPI, we build it ourselves in .zip format instead of .tar.gz format, using the following
a KA Lite sdist from PyPI, we build it ourselves in .whl format instead of .tar.gz format, using the following
make directive in the ka-lite base directory:

```
> make dist format=zip
> make dist
```

Additionally, you *must* update the value of the `KALITE_BUILD_VERSION` environment variable that the build server
Expand Down
80 changes: 55 additions & 25 deletions windows/installer-source/KaliteSetupScript.iss
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "..\ka-lite-static-*.zip"; DestDir: "{app}\ka-lite"
Source: "..\ka_lite_static-*.whl"; DestDir: "{app}\ka-lite"
Source: "..\en.zip"; DestDir: "{app}"
Source: "..\scripts\*.bat"; DestDir: "{app}\ka-lite\scripts\"
Source: "..\gui-packed\KA Lite.exe"; DestDir: "{app}"; Flags: ignoreversion
Expand Down Expand Up @@ -79,6 +79,7 @@ var
restoreDatabaseTemp : integer;
forceCancel : boolean;


procedure InitializeWizard;
begin
isUpgrade := False;
Expand All @@ -90,7 +91,7 @@ begin
ShellExec('open', 'tskill.exe', '"KA Lite"', '', SW_HIDE, ewWaitUntilTerminated, stopServerCode);
Exec(ExpandConstant('{cmd}'),'/C ka-lite\bin\windows\kalite.bat stop', WizardForm.PrevAppDir, SW_HIDE, ewWaitUntilTerminated, stopServerCode);
Exec(ExpandConstant('{cmd}'),'/C del winshortcut.vbs', WizardForm.PrevAppDir, SW_HIDE, ewWaitUntilTerminated, removeOldGuiTool);
end;
end;

// Server data
ServerInformationPage := CreateInputQueryPage(wpSelectDir,
Expand Down Expand Up @@ -314,42 +315,62 @@ begin
end;
end;

{REF: http://stackoverflow.com/questions/4438506/exit-from-inno-setup-instalation-from-code}
procedure ExitProcess(uExitCode: Integer);
external '[email protected] stdcall';

procedure HandlePythonSetup;
var
installPythonErrorCode : Integer;
begin
if(MsgBox('Python 2.7.9+ is required to install KA Lite on Windows; do you wish to first install Python 2.7.10, before continuing with the installation of KA Lite?', mbConfirmation, MB_YESNO) = idYes) then
begin
ExtractTemporaryFile('python-2.7.10.msi');
ShellExec('open', ExpandConstant('{tmp}')+'\python-2.7.10.msi', '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, installPythonErrorCode);
end
else begin
MsgBox('Error' #13#13 'You must have Python 2.7.9+ installed to proceed! Installation will now exit.', mbError, MB_OK);
forceCancel := True;
WizardForm.Close;
end;
if(MsgBox('KA Lite requires Python to be installed on your system.' + #13#10 + 'This wizard will proceed to install Python 2.7.12, and then continue with KA Lite installation.' + #13#10 + #13#10 + 'Click OK to continue.', mbConfirmation, MB_OKCANCEL) = idCancel) then
if(MsgBox('Are you sure you want to cancel the installation of Python 2.7.12?' + #13#10 + 'If you select Yes, this installer will close and KA Lite will not be installed on your system.', mbConfirmation, MB_YESNO) = idYes) then
begin
forceCancel := True;
ExitProcess(1);
end
else begin
HandlePythonSetup();
exit;
end
else
ExtractTemporaryFile('python-2.7.12.msi');
ExtractTemporaryFile('python-2.7.12.amd64.msi');
ExtractTemporaryFile('python-exe.bat');
ShellExec('open', ExpandConstant('{tmp}')+'\python-exe.bat', '', '', SW_HIDE, ewWaitUntilTerminated, installPythonErrorCode);
end;

{ Used in GetPipPath below }
const
DEFAULT_PATH = '\Python27\Scripts\pip.exe';
DEFAULT_PIP_PATH = '\Python27\Scripts\pip.exe';
DEFAULT_PYTHON_PATH = '\Python27\python.exe';

{ Returns the path of pip.exe on the system. }
{ Tries several different locations before prompting user. }
function GetPipPath: string;
var
kalitePythonEnv: string;
path : string;
i : integer;
begin
for i := Ord('C') to Ord('H') do
begin
path := Chr(i) + ':' + DEFAULT_PATH;
kalitePythonEnv := GetEnv('KALITE_PYTHON');
Log(kalitePythonEnv)
if kalitePythonEnv = '' then
begin
path := DEFAULT_PIP_PATH;
if FileExists(path) then
begin
Result := path;
exit;
end;
end;
end
end
else
begin
if FileExists(kalitePythonEnv) then
Result := ExtractFileDir(kalitePythonEnv) + '\Scripts\pip.exe';
exit;
end

MsgBox('Could not find pip.exe. Please select the location of pip.exe to continue installation.', mbInformation, MB_OK);
if GetOpenFileName('Please select pip.exe', path, '', 'All files (*.*)|*.*', 'exe') then
begin
Expand All @@ -366,21 +387,23 @@ procedure HandlePipSetup;
var
PipCommand: string;
PipPath: string;
pythonPath: string;
checkEnc: string;
ErrorCode: integer;

begin
PipPath := GetPipPath;
PipPath := GetPipPath;
if PipPath = '' then
exit;
PipCommand := 'install "' + ExpandConstant('{app}') + '\ka-lite\ka-lite-static-' + '{#TargetVersion}' + '.zip"';
PipCommand := 'install "' + ExpandConstant('{app}') + '\ka-lite\ka_lite_static-' + '{#TargetVersion}' + '-py2-none-any' + '.whl"';

MsgBox('Setup will now install kalite source files to your Python site-packages.', mbInformation, MB_OK);
if not Exec(PipPath, PipCommand, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
begin
MsgBox('Critical error.' #13#13 'Dependencies have failed to install. Error Number: ' + IntToStr(ErrorCode), mbInformation, MB_OK);
forceCancel := True;
WizardForm.Close;
end;
end

{ Must set this environment variable so the systray executable knows where to find the installed kalite.bat script}
{ Should by in the same directory as pip.exe, e.g. 'C:\Python27\Scripts' }
Expand All @@ -390,6 +413,14 @@ begin
'KALITE_SCRIPT_DIR',
ExtractFileDir(PipPath)
);
pythonPath := ExtractFileDir(ExtractFileDir(PipPath)) + '\python.exe';
FileCopy(ExpandConstant('{app}') + '\ka-lite\scripts\kalite.bat', ExtractFileDir(PipPath) + '\kalite.bat', False);
RegWriteStringValue(
HKLM,
'System\CurrentControlSet\Control\Session Manager\Environment',
'KALITE_PYTHON',
pythonPath
);
end;

function InitializeSetup(): Boolean;
Expand All @@ -406,7 +437,7 @@ begin

RegDeleteValue(HKCU, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', ExpandConstant('{#MyAppName}'));

if ShellExec('open', 'python.exe','-c "import sys; (sys.version_info >= (2, 7, 9,) and sys.version_info < (3,) and sys.exit(0)) or sys.exit(1)"', '', SW_HIDE, ewWaitUntilTerminated, PythonVersionCodeCheck) then
if ShellExec('open', 'python.exe','-c "import sys; (sys.version_info >= (2, 7, 11,) and sys.version_info < (3,) and sys.exit(0)) or sys.exit(1)"', '', SW_HIDE, ewWaitUntilTerminated, PythonVersionCodeCheck) then
begin
if PythonVersionCodeCheck = 1 then
begin
Expand All @@ -419,6 +450,7 @@ begin
end;
end;


function InitializeUninstall(): Boolean;
var
ErrorCode: Integer;
Expand All @@ -435,7 +467,7 @@ var
begin
{ Used to have more responsibility, but we delegated those to the app itself! }
{ Unpacks the English content pack. }
Exec(ExpandConstant('{cmd}'), '/S /C "' + ExpandConstant('"{reg:HKLM\System\CurrentControlSet\Control\Session Manager\Environment,KALITE_SCRIPT_DIR}\kalite.bat"') + ' manage retrievecontentpack local en en.zip --foreground"', ExpandConstant('{app}'), SW_SHOW, ewWaitUntilTerminated, retCode);
Exec(ExpandConstant('{cmd}'), '/S /C "' + ExpandConstant('"{reg:HKLM\System\CurrentControlSet\Control\Session Manager\Environment,KALITE_SCRIPT_DIR}\kalite.bat"') + ' manage retrievecontentpack local en en.zip --foreground"', ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, retCode);
end;

procedure CurStepChanged(CurStep: TSetupStep);
Expand Down Expand Up @@ -496,8 +528,6 @@ begin
if installFlag then
begin
HandlePipSetup();

if Not forceCancel then
begin
DoSetup;
end;
Expand Down
66 changes: 66 additions & 0 deletions windows/ka-lite/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
------------------------------------------------------------------------------
For the KA Lite software:
------------------------------------------------------------------------------

Copyright for the KA Lite software, except where otherwise specified in the code or further down in this file, belongs to the Foundation for Learning Equality, Inc. (FLE), and by contributing your code to this project (except where otherwise negotiated), you agree to assign copyright in this code to FLE, to be licensed under the same terms as the rest of the code. The KA Lite codebase is released for use under the open-source MIT license (see http://opensource.org/licenses/MIT):

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


------------------------------------------------------------------------------
For the khan-exercises framework:
------------------------------------------------------------------------------

While the framework is MIT licensed, the exercises are licensed separately under a Creative Commons Attribution/Non-Commercial/Share-Alike License.

See: https://khan-exercises.readthedocs.org/en/latest/#small-print


------------------------------------------------------------------------------
For the Khan Academy content (Perseus exercises):
------------------------------------------------------------------------------
Perseus exercise data is copyright Khan Academy and its partners, and is included here with permission.

For full content license, see: http://www.khanacademy.org/about/tos#7


------------------------------------------------------------------------------
For the Khan Academy content (videos):
------------------------------------------------------------------------------
Unless otherwise indicated, the subset of the Khan Academy videos that are downloadable into KA Lite are released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License (available at http://creativecommons.org/licenses/by-nc-sa/3.0/us/) (the “Creative Commons License”).

For full content license, see: http://www.khanacademy.org/about/tos#7

------------------------------------------------------------------------------
For the Python packages found under "ka-lite/python-packages":
(please alert us to any discrepancies)
------------------------------------------------------------------------------

Under the New BSD license (http://opensource.org/licenses/BSD-3-Clause):
django
django-chronograph
django-annoying
django_extensions
django-faq
GitPython
django-postmark
ifcfg
pyasn1
werkzeug

Under the Simplified BSD license:
dateutil

Under the MIT license:
iso8601

Under the ISC license (http://opensource.org/licenses/isc-license):
requests

Under the ASL license v2 (http://www.apache.org/licenses/LICENSE-2.0.html):
rsa
south
Binary file added windows/python-setup/python-2.7.12.amd64.msi
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions windows/python-setup/python-exe.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off
rem Execute python based on machine architecture.
:Check_Architecture
if /i "%processor_architecture%"=="x86" (
IF NOT DEFINED PROCESSOR_ARCHITEW6432 (
msiexec /i "python-2.7.12.msi"

) ELSE (
msiexec /i "python-2.7.12.amd64.msi"
)
) else (
msiexec /i "python-2.7.12.amd64.msi"
)
10 changes: 10 additions & 0 deletions windows/scripts/kalite.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
set mypath=%~dp0
set pyscript="%mypath%kalite"
set /p line1=<%pyscript%
if "%line1:~0,2%" == "#!" (goto :goodstart)
echo First line of %pyscript% does not start with "#!"
exit /b 1
:goodstart
set py_exe=%line1:~2%
call %py_exe% %pyscript% %*