(Migrated) Adding arbitrary Python packages on PYTHONPATH

(This message has been automatically imported from the retired mailing list)

Hi there,

this is an answer to a question asked off-list regarding making use of
arbitrary Python packages in Zato servers.

This depends on whether this is code from PyPI/any Python index like a
company’s own or if it the code is not a proper Python package.

For PyPI/package indexes - let’s say we want to add a dependency on Faker

https://pypi.python.org/pypi/Faker/0.0.4

  • Open INSTALL_DIR/versions.cfg and add faker = 0.0.4
  • Open INSTALL_DIR/buildout.cfg and add faker to zato.eggs stanza
  • ditto for INSTALL_DIR/buildout-darwin.cfg
  • run INSTALL_DIR/bin/buildout

Now the package will be pulled off PyPI and placed into INSTALL_DIR/eggs.

Note however that if a package has dependencies they also have to be
added to versions.cfg/buildout.cfg/buildout-darwin.cfg - this is in
order to guarantee repeatable builds instead of downloading the latest
dependencies.

Naturally, this is not always known in advance what the additional
dependencies are so it’s sometimes a matter of running
INSTALL_DIR/bin/buildout, noticing the additional package it’s not aware
of, adding it to the config files and repeating the process.

As for code that is not on PyPI - this is what zato_extra_paths is for -
you can add or symlink anything in there.

https://zato.io/docs/admin/guide/enabling-extra-libs.html

Servers need to be restarted for the changes to be picked up.