Installing and managing dependencies¶
A Lime CRM project has a number of first and third party dependencies. To install and manage them we use a tool called Poetry.
Poetry is a tool for managing dependencies and virtual environments, as well as building and publishing your Python packages. It serves as a modern replacement for pip, making the development experience easier. This quick start guide provides the basics of using poetry for working with Lime packages and solutions.
The official documentation for poetry lives here: https://python-poetry.org/docs/
The recommended way to install poetry is by using one the custom installers provided here: https://python-poetry.org/docs/#installation.
Poetry is installed into the user's platform-specific home directory. Test your installation by running:
For configuring poetry, refer to https://python-poetry.org/docs/configuration/.
Poetry uses a single standardized
pyproject.toml file to replace
setup.py, requirements.txt, setup.cfg, MANIFEST.in, and Pipfile.
This file is used to store all your metadata and dependency declarations.
Dependencies and dev-dependencies are declared in their corresponding
For newly created solutions using
lime-project, the file will look
similar to this:
[build-system] requires = ['poetry>=0.12'] build-backend = 'poetry.masonry.api' [tool.metadata] display_name = '' package_name = 'solution-test' lib_name = 'solution_test' [tool.poetry] name = 'solution-test' version = '0.1.0' description = 'Lime CRM solution' authors = ['Author <[email protected]>'] [[tool.poetry.source]] name = 'lime' url = 'https://pypi.lime.tech/simple/' [tool.poetry.plugins.'lime_plugins'] 'solution-test' = 'solution_test' [tool.poetry.dependencies] python = '~3.7.3' lime-crm = ">=1.3.1, <3" [tool.poetry.dev-dependencies] autopep8 = '>=1' pytest = '^5' flake8 = '^3' [tool.lime] [tool.lime.project] project_version = '1.26.0-poetry.1' project_type = 'solution'
Each project always has a dependency on
lime-crm, the underlying library for Lime CRM.
A package should keep as broad range of versions as its dependencies, while a solution should
narrow it down.
Each Lime CRM Server on-premise release has a specific version of the library
To enable a matching release, you need to specify the correct version of
lime-crm in your
pyproject.toml file, e.g.:
[tool.poetry.dependencies] lime-crm = "==1.6.1"
In the list of released on-premise versions, the version of the
lime-crm can be found in parentheses of the version number.
Lime CRM 2020.2.245 (2.22.2) is built against
lime-crm==2.22.2 as implied in the version number
Set up poetry to use our own PyPi¶
We have our own server for hosting python packages at https://pypi.lime.tech/. By default, poetry won't know about this server unless you tell it.
Configuring poetry to use the Lime PyPI
poetry config repositories.lime https://pypi.lime.tech/simple/ poetry config http-basic.lime [PYPI USERNAME HERE] [PYPI PASSWORD HERE]
this is only needed the first time you install and set up Poetry
You can explicitly tell poetry to search for packages on our own server
by adding the following to the
pyproject.toml file of your project:
[[tool.poetry.source]] name = "lime" url = "https://pypi.lime.tech/simple/"
This entry is auto-generated when creating or migrating a
Dependencies are added running
$ poetry add [dependency]
For more information regarding options and dependency specification please see Poetry's documentation
Project dependencies must be locked in a file called
before your project is published to the remote repo. This is done by
$ poetry lock
Once dependencies are lock, all following installs will use the lock-file to install dependencies. To update any dependency run:
$ poetry update [dependency]
poetry.lock file will fail to build
when pushed to the master branch.
Dependencies can be installed from the
poetry.lock file by running:
$ poetry install
If you don't have a lock-file, running
poetry install will create one
For more info on managing dependencies, refer to https://python-poetry.org/docs/cli/#install.