Skip to content

Commit

Permalink
fix: (re)Install every Frappe app even if not installed to env
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Jun 16, 2022
1 parent 39553b3 commit ffae670
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
32 changes: 12 additions & 20 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ def reload(self, web=False, supervisor=True, systemd=True):
def get_installed_apps(self) -> List:
"""Returns list of installed apps on bench, not in excluded_apps.txt
"""
apps = [app for app in self.apps if app not in self.excluded_apps]
apps.remove("frappe")
apps.insert(0, "frappe")
return apps
try:
installed_packages = get_cmd_output(f"{self.python} -m pip freeze", cwd=self.name)
except Exception:
installed_packages = []
is_installed = lambda app: app in installed_packages

return [app for app in self.apps if app not in self.excluded_apps and is_installed(app)]


class BenchApps(MutableSequence):
Expand Down Expand Up @@ -262,23 +265,14 @@ def sync(
)

def initialize_apps(self):
is_installed = lambda app: app in installed_packages

try:
installed_packages = get_cmd_output(f"{self.bench.python} -m pip freeze", cwd=self.bench.name)
except Exception:
self.apps = []
return

try:
self.apps = [
x
for x in os.listdir(os.path.join(self.bench.name, "apps"))
if (
is_frappe_app(os.path.join(self.bench.name, "apps", x))
and is_installed(x)
)
if is_frappe_app(os.path.join(self.bench.name, "apps", x))
]
self.apps.remove("frappe")
self.apps.insert(0, "frappe")
except FileNotFoundError:
self.apps = []

Expand Down Expand Up @@ -438,8 +432,7 @@ def requirements(self, apps=None):
"""
from bench.app import App

if not apps:
apps = self.bench.get_installed_apps()
apps = apps or self.bench.apps

self.pip()

Expand All @@ -456,8 +449,7 @@ def python(self, apps=None):
"""
import bench.cli

if not apps:
apps = self.bench.get_installed_apps()
apps = apps or self.bench.apps

quiet_flag = "" if bench.cli.verbose else "--quiet"

Expand Down
3 changes: 1 addition & 2 deletions bench/utils/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def update_yarn_packages(bench_path=".", apps=None):

bench = Bench(bench_path)

if not apps:
apps = bench.get_installed_apps()
apps = apps or bench.apps

apps_dir = os.path.join(bench.name, "apps")

Expand Down

0 comments on commit ffae670

Please sign in to comment.