feat: discover apps from Python environment to reduce dependency on apps.txt#1677
Draft
feat: discover apps from Python environment to reduce dependency on apps.txt#1677
Conversation
…tory - Added _get_installed_packages() to query pip/uv for installed packages - Added _discover_apps_from_env() to find frappe apps in Python environment - Enhanced initialize_apps() to discover apps from both directory and environment - Added caching mechanism with _cached_apps for performance - Cache is invalidated when sync() is called to ensure fresh discovery - Maintains backward compatibility by still writing apps.txt Co-authored-by: ankush <9079960+ankush@users.noreply.github.com>
- Test caching behavior of initialize_apps - Test cache invalidation on sync - Test that new discovery methods exist Co-authored-by: ankush <9079960+ankush@users.noreply.github.com>
- Changed cache storage to use .copy() to prevent reference issues - Changed cache retrieval to return a copy instead of reference - This prevents corruption when self.apps is modified elsewhere Co-authored-by: ankush <9079960+ankush@users.noreply.github.com>
- Added documentation about package name sanitization - Added note about potential command injection in unused method - Clarified that pkg_name comes from pip's JSON output Co-authored-by: ankush <9079960+ankush@users.noreply.github.com>
|
Copilot
AI
changed the title
[WIP] Remove usage of apps.txt for managing installed apps
feat: discover apps from Python environment to reduce dependency on apps.txt
Dec 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The bench system currently relies on manually maintaining
apps.txtto track installed apps. This requires users to understand the bench directory structure and makes the system fragile when apps are installed/removed outside of bench commands.Changes
App Discovery Enhancement
BenchApps.initialize_apps()now discovers apps from both theapps/directory and the Python environmentpip list(oruv pip list) for installed packages, then validates which correspond to frappe apps in the apps directoryis_frappe_app()to filter packages, ensuring only valid frappe apps are detectedPerformance
_cached_appsinstance variable to cache discovery resultssync()to pick up new installationsHelper Methods
_get_installed_packages(): Retrieves installed packages from pip/uv as JSON_discover_apps_from_env(): Filters packages for frappe apps in apps directory_get_app_location_from_env(): Reserved for future editable install detectionBackward Compatibility
apps.txtduringsync()for tools that depend on itExample
Before, apps had to be manually tracked in
sites/apps.txt. Now:The system gracefully handles both discovery methods failing and deduplicates results using a set.
Original prompt
apps.txt#1676💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.