Install packages in a certain order with Poetry

Viewed 21

Is there a way to set the .toml file up so you will have the dependencies installed in a certain order with Poetry?

Imagine I have the following .toml:

[tool.poetry.dependencies]
wxPython = "4.1.1"
python = "^3.9"
pandas = "^1.4.2"
Faker = "^13.13.0"
pymarc = "^4.2.0"

How can I make sure wxPython always is installed first?

2 Answers

There is no way to tell Poetry to install packages in a certain order. The reason for this is, because it is not needed.

If the package provide a wheel the content is just extracted to the appropriate target folder.

If the package only provides an sdist and therefor a wheel needs to be build, this happens an a fresh isolated environment. Thus, the build process does not have access to any previously installed package.

If the build process fail, due to a missing dependency in the build environment, the package maintainers miss to declare those build-dependencies according to PEP-518. Once this is fixed, those dependencies are installed in the isolated build environment during the build process.

Poetry already takes care of this for you. It will install wxPython in your example before any other packages that declare a dependency on it.

Related