Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Bookie: setup a Mac OSX local dev environment

Bookie: setup a Mac OSX local dev environment

I succesfully managed to setup a local development environment for Bookie in my Mac OSX machine and I'd like to share a few notes. The required changes are just small details and I guess it would be easy to edit the Makefile in order to make it work with Mac OSX, but actually I'm not an expert on it...

System configuration

OS: Mac OSX 10.8.5
Xcode: 4.6.3

Steps

  1. Manually install system libraries
    build-essential libxslt1-dev libxml2-dev python-dev libpq-dev git python-virtualenv redis-server unzip
    I didn't have to install anything, most probably because many of these libraries are included in Xcode.
    In case, I suggest to use Homebrew and install libraries with a command like: brew install <lib-name>
    You can choose to install Redis in the same machine (with Mac OSX) or in a remote machine (in this case skip the library redis-server): I chose a remote Ubuntu machine.

  2. Create a folder and clone the code
    $ mkdir bookie && cd bookie
    $ git clone https://github.com/<my-username>/Bookie.git .

  3. Pyinotify and Redis
    Pyinotify uses inotify which works only on Linux machine, so we need to comment it out from requirements.txt:
    #pyinotify==0.9.4
    In case you use Redis in a remote machine, edit sample.ini:
    celery_broker=redis://<ip-address>:6379/3
    Also, make sure that $ python2 runs python2.7.x

  4. Install the app
    $ make install
    At a certain point, while running $ bin/python bin/alembic upgrade head it will fail, saying: from bookie.models import Base
    I have no idea why this happens, since actually if you run the python interpreter in the virtualenv you can correctly import Base.
    So just run it again: $ make install and this time it will work... this is not a good solution, of course, but I couldn't figure out a better solution.

  5. Run the app
    $ make run
    Or if you want to run Celery and and Pyramid in 2 different shells: $ bin/python bin/celery worker --app=bookie.bcelery -B -l debug --purge -c 1 --pidfile celeryd.pid
    $ bin/python bin/pserve --reload bookie.ini

Notes

mazz commented Apr 5, 2014

On Mavericks and higher in order to compile bcrypt(and other python packages that have C dependencies), you'll need to get the command-line apps(Xcode 5.1):

xcode-select --install

have clang ignore unused-arguments

export CPPFLAGS=-Qunused-arguments
export CFLAGS=-Qunused-arguments

sudo -E pip install bcrypt

an example of python code to do this(virtualenv):

from sys import platform as _platform
    if _platform == "darwin":
        logger.info("darwin")
        os.environ["CPPFLAGS"] = "-Qunused-arguments"
        os.environ["CFLAGS"] = "-Qunused-arguments"
        subprocess.call(["bin/pip", "install", "bcrypt"])

See also:

http://stackoverflow.com/questions/22313407/clang-error-unknown-argument-mno-fused-madd-python-package-installation-fa/22322645#22322645

I'm going to give these directions a run-through on a fresh-from-the-store MacBook later this week. In the meantime, I've submitted a PR to add Vagrant support to Bookie:

bookieio/Bookie#416

wellphd commented Jul 16, 2014

Thanks for posting this solution. I'm trying to install on OSX 10.9.4, python 2.7.5 and ending up with an error: /bookie/Bookie/build/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found
I'll keep digging, do you have any ideas besides the obvious? Thanks in advance.

ygreq commented Feb 2, 2017

A tutorial for non-tehcie guys would be very appreciated. I am stuck at Manually install system libraries
build-essential libxslt1-dev libxml2-dev python-dev libpq-dev git python-virtualenv redis-server unzip

I installed Homebrew by the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment