Skip to content

Commit

Permalink
v_2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
walterverwer committed May 5, 2021
1 parent b3189ff commit d715df5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
18 changes: 18 additions & 0 deletions build/lib/walpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
@git: https://github.com/walterverwer
"""

# Let users know if they're missing any of our hard dependencies
hard_dependencies = ('rpy2')
missing_dependencies = []

for dependency in hard_dependencies:
try:
__import__(dependency)
except ImportError as e:
missing_dependencies.append(f'{dependency}: {e}')

if missing_dependencies:
raise ImportError(
'Unable to import required dependencies:\n' + '\n'.join(missing_dependencies)
)
del hard_dependencies, dependency, missing_dependencies

# Functions in walpy
from .r_importer import r_importer
from .suppress import suppress
from .write_run import write_run
11 changes: 9 additions & 2 deletions build/lib/walpy/r_importer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import walpy
import rpy2.robjects.packages as rpackages
from rpy2.robjects.vectors import StrVector
from walpy import suppress

def r_importer(modules, install_only=[], log=False):
"""
Expand All @@ -25,6 +25,12 @@ def r_importer(modules, install_only=[], log=False):
Returns:
None
"""
if not isinstance(modules, list):
modules = [modules]

if not isinstance(install_only, list):
install_only = [install_only]

# import R's utility package:
utils = rpackages.importr('utils')

Expand All @@ -35,7 +41,8 @@ def r_importer(modules, install_only=[], log=False):
names_to_install = [x for x in packnames if not rpackages.isinstalled(x)]
if len(names_to_install) > 0:
print('Installing:', names_to_install)
utils.install_packages(StrVector(names_to_install),
with walpy.suppress():
utils.install_packages(StrVector(names_to_install),
repos='https://cloud.r-project.org/')
print('Successfully installed:', names_to_install)

Expand Down
Binary file removed dist/walpy-2.0.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/walpy-2.0.1.tar.gz
Binary file not shown.
Binary file added dist/walpy-2.0.2-py3-none-any.whl
Binary file not shown.
Binary file added dist/walpy-2.0.2.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion walpy.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: walpy
Version: 2.0.1
Version: 2.0.2
Summary: General functions
Home-page: https://github.com/walterverwer/walpy
Author: Walter Verwer
Expand Down

0 comments on commit d715df5

Please sign in to comment.