Skip to content

Commit

Permalink
Merge pull request #171 from ThrunGroup/pspace_gradient_hotfix
Browse files Browse the repository at this point in the history
Hotfix: fixing installation on paperspace gradient and google colab
  • Loading branch information
motiwari authored Jan 8, 2022
2 parents 05a303b + 7c99fbf commit 91f386d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# We need this for the sdist uploaded to PyPI to include the headers
graft headers
include docs/long_desc.rst
47 changes: 44 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import distutils.sysconfig
import distutils.spawn

__version__ = "3.0.0"
__version__ = "3.0.1"


class get_pybind_include(object):
Expand Down Expand Up @@ -191,6 +191,23 @@ def check_linux_package_installation(pkg_name: str):
)
return output.decode().strip()

def install_ubuntu_pkgs():
# TODO: Remove dangerous os.system() calls
# See https://stackoverflow.com/a/51329156
os.system('apt update')
os.system('apt install -y \
build-essential \
checkinstall \
libreadline-gplv2-dev \
libncursesw5-dev \
libssl-dev \
libsqlite3-dev \
libgdbm-dev \
libc6-dev \
libbz2-dev \
libffi-dev \
zlib1g-dev'
)

def setup_colab():
# If we're in Google Colab, we need to manually copy over
Expand All @@ -203,16 +220,38 @@ def setup_colab():
in_colab = False

if in_colab:
# TODO: Dangerous os.system() call.
# TODO: Remove dangerous os.system() calls
# See https://stackoverflow.com/a/51329156
install_ubuntu_pkgs()
repo_location = os.path.join("/", "content", "BanditPAM")
os.system('git clone https://github.com/ThrunGroup/BanditPAM.git' +
# Note the space after the git URL to separate the source and target
os.system('git clone https://github.com/ThrunGroup/BanditPAM.git ' +
repo_location)
os.system(repo_location +
'/scripts/colab_files/colab_install_armadillo.sh')
os.system('rm -rf ' + repo_location)


def setup_paperspace_gradient():
# Unfortunately, Paperspace Gradient does not make it easy to tell
# whether you're inside a Gradient instance. For this reason, we
# determine whether python is running inside a Gradient instance
# by checking for a /notebooks directory

# TODO: Remove dangerous os.system() calls
# See https://stackoverflow.com/a/51329156

in_paperspace_gradient = os.path.exists('/notebooks')

if in_paperspace_gradient:
install_ubuntu_pkgs()
os.system('DEBIAN_FRONTEND=noninteractive TZ=America/NewYork \
apt install -y tk-dev')
os.system('git clone \
https://gitlab.com/conradsnicta/armadillo-code.git')
os.system('cd armadillo-code && cmake . && make install')


def install_check_ubuntu():
# Make sure linux packages are installed
dependencies = [
Expand All @@ -232,6 +271,8 @@ def install_check_ubuntu():

setup_colab()

setup_paperspace_gradient()

for dep in dependencies:
check_linux_package_installation(dep)

Expand Down

0 comments on commit 91f386d

Please sign in to comment.