Migrate pyproject.toml to poetry for inspection #135
+4,424
−54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #129.
As pointed out by @macflo8, the sdmx dependency version needs to be bumped. And all of the below can be discarded by dropping the second and third commit, if we don't like it. However:
While working on this, I found myself thinking that I'd like to manage dependencies with poetry as we already do in ixmp4. With poetry, we could quite easily update more dependencies as well:
$ poetry show -o
shows all packages in the venv that can be updated and whether this update is considered safe;
$ poetry show -o -T
shows all of these packages that we explicitly specify in our
pyproject.toml
. In this case, the output of the latter isWith pip, I would now specify
pyam-iamc >= 2.0.0
in the dependencies to force the new version. In contrast, poetry can managepyproject.toml
for us and keeps us from making that mistake:So we immediately know that we will only be able to use pyam-iamc 2.0.0 once we move our python requirement to be at least 3.10.
Poetry has some other nice features such as a focus on environment isolation. If poetry detects it is running in a venv, it will use that one, but if it isn't running in one, it will create and manage one for you. For ixmp4, we use the config option
poetry config virtualenvs.in-project true
to have these venvs installed in the project rather than globally.On the user side, nothing should change by including this version of
pyproject.toml
andpoetry.lock
. We can still run$ pip install message-ix-models[docs,report,tests]
or equivalently, when using poetry,
However, it might be possible to improve other things as well: maybe we can use the automatically created
poetry.lock
as an input file for pinned dependencies for the docs builds that is automatically kept up-to-date when we update dependencies via poetry.To install message-ix-models using poetry, you can follow these steps from within your local clone of this branch:
Once this is done, you can access the venv from the directory by running
poetry shell
, which will spawn a new shell where you can runmix-models
and everything else as usual. However, you can also usepoetry run <command>
to run cli commands without creating a new shell.Please note that I dropped some classifiers since poetry is adding python and license classifiers automatically.
How to review
developer (someone like the reviewer) will be able to understand what the code
does in the future. (only if we decide to keep poetry)
PR checklist
[ ] Add or expand tests; coverage checks both ✅Not adding functionality.[ ] Add, expand, or update documentation.Only if we keep poetry.[ ] Update doc/whatsnew.Only if we keep poetry.