Command line tools for interacting with government food database,
and analyzing your health trends. The SR28 database includes data
for ~8500 foods and ~180 nutrients. Customizable with extensions
and mapping rules built on top.
Requires:
- Python 3.4.3 or later (
lzma,ssl&sqlite3modules) [WinXP, Ubuntu14.04, or later]. - Packages: see
setup.py, andrequirements.txtfiles. - Internet connection, to download food database & package dependencies.
See nt database: https://github.com/nutratech/nt-sqlite
See usda database: https://github.com/nutratech/usda-sqlite
| Category | ||
|---|---|---|
| Install / Linux | ||
| Install / Windows | ||
| Other checks | ||
| PyPI Release | ||
| Supported Runtime | ||
| Code Style | ||
| License |
You will need make and gcc to build the Levenshtein extension.
sudo apt install make gcc direnv python3-dev python3-venv
# on macOS
brew install make gcc direnv [email protected]Install with,
sudo apt install direnv || brew install direnv
# Need to add hook, too
# See: https://direnv.net/docs/hook.html
DEFAULT_SHELL=$(basename $SHELL)
SHELL_RC_FILE=~/.${DEFAULT_SHELL}rc
HOOK='eval "$(direnv hook '$DEFAULT_SHELL')"'
# Install the hook, if not already
grep "$HOOK" $SHELL_RC_FILE || echo "$HOOK" >>$SHELL_RC_FILE
source $SHELL_RC_FILEThis is what the .envrc file is for. It automatically activates venv.
On Windows you should check the box during the Python installer
to include Scripts directory in your %PATH%. This can be done
manually after installation too.
Main program works 100% on older OSes, but test and lint may break.
Install the Levenshtein speedup with this.
pip install nutra[extras]Linux may need to install python-dev package as well as gcc.
Windows may fail if missing the Visual Studio build tools are missing.
pip install -U nutra(Specify: flag -U to upgrade, or --pre for development releases)
Clone down, initialize nt-sqlite submodule, and install requirements:
git clone https://github.com/nutratech/cli.git
cd cli
make init || source .venv/bin/activate
make deps
./nutra -hInitialize the DBs (nt and usda).
# source .venv/bin/activate # uncomment if NOT using direnv
./nutra init
# Or install and run as package script
make install
n initIf installed (or inside cli) folder, the program can also run
with python -m ntclient.
You may need to set the PY_SYS_INTERPRETER value for the Makefile
if trying to install other than with /usr/bin/python3.
make build # python3 setup.py --quiet sdist
twine upload dist/nutra-X.X.X.tar.gzInstall the dependencies (make deps). Now you can lint & test.
# source .venv/bin/activate # uncomment if NOT using direnv
make format lint testThe argcomplete package will be installed alongside.
Simply run the following out of a bash shell. Check their page for more
specifics on using other shells, e.g. zsh, fish, or tsh.
activate-global-python-argcomplete --userThen you can press tab to fill in or complete sub-commands and to list argument flags.
This can work with git bash too. I followed the instructions on their README.
I've run the command to seed the autocomplete script.
mkdir -p $HOME/.bash_completion.d
activate-global-python-argcomplete --userAnd my ~/.bashrc file looks like this.
export ARGCOMPLETE_USE_TEMPFILES=1
# python bash completion
if [ -f ~/.bash_completion.d/python-argcomplete ]; then
source ~/.bash_completion.d/python-argcomplete
fiOn older versions it may be python-argcomplete.sh instead.
NOTE: Standard autocomplete is fully functional, we are adding customized completions.
USDA Stock database
- Standard reference database (SR28) [7794 foods]
USDA Extensions (Relational)
- Flavonoid, Isoflavonoids, and Proanthocyanidins [1352 foods]
Requires internet connection to download initial datasets.
Run nutra init for this step.
Run n or nutra to output usage (-h flag is optional and defaulted).