macOS

It is recommended to use Homebrew to install the dependencies for Boxes.py. See brew.sh on how to install Homebrew.

General

  1. Install Python 3 and other dependencies:

    brew install python3 git
    

    Optional:

    brew install pstoedit
    
  2. Install cairio:

brew install pkg-config
  1. Install required Python modules:

    pip3 install Markdown affine shapely
    
  2. Download Boxes.py via Git:

    git clone https://github.com/florianfesti/boxes.git
    
  3. Run Boxes.py:

    Local web server on port 8000:

    ./scripts/boxesserver
    

    Command line variant (CLI):

    ./scripts/boxes
    

System-wide with Inkscape extension

To install Boxes.py system-wide with the Inkscape extension, following steps are required:

  1. Install Inkscape with Homebrew Cask (requires XQuartz):

    brew install inkscape
    
  2. From the root directory of the repository, run:

    ./setup.py install
    
  3. Now boxes and boxesserver can be executed like other commands and the Inkscape extension should be available.

Troubleshooting

When using the Inkscape extension something like the following error might occur:

Traceback (most recent call last):
  File "/Users/martin/.config/inkscape/extensions/boxes", line 107, in <module>
    main()
  File "/Users/martin/.config/inkscape/extensions/boxes", line 47, in main
    run_generator(name, sys.argv[2:])
  File "/Users/martin/.config/inkscape/extensions/boxes", line 73, in run_generator
    box.close()
  File "/usr/local/lib/python3.7/site-packages/boxes-0.1-py3.7.egg/boxes/__init__.py", line 594, in close
    svgutil.svgMerge(self.output, self.inkscapefile, out)
  File "/usr/local/lib/python3.7/site-packages/boxes-0.1-py3.7.egg/boxes/svgutil.py", line 144, in svgMerge
    from lxml import etree as et
ImportError: dlopen(/Applications/Inkscape.app/Contents/Resources/lib/python2.7/site-packages/lxml/etree.so, 2): Symbol not found: _PyBaseString_Type
  Referenced from: /Applications/Inkscape.app/Contents/Resources/lib/python2.7/site-packages/lxml/etree.so
  Expected in: flat namespace

This is because Inkscape on macOS ships its own version of Python 2.7 where lxml and other dependencies are missing.

A workaround is to edit the file at /Applications/Inkscape.app/Contents/Resources/bin/inkscape. At line 79 there should be following code:

export PYTHONPATH="$TOP/lib/python$PYTHON_VERS/site-packages/"

which needs to be changed to

#export PYTHONPATH="$TOP/lib/python$PYTHON_VERS/site-packages/"

This forces Inkscape to use the Python version installed by Homebrew which has all the necessary dependencies installed.

Note: This might break other extensions. In this case simply change the line back and restart Inkscape.