Would it be possible to add a poetry check command (oh, I see you'e used that already, maybe the command could be extended or have a poetry lock --check?) that will return zero if the current poetry.lock is both correct w.r.t. the pyproject.toml (ie: packages match) and that it matches the output of poetry lock.
It's very useful in CI/CD. With this command we could check that programmer didn't forget re-lock requirements.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This feature request is still valid.
I agree that this would be a nice feature!
This feature is available in some other package managers. I list some examples below:
npm ci: https://docs.npmjs.com/cli/ci.htmlyarn install --frozen-lockfile: https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-frozen-lockfileI had figure out script to emulate the behavior of #1954 and fortunately it is simple:
python -c "from poetry.factory import Factory; l = Factory().create_poetry('.').locker; exit(0) if l.is_locked() and l.is_fresh() else exit(1)" && echo 'OK'
worth mentioning that you need poetry on your PYTHONPATH which you can do like:
PYTHONPATH="${PYTHONPATH}:${HOME}/.poetry/lib" \
python -c "from poetry.factory import Factory; l = Factory().create_poetry('.').locker; exit(0) if l.is_locked() and l.is_fresh() else exit(1)" && echo 'OK'
Thank you both!
I think it's also worth mentioning if you have not followed the recommended install, the necessary changes to PYTHONPATH might differ.
In my case, on ArchLinux, where I installed poetry via pacman, I had to:
PYTHONPATH="${PYTHONPATH}:/usr/lib/python3.8/site-packages"
poetry run python -c "from poetry.factory import Factory; l = Factory().create_poetry('.').locker; exit(0) if l.is_locked() and l.is_fresh() else exit(1)" && echo 'OK'
I'll add to my requirements wishlist for this: also check that the .lock file is consistent with what's actually in the managed python environment.
I've commented on @cliebBS pull request #1954, but thought I'd mention it here too for completeness.
I'd like to report back and say this check in it's current form isn't really useful for me… it only checks to make sure that poetry update would result in no updates.
I thought it would function more like bundlers deployment mode. So that it errors if the pyproject.toml has been modified but the lock file is out of date.
If you use poetry-dynamic-versioning and the above mentioned script is failing, you can try this one:
PYTHONPATH="${PYTHONPATH}:${HOME}/.poetry/lib:${HOME}/.poetry/lib/poetry/_vendor/py3.6/" python -c "from poetry.factory import Factory; from pathlib import Path; l = Factory().create_poetry(Path('.')).locker; exit(0) if l.is_locked() and l.is_fresh() else exit(1)" && echo 'OK' || (echo 'Lock file out of date. Maybe you need to do "poetry lock"'; exit 1)
Most helpful comment
I had figure out script to emulate the behavior of #1954 and fortunately it is simple: