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/
pyproject.toml
file¶
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
sections tool.poetry.dependencies
and tool.poetry.dev-dependencies
of the pyproject.toml
file.
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'
The lime-crm
dependency¶
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.
Adding dependencies¶
Dependencies are added running
$ poetry add [dependency]
For more information regarding options and dependency specification please see Poetry's documentation
Managing dependencies¶
Project dependencies must be locked in a file called poetry.lock
before your project is published to the remote repo. This is done by running:
$ 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]
Warning
Without the 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
Info
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.