Skip to content

Conversation

@Dimi20cen
Copy link
Contributor

Summary

This pull request introduces a set of changes to enhance the development and build process for the kolibri-app, with a strong focus on improving Windows compatibility and clarifying the developer documentation.

The changes are as follows:

Makefile:

  • Standardized Python Interpreter: Introduced a PYTHON_EXEC variable to dynamically use python on Windows and python3 on Unix-like systems, eliminating windows command failures.
  • Robust Wheel Downloading: The get-whl target has been refactored to be more reliable. It now uses simplified filename extraction using basename to get the filename from the URL and sed to remove query parameters. wget now downloads directly to this precalculated clean path using the -O option.
  • Windows UnicodeEncodeError Fix: Resolved a UnicodeEncodeError on Windows during the make loading-pages step by forcing Python to use UTF-8 mode via the -X utf8 flag.
  • Corrected PYTHONPATH Handling: Implemented OS-aware PYTHONPATH logic for loading-pages and run-dev targets. This ensures that modules from kolibrisrc and local app code from src are correctly discovered on both Windows (using semicolons) and Unix-like systems (using colons).

README.md:
Has been updated to improve ease of use for developers

  • Platform support was clarified to specify "Windows (Git Bash)".
  • wget has been added as a requirement for downloading Kolibri wheels , with a suggested source for Windows users.
  • The guide is now organized into clearer, more logical sections, including "Development Environment Setup" , "Build the Application" , and a dedicated section for "Running from Source".
  • The process for finding the whl URL is now clear.

Manual Verification:
These changes have been manually tested on:

  • OS: Windows 11
  • Environment: Git Bash with a venv virtual environment
  • Python: 3.10

The following commands were successfully executed: make dependencies, make get-whl, make pyinstaller, and make run-dev.

Additionally, the build_mac.yml workflow was used to ensure that these changes did not introduce any issues for the macOS build process.

References

This PR fixes #155

Reviewer guidance

To test the updated Makefile, please use the updated README.md

Dimi20cen and others added 2 commits June 7, 2025 10:02
- Standardized Python interpreter usage via `PYTHON_EXEC` for cross-platform builds.
- Addressed Windows-specific issues:
    - Fixed `UnicodeEncodeError` by enabling Python's UTF-8 mode.
    - Ensured correct module and asset discovery through robust `PYTHONPATH` handling (e.g., `./src`, `./kolibrisrc`).
- Improved `get-whl` target logic for more reliable wheel downloads.
get-whl: clean-whl
# The eval and shell commands here are evaluated when the recipe is parsed, so we put the cleanup
# into a prerequisite make step, in order to ensure they happen prior to the download.
$(eval DLFILE = $(shell wget --content-disposition -P whl/ "${whl}" 2>&1 | grep "Saving to: " | sed 's/Saving to: ‘//' | sed 's/’//'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flagging that we've lost something in the refactor here - this currently deliberately uses the --content-disposition flag in order to save the file with wget using the content disposition header, when available.

An alternative to this refactor would be to invoke the original recipe if not on Windows, and use this powershell recipe otherwise: https://github.com/learningequality/kolibri-installer-windows/blob/main/.github/workflows/build_exe.yml#L82

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So -O flag here wget --content-disposition -O "$(OUTPUT_PATH)" "$(whl)" would override the output filename and defeat the purpose of --content-disposition flag right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the --content-disposition, since currently it's not needed.

Makefile Outdated
PYTHONPATH=$$PYTHONPATH:./kolibrisrc python3 -m kolibri manage loadingpage --output-dir src/kolibri_app/assets --version-text "${KOLIBRI_VERSION}-${APP_VERSION}"
# -X utf8 ensures Python uses UTF-8 for I/O, fixing UnicodeEncodeError on Windows.
ifeq ($(OS),Windows_NT)
PYTHONPATH="./kolibrisrc;%PYTHONPATH%" $(PYTHON_EXEC) -X utf8 -m kolibri manage loadingpage --output-dir src/kolibri_app/assets --version-text "${KOLIBRI_VERSION}-${APP_VERSION}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be overkill but we could consider defining a PYTHONPATH_BASE variable at the top of the Makefile based on the OS (similar to how PYTHON_EXEC is set). That way, we avoid repeating PYTHONPATH="./kolibrisrc:$$PYTHONPATH" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, seems like a good idea, I'll do it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could even do it as PYTHON_EXEC_WITH_PATH, as we only need PYTHONPATH in the context of executing Python - with the PYTHON_EXEC_WITH_PATH being:

PYTHONPATH="./kolibrisrc;%PYTHONPATH%" $(PYTHON_EXEC)

on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduced the PYTHON_EXEC_WITH_PATH variable as rtibbles said.

Copy link
Member

@ozer550 ozer550 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from adding some more instructions around wget that we talked about, everything seems to be working as expected! Nice work.

@rtibbles
Copy link
Member

Build still builds, and dmg file is correctly named, so I have no concerns here!

@rtibbles rtibbles merged commit 8546096 into learningequality:main Jun 24, 2025
4 checks passed
@Dimi20cen Dimi20cen deleted the makefile_readme branch July 2, 2025 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Win11] Installation Issues & Fixes for Kolibri: Makefile Errors, Python Path, and Encoding

3 participants