<NME> Makefile.mac
<BEF> ADDFILE
<MSG> Merge remote-tracking branch 'origin/mac_install'

<DFF> @@ -0,0 +1,18 @@
+NAMES = ContinuousComponentModel MultinomialComponentModel State
+SOS = $(foreach name, $(NAMES), $(name).so)
+PYXS = $(foreach name, $(NAMES), $(name).pyx)
+INTERMEDIATE = $(foreach name, $(NAMES), $(name).cpp)
+RUN = state_test.py
+
+all: sos
+
+sos: $(SOS)
+
+$(SOS): $(PYXS)
+	python setup.py build_ext --inplace -I/opt/local/include
+
+clean:
+	rm -rf build $(SOS) $(INTERMEDIATE)
+
+run: all
+	python $(RUN)
\ No newline at end of file

{'commit': 'diff --git a/install_scripts/mac_install/README.md b/install_scripts/mac_install/README.md\nnew file mode 100644\nindex 00000000..ab82c451\n--- /dev/null\n+++ b/install_scripts/mac_install/README.md\n@@ -0,0 +1,37 @@\n+# Mac OSX installation\n+\n+## Notes\n+\n+- Works only on OS 10.7 and 10.8.\n+- Requires XCode with command line utilities\n+- Requires [MacPorts](http://www.macports.org/)\n+- Assumes that MacPorts uses the default directory `/opt/local/`\n+- Uses `bash` instead of default login shell (see below)\n+\n+## Installation Instructions\n+\n+Make the installation script executable\n+\n+     chmod +x mac_install.sh\n+\n+Run the script\n+\n+     ./mac_install.sh\n+\n+Select 1 to install the backend dependencies.\n+This will install all necessary libraries, create a virtual environment, and update `.bashrc`\n+\n+Once this has completed, run the script again and select 2 to compile the code.\n+Any time you wish to compile the code, simply run the script and select 2.\n+\n+There is also the makefile in the `tabular_predDB/cython_code` directory which can be run with\n+\n+\tmake -f Makefile.mac\n+\n+## Running code\n+\n+**At this time all code must be run from bash.**\n+\n+1. Enter a bash session by entering `bash` in terminal.\n+2. To access the virtual environment enter `workon tabular_predDB`\n+3. You are now in the `tabular-predDB` directory and ready to run code!\ndiff --git a/install_scripts/mac_install/compile_cython_mac.sh b/install_scripts/mac_install/compile_cython_mac.sh\nnew file mode 100755\nindex 00000000..73daee9e\n--- /dev/null\n+++ b/install_scripts/mac_install/compile_cython_mac.sh\n@@ -0,0 +1,68 @@\n+#!/bin/bash\n+# compiles the cython code\n+\n+\n+ERR_FILE=osxerrs.out\n+\n+# get the macports directory\n+BOOST_DIR="/opt/local/include"\n+\n+if [ -e "$BOOST_DIR" ]\n+then\n+\techo "Detected default MacPorts include directory at /opt/local/include"\n+else\n+\tif [ -z `which port` ]\n+\tthen\n+\t\techo "MacPorts not detected. "\n+\t\techo "Please install MacPorts from http://www.macports.org/"\n+\telse\n+\t\techo "Detected non-standard MacPorts install."\n+\t\techo "Please enter the full path to your Boost Headers (For default install this is /opt/local/include)"\n+\t\techo -ne "Enter:"\n+\n+\t\tread BOOST_DIR\n+\n+\t\techo " "\n+\n+\t\tif [ -z "$BOOST_DIR" ]\n+\t\tthen\n+\t\t\techo "$BOOST_DIR does not exist."\n+\t\t\texit\n+\t\tfi\n+\tfi\n+fi\n+\n+# source the virtualenvironment script\n+source /usr/local/bin/virtualenvwrapper.sh\n+if [ $? = 1 ]\n+then\n+\techo "failed to source virtualenvwrapper.sh."\n+\techo "Compile failed. Check $ERR_FILE."\n+\texit\n+fi\n+\n+echo -ne "Compiling..."\n+\n+workon tabular_predDB\n+\n+if [ $? = 1 ]\n+then\n+\techo "workon command failed."\n+\techo "Compile failed. Check $ERR_FILE."\n+\texit\n+fi\n+\n+cd cython_code\n+\n+sudo make -f Makefile.mac 1>> /dev/null 2>> $ERR_FILE\n+\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Compile failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+\t# echo "Run Test (y/n)?"\n+\t# read run_test\n+fi\n\\ No newline at end of file\ndiff --git a/install_scripts/mac_install/init_postgres_mac.sh b/install_scripts/mac_install/init_postgres_mac.sh\nnew file mode 100755\nindex 00000000..7df5eaab\n--- /dev/null\n+++ b/install_scripts/mac_install/init_postgres_mac.sh\n@@ -0,0 +1,19 @@\n+#!/bin/bash\n+\n+# not currently working\n+\n+# finish up the macports postgresql install\n+sudo mkdir -p /opt/local/var/db/postgresql92/defaultdb\n+sudo chown -R postgres:postgres /opt/local/var/db/postgresql92/defaultdb\n+sudo su postgres -c \'/opt/local/lib/postgresql92/bin/initdb -D /opt/local/var/db/postgresql92/defaultdb\'\n+\n+# start the server\n+sudo su postgres -c \'/opt/local/lib/postgresql92/bin/postgres -D /opt/local/var/db/postgresql92/defaultdb\'\n+\n+# create a user and a database\n+sudo su postgres -c \'/opt/local/lib/postgresql92/bin/createuser -s sgeadmin\'\n+sudo su postgres -c \'/opt/local/lib/postgresql92/bin/createdb sgeadmin -O sgeadmin\'\n+\n+# Set up postgres SQL\n+sudo su sgeadmin -c \'/opt/local/lib/postgresql92/bin/psql -f ../table_setup.sql\'\n+# sudo su sgeadmin -c \'psql -f table_setup.sql\'\n\\ No newline at end of file\ndiff --git a/install_scripts/mac_install/install_mac_deps.sh b/install_scripts/mac_install/install_mac_deps.sh\nnew file mode 100755\nindex 00000000..450483ed\n--- /dev/null\n+++ b/install_scripts/mac_install/install_mac_deps.sh\n@@ -0,0 +1,246 @@\n+#!/bin/bash\n+#\n+# installs all software dependencies for Mac\n+\n+ERR_FILE=osxerrs.out\n+\n+# the directory tabular-predDB must be renamed to tabular_predDB (\'-\'\' to \'_\')\n+\n+# we should be in ...tabular-predDB/install_scripts/mac_install\n+cd ../../tabular_predDB\n+\n+# We need to install coreutils, because MacOS doesn\'t support readlink -f. \n+# coreutils offers a greadlink (GNU readlink)\n+echo -ne "Installing coreutils. "\n+sudo port install coreutils 1>> /dev/null 2> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of coreutils failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+################################################################################\n+# Install misc requirements\n+################################################################################\n+echo -ne "Installing libpng. "\n+sudo port install libpng 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Installation of libpng failed. Check $ERR_FILE.\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+echo -ne "Installing freetype. "\n+sudo port install freetype 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of freetype failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+# echo -ne "Installing postgres. "\n+# sudo port install postgresql92 1>> /dev/null 2>> $ERR_FILE\n+# if [ $? = 1 ]\n+# then\n+# \techo Failed.\n+# \techo "Installation of postgres failed. Check $ERR_FILE."\n+# \texit\n+# else\n+# \techo "done."\n+# fi\n+\n+# echo -ne "Installing postgres server. "\n+# sudo port install postgresql92-server 1>> /dev/null 2>> $ERR_FILE\n+# if [ $? = 1 ]\n+# then\n+# \techo Failed.\n+# \techo "Installation of postgres server failed. Check $ERR_FILE."\n+# \texit\n+# else\n+# \techo "done."\n+# fi\n+\n+echo -ne "Installing valgrind. "\n+sudo port install valgrind 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of valgrind failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+# # Python requirements\n+# pip_dir=`which pip`\n+# if [[ -z "$pip_dir" ]]\n+# then\n+# \techo -ne "Installing pip."\n+# \tsudo easy_install pip 1>> /dev/null 2>> $ERR_FILE\n+# \tif [ $? = 1 ]\n+# \tthen\n+# \t\techo Failed.\n+# \t\techo Installation of pip failed. Check $ERR_FILE.\n+# \t\texit\n+# \telse\n+# \t\techo "done."\n+# \tfi\n+# fi\n+\n+# set up the virtual environment\n+echo \n+echo "Setting up virtual environment (Python)..."\n+echo -ne "Installing virtual environment. "\n+sudo pip install virtualenv 1>> /dev/null 2>> $ERR_FILE && sudo pip install virtualenvwrapper 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of virtualenv failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+\techo " "\n+fi\n+\n+################################################################################\n+# install Boost \n+################################################################################\n+echo -ne "Installing boost. "\n+sudo port install boost 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of Boost failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+################################################################################\n+# set up the virtual environment stuff\n+################################################################################\n+\n+# get the current user and make a working directory\n+\n+USER_HOME=$HOME\n+WORKING=$USER_HOME/.virtualenvs\n+PYTHONDIR="$(dirname `pwd`)"\n+\n+project_name=tabular_predDB\n+wrapper_script=/usr/local/bin/virtualenvwrapper.sh\n+\n+# START: POACHED CODE\n+# The following snippet poached from the original virtualenv_setup.sh\n+# script:\n+# ensure virtualenvwrapper is loaded\n+\n+# make sure that .bashrc exists, if it doesn\'t make it\n+if [ -z ${USER_HOME}/.bashrc ]\n+then\n+\techo "No .bashrc found. Creating one."\n+\ttouch ${USER_HOME}/.bashrc\n+fi\n+\n+if [[ -z $(grep WORKON_HOME ${USER_HOME}/.bashrc) ]]; then\n+    cat -- >> ${USER_HOME}/.bashrc <<EOF\n+export PYTHONPATH=${PYTHONPATH}:${USER_HOME}:$PYTHONDIR\n+export WORKON_HOME=$WORKING\n+source $wrapper_script\n+EOF\n+fi\n+\n+source ${USER_HOME}/.bashrc\n+\n+# ensure requirements in virtualenv $project_name\n+has_project=$(workon | grep $project_name)\n+if [[ -z $has_project ]] ; then\n+    # readlink -f is not an option on macs so we have to use\n+    # coreutils greadlink as mentione above -Bax\n+    my_abs_path=$(greadlink -f "$0")\n+    project_location=$(dirname $my_abs_path)\n+    mkvirtualenv $project_name\n+    cdvirtualenv\n+    echo "cd $project_location" >> bin/postactivate\n+    deactivate\n+    workon $project_name\n+fi\n+\n+echo -ne "Installing cython. "\n+sudo pip install cython==0.17.1 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of cython failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+echo -ne "Installing numpy. "\n+sudo pip install numpy==1.7.0 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of numpy failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+echo -ne "Installing matplotlib. "\n+sudo pip install matplotlib==1.2.0 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of matplotlib failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+echo -ne "Installing freetype-py. "\n+sudo pip install freetype-py==0.4.1 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of freetype-py failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+echo -ne "Installing hcluster. "\n+sudo pip install hcluster 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of hcluster failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+# needed for enum_test\n+echo -ne "Installing scipy. "\n+sudo pip install scipy 1>> /dev/null 2>> $ERR_FILE\n+if [ $? = 1 ]\n+then\n+\techo Failed.\n+\techo "Installation of scipy failed. Check $ERR_FILE."\n+\texit\n+else\n+\techo "done."\n+fi\n+\n+\n+\n+echo "Installation of dependencies complete."\n+#TODO: Follow up messages about next steps\ndiff --git a/install_scripts/mac_install/mac_install.sh b/install_scripts/mac_install/mac_install.sh\nnew file mode 100755\nindex 00000000..259abbd9\n--- /dev/null\n+++ b/install_scripts/mac_install/mac_install.sh\n@@ -0,0 +1,83 @@\n+#!/bin/bash\n+#\n+# CrossCat Mac OSX installation script\n+# Currently only works for Mac OS 10.7 and 10.8 (Lion and Mountain Lion). It \n+# does not appear to work on Snow Leopard.\n+#\n+# Installation requires XCode with command line tools and MacPorts.\n+# XCode can be got from the app store. The command line tools are installed \n+# through XCode\'s preferences menu.\n+# MacPorts can be downloaded from http://www.macports.org/\n+# This script assumes that the user has a default macports install with all \n+# packages installed to /opt/local\n+\n+# make all scripts executable if they are not already \n+if [ ! -x install_mac_deps.sh ]\n+then\n+\tchmod +x install_mac_deps.sh\n+fi\n+\n+if [ ! -x compile_cython_mac.sh ]\n+then\n+\tchmod +x compile_cython_mac.sh\n+fi\n+\n+if [ ! -x init_postgres_mac.sh ]\n+then\n+\tchmod +x init_postgres_mac.sh\n+fi\n+\n+# Check for OSX version\n+OSX_VERSION=`sw_vers -productVersion | grep -o \'[0-9]\' | awk \'{i++}i==3\'`\n+if [ "$OSX_VERSION" -lt 7 ]\n+then\n+\techo "This script does not currently work on OSX below 10.7 (Lion)."\n+\texit\n+fi\n+\n+# check for xcode\n+if [ -z `which xcodebuild` ]\n+then\n+\techo "Installation requires XCode."\t\n+\techo "Please install XCode from the App Store."\n+\techo "Once you have installed XCode, please install the command line tools from XCode\\\'s preferences menu."\n+\texit\n+fi\n+\n+# check for maports\n+WHICH_PORT=`which port`\n+if [ -z "$WHICH_PORT" ]\n+then\n+\techo "Installation requires MacPorts (http://www.macports.org/)."\n+\texit\n+fi\n+\n+\n+echo " "\n+echo "tabular_predDB mac OSX setup:"\n+echo -e "\\t1. Install backend dependencies."\n+echo -e "\\t2. Compile Cython and C++ code."\n+# echo -e "\\t3. Set up PostgresDB."\n+echo " "\n+echo -ne "Enter choice: "\n+\n+read user_input\n+\n+echo " "\n+\n+case "$user_input" in\n+\t1) \n+\t\tsudo ./install_mac_deps.sh\n+\t\t;;\n+\t2) \n+\t\tsudo ./compile_cython_mac.sh\n+\t\t;;\n+\t# 3)\n+\t# \t./init_postgres_mac.sh\n+\t# \t;;\n+\t*) \n+\t\techo "Invalid input."\n+\t\texit\n+\t\t;;\n+\t\t\n+esac\n\\ No newline at end of file\ndiff --git a/tabular_predDB/cython_code/Makefile.mac b/tabular_predDB/cython_code/Makefile.mac\nnew file mode 100644\nindex 00000000..6432cb77\n--- /dev/null\n+++ b/tabular_predDB/cython_code/Makefile.mac\n@@ -0,0 +1,18 @@\n+NAMES = ContinuousComponentModel MultinomialComponentModel State\n+SOS = $(foreach name, $(NAMES), $(name).so)\n+PYXS = $(foreach name, $(NAMES), $(name).pyx)\n+INTERMEDIATE = $(foreach name, $(NAMES), $(name).cpp)\n+RUN = state_test.py\n+\n+all: sos\n+\n+sos: $(SOS)\n+\n+$(SOS): $(PYXS)\n+\tpython setup.py build_ext --inplace -I/opt/local/include\n+\n+clean:\n+\trm -rf build $(SOS) $(INTERMEDIATE)\n+\n+run: all\n+\tpython $(RUN)\n\\ No newline at end of file\n', 'commit_subject': "Merge remote-tracking branch 'origin/mac_install'", 'repo_name': 'probcomp/crosscat', 'committer': {'name': 'dlovell', 'email': 'e4757993ddd74c458c069a2fc994cf795ce2e98e@gmail.com', 'time_sec': '1370611319', 'tz_offset': '-240', 'date': {'seconds': '1370611319'}}, 'commit_tree': 'a29bcda780ae3ba2e68881aa3e874828594722e8', 'commit_message': "Merge remote-tracking branch 'origin/mac_install'\n", 'language_name': 'JavaScript', 'license': 'apache-2.0', 'hunks': '@@ -0,0 +1,18 @@\n+NAMES = ContinuousComponentModel MultinomialComponentModel State\n+SOS = $(foreach name, $(NAMES), $(name).so)\n+PYXS = $(foreach name, $(NAMES), $(name).pyx)\n+INTERMEDIATE = $(foreach name, $(NAMES), $(name).cpp)\n+RUN = state_test.py\n+\n+all: sos\n+\n+sos: $(SOS)\n+\n+$(SOS): $(PYXS)\n+\tpython setup.py build_ext --inplace -I/opt/local/include\n+\n+clean:\n+\trm -rf build $(SOS) $(INTERMEDIATE)\n+\n+run: all\n+\tpython $(RUN)\n\\ No newline at end of file\n', 'addition_count': 18, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/tabular_predDB/cython_code/Makefile.mac', 'file_extension': '.mac', 'before_file': 'ADDFILE', 'message': "Merge remote-tracking branch 'origin/mac_install'\n", 'author_name': 'dlovell', 'lang': 'mac'}