kivy / kivy/python-for-android

Proposal: Remove Obsolete `biglink` and `liblink` Code Path

Open
#3,193 0 comments 0 reactions 0 assignees View on GitHub
recipe
Dominant language
Python
Stars
8.9k
Forks
2k
Avg merge
12h 20m
Merged PRs (30d)
9

Description

**Summary**

This issue proposes the complete removal of the `biglink` and `liblink` functionality from the python-for-android codebase. This build path appears to be a legacy mechanism that is no longer used in any standard build involving a Python recipe (e.g., `python3`), making it effectively dead code. Its removal would simplify the toolchain, reduce maintenance overhead, and improve clarity for new contributors.

**Reasoning**

The primary evidence for the obsolescence of `biglink` is in `pythonforandroid/build.py`:

```python
# 4) biglink everything
info_main('# Biglinking object files')
if not ctx.python_recipe:
biglink(ctx, arch)
else:
warning(
"Context's python recipe found, "
"skipping biglink (will this work?)"
)
```

1. **The `biglink` Path is Not Executed:** The `biglink()` function is only called if `ctx.python_recipe` is `None`. However, all modern builds are initiated with a `TargetPythonRecipe` (like `python3`), which explicitly sets `ctx.python_recipe`. Therefore, the `if` condition is effectively always false, and the `else` block containing the warning is always executed.

2. **The Modern Build Process Works Differently:** The current, functional build process does not rely on combining all compiled components into a single `libpymodules.so`. Instead, it leverages the standard Python ecosystem approach where each compiled extension (e.g., from Cython or C) is built into its own `.so` file and placed in the `site-packages` directory. The Python interpreter on Android then loads these modules using the standard import mechanism, which is more robust, modular, and aligns with how Python packages are handled on other platforms.

3. **The `(will this work?)` Comment:** The warning `"skipping biglink (will this work?)"` is a historical artifact from when the build system was transitioning to the modern approach. Years of successful builds have definitively answered this question: **Yes, it works without `biglink`.** The modern method is the de facto standard, and the comment itself, while once a valid question, is now a source of confusion.

**Benefits of Removal**

* **Code Simplification:** Removing this legacy path will eliminate a significant amount of complex and now-unnecessary code, including the `biglink()` and `copylibs_function()` in `build.py` and the liblink and biglink tools in tools/.
* **Reduced Maintenance Burden:** Eliminates the need to maintain or debug a code path that is no longer in use.
* **Improved Clarity for Contributors:** New developers will no longer be confused by this obsolete build logic or the historical warning message. This makes the build process easier to understand and contribute to.

This change would be a valuable cleanup, making the python-for-android build system leaner and more aligned with its current, functional architecture. Open to discussion on any potential edge cases where this legacy code might still be triggered, although none are apparent in the standard workflow.

Contributor guide

Open the contributing guide

Research direction

Start in pythonforandroid/build.py by tracing the ctx.python_recipe condition and the referenced biglink and copylibs_function paths. Then inspect the liblink and biglink tools; done means the obsolete code and warning are removed without affecting the modern TargetPythonRecipe build path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.