Skip to content

Commit

Permalink
Fix order of package manager operations (#53)
Browse files Browse the repository at this point in the history
* fix order of operations by default and also if with user input

* should have ticked this up a while ago, because a major change happened like a tag ago

* fix typos and patch up the version

* fix logging for ide_setup and remove unused import for env_config

* ticking version up for fix for broken logger in ide_setup

* fix package manager order, so that snap is available for apt

* tick up version for setup

* fix issue where we don't get the package manager per OS

* keep it DRY and fix possible pathing issue with youcompleteme

* tick up version for new changes

* remove unused list comprehension because it's confusing

* changing away from set because this isn't where that needs to be done anyway

* moving brew into the loop with continue for package iteration

* ticking up version for attempted pkg order fix

* fix if 'brew' in pkg_mngrs to be if pkg_mngr == 'brew'. oof

* uptick version

* fixing os.path to path as we already do a from os import path
  • Loading branch information
jessebot authored Nov 5, 2022
1 parent a12d70b commit 919e1e1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion onboardme/config/onboardme_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ package:
Linux:
- brew
- pip3.10
- apt
- snap
- flatpak
- apt
# list of extra existing packages groups to install
groups:
- default
Expand Down
18 changes: 15 additions & 3 deletions onboardme/env_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
from os import getenv, path, uname
# rich helps pretty print everything
from rich.prompt import Confirm
from rich.logging import RichHandler
from .console_logging import print_panel
import yaml
# this is the only logger that needs to updated manually if you are
# troubleshooting. set to logging.DEBUG to see errors


def load_yaml(yaml_config_file=""):
Expand Down Expand Up @@ -87,6 +84,19 @@ def process_steps(steps=[], firewall=False, browser=False):
return result_steps


def sort_pkgmngrs(package_managers_list=[]):
"""
make sure the package managers are in the right order 🤦
"""
final_list = []
package_managers = ['brew', 'pip3.10', 'apt', 'snap', 'flatpak']
for mngr in package_managers:
if mngr in package_managers_list:
final_list.append(mngr)

return final_list


def fill_in_defaults(defaults={}, user_config={}, always_prefer_default=False):
"""
Compares/Combines a default dict and another dict. Prefer default values
Expand Down Expand Up @@ -146,5 +156,7 @@ def process_configs(overwrite=False, repo="", git_branch="", pkg_mngrs=[],
valid_steps = process_steps(final_defaults['steps'][OS[0]],
final_defaults['remote_hosts'])
final_defaults['steps'][OS[0]] = valid_steps
sorted_mngrs = sort_pkgmngrs(final_defaults['package']['managers'][OS[0]])
final_defaults['package']['managers'][OS[0]] = sorted_mngrs

return final_defaults
6 changes: 4 additions & 2 deletions onboardme/ide_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
LICENSE: GNU AFFERO GENERAL PUBLIC LICENSE
"""

import logging as log
from git import Repo, RemoteProgress
from os import path
from pathlib import Path
Expand All @@ -28,7 +29,8 @@ def vim_setup():

# trick to not run youcompleteme init every single time
init_ycm = False
if not path.exists(f'{HOME_DIR}/.vim/plugged/YouCompleteMe/install.py'):
ycm_dir = path.join(HOME_DIR, '.vim/plugged/YouCompleteMe/install.sh')
if not path.exists(ycm_dir):
init_ycm = True

# this is for installing vim-plug
Expand All @@ -48,7 +50,7 @@ def vim_setup():

if init_ycm:
# This is for you complete me, which is a python completion module
subproc(f'{HOME_DIR}/.vim/plugged/YouCompleteMe/install.py')
subproc(ycm_dir)

return True

Expand Down
23 changes: 12 additions & 11 deletions onboardme/pkg_management.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3.10
import logging as log
from os import path

# custom libs
Expand Down Expand Up @@ -57,16 +58,16 @@ def run_pkg_mngrs(pkg_mngrs=[], pkg_groups=[]):
list passed in, only use brew/pip3.10 for mac. Takes optional variable,
pkg_group_lists to install optional packages.
"""
# brew has a special flow with brew files
if 'brew' in pkg_mngrs:
brew_install_upgrade(OS[0], pkg_groups)
pkg_mngrs.remove('brew')

pkg_mngrs_list = load_yaml(f'{PWD}/config/packages.yml')

# just in case we got any duplicates, we iterate through pkg_mngrs as a set
for pkg_mngr in set(pkg_mngrs):
pkg_mngr_dict = pkg_mngrs_list[pkg_mngr]
pkg_mngrs_list_of_dicts = load_yaml(path.join(PWD, 'config/packages.yml'))
log.debug(f"pkg_mngrs: {pkg_mngrs}", extra={"markup": True})

# we iterate through pkg_mngrs which should already be sorted
for pkg_mngr in pkg_mngrs:
# brew has a special flow with "Brewfile"s
if pkg_mngr == 'brew':
brew_install_upgrade(OS[0], pkg_groups)
continue
pkg_mngr_dict = pkg_mngrs_list_of_dicts[pkg_mngr]
pkg_emoji = pkg_mngr_dict['emoji']
msg = f'{pkg_emoji} [green][b]{pkg_mngr}[/b][/] app Installs'
print_header(msg)
Expand All @@ -75,7 +76,7 @@ def run_pkg_mngrs(pkg_mngrs=[], pkg_groups=[]):
pkg_cmds = pkg_mngr_dict['commands']
for pre_cmd in ['setup', 'update', 'upgrade']:
if pre_cmd in pkg_cmds:
subproc([pkg_cmds[pre_cmd]], spinner=False)
subproc([pkg_cmds[pre_cmd]], spinner=False)

# list of actually installed packages
installed_pkgs = subproc([pkg_cmds['list']], quiet=True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def readme():
lic_class],
python_requires='>3.10',
keywords='onboardme, onboarding, desktop-setup, setuptools, development',
version='0.13.12',
version='0.14.8',
project_urls={
'Documentation': 'https://jessebot.github.io/onboardme/onboardme',
'Source': 'http://github.com/jessebot/onboardme',
Expand Down

0 comments on commit 919e1e1

Please sign in to comment.