Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save glowinthedark/33c6b58b1b17b53e62e50c92ea4dc74c to your computer and use it in GitHub Desktop.

Select an option

Save glowinthedark/33c6b58b1b17b53e62e50c92ea4dc74c to your computer and use it in GitHub Desktop.
Installation instructions for libicu-dev, PyICU, libpostal, pypostal on Mac OS X

Installing PyICU, libpostal, pypostal on Mac OS X 10.14+

libicu-dev (PyICU dependency)

brew reinstall pkg-config icu4c

PyICU (pypostal dependency)

BREW_PREFIX=$(brew --prefix)
ls $BREW_PREFIX/opt/icu4c/bin
ls $BREW_PREFIX/opt/icu4c/sbin
# add to PATH and PKG_CONFIG_PATH
export PATH="$BREW_PREFIX/opt/icu4c/bin:$BREW_PREFIX/opt/icu4c/sbin:${PATH}"
export PKG_CONFIG_PATH="$BREW_PREFIX/opt/icu4c/lib/pkgconfig:${PKG_CONFIG_PATH}"

# ensure system clang is used for proper libstdc++ https://github.com/ovalhub/pyicu/issues/5#issuecomment-291631507
unset CC CXX

python3 -m pip install -U --force-reinstall --no-binary=pyicu pyicu --break-system-packages

libpostal (pypostal dependency)

One-liner (using HEAD as v1.1 was released in 2018):

brew install --HEAD robsalasco/libpostal/libpostal
# this is the recent homebrew opt path: double check these folders exist
ls /opt/homebrew/opt/libpostal/lib
ls /opt/homebrew/opt/libpostal/include
# add to LDFLAGS and CPPFLAGS
export LDFLAGS="-L/opt/homebrew/opt/libpostal/lib ${LDFLAGS}"
export CPPFLAGS="-I/opt/homebrew/opt/libpostal/include ${CPPFLAGS}"

pip install --no-cache-dir --force-reinstall postal

# test installation by parsing an example address
python -c "from postal.parser import parse_address; my_address = '123 Beech Lake Ct. Roswell, GA 30076'; print({v: k for k, v in dict(parse_address(my_address)).items()})"
# {'house_number': '123', 'road': 'beech lake ct.', 'city': 'roswell', 'state': 'ga', 'postcode': '30076'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment