-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to Poetry for dependency management #605
Conversation
Codecov Report
@@ Coverage Diff @@
## master #605 +/- ##
=======================================
Coverage 99.61% 99.61%
=======================================
Files 87 87
Lines 6038 6038
=======================================
Hits 6015 6015
Misses 23 23 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
3def936
to
6877a1f
Compare
…efore setup-python
Fixes using wrong Python version in Poetry environment
… useless --no-interaction flag
The install command has large time overhead
e9243b9
to
a959729
Compare
Force-pushed after some commit clean-up. The Still needs to check the release job with test-pypi. |
I checked with the branch test-pypi-release that the current setup works for publishing releases (using necessary alterations for using test-PyPI project as destination). |
There was weird behaviour in resolving flake8 version: when running Pinning autopep8 did not change anything, only pinning flake8 version to 4.* worked: now running
|
The installation of Poetry itself is now instructed in README to be done by curling and running the installation script from https://install.python-poetry.org/, and in GH Actions the install-poetry action does the same. Poetry documentation states also pipx and manual (with pip and venv) ways to install Poetry. They could be a bit more secure, but also less convenient ways. Maybe the Poetry installation in GH Actions could be done without the ready-made action but with just curling the script and running md5sum check for it? |
I tested this briefly on two machines: a desktop with fixed Ethernet and a laptop with Wi-Fi. For both machines, the "Resolving dependencies" step in More worrying is that the install slowdown also affects CI jobs. The latest run with Poetry took 6 minutes 42 seconds, while a recent non-Poetry run took 3 minutes 55 seconds. So the CI run now takes almost three minutes longer! I wonder if there's anything that could still be done to speed up the installation step under CI? However, slow install seems to be a known issue in Poetry (and there are many other similar but more recent issues). It's also the first question in the FAQ. According to the FAQ, the main reason for the slow operation is the lack of dependency metadata on PyPI, which leads to lots of extra work downloading and inspecting individual package versions from PyPI. This gives me two ideas for possible improvements of this PR:
I like the way Poetry shows outdated packages a lot:
(the color coding gets lost in the copy&paste) |
I tested re-running the CI jobs for this PR. First attempt took 5min 30s, second took 5min 35s. So not quite as slow as the first time, but still much slower than without Poetry. The "Install Python dependencies" step seems to take around 2 minutes for all three Python versions. |
I see that there are quite a few Poetry-related actions in the GitHub Actions Marketplace: https://github.com/marketplace?type=actions&query=poetry+ Maybe one of the others would be faster or otherwise better than the current one? |
This did not help (at least much). With strict pinning:
This worked! Caching directory A bit surprising that this was not cached already, as the virtual environment was, by the setup-python action feature. Well, that cache is stated to apply to virtual environment (only) as stated in the docs, but I missed that. |
Include also .local/bin where pipx places symlink for Poetry
Builder stage was needed for building fastText, which is now installed with prebuilt wheels
Resolved conflicts due to update of setup.py by adjusting pyproject.toml: - upgrade to Simplemma 0.8 - upgrade to Click 8.1.*
Allows using cached nltk data layer when source changes
I changed README.md to instruct to use pipx instead curl|bash for installing Poetry, as pipx might be the way for Annif installations for end-users in the future. Without layer caching building Docker image with Poetry is slow (6-7 mins in GH Actions), but actually has not been much faster with pip. The layer caching could be implemented in GH Actions (an example), but that can be a different PR, and the Docker build occurs anyway only on pushes to master, not to every push to PR branches. |
Kudos, SonarCloud Quality Gate passed! |
Closes #601.
Besides creating the
pyproject.toml
file with dependencies, these are done:poetry build
automatically,TODO: needs to be double-checkedChecked: all necessary static content for Web UI are automatically included.)Points to note:
--all-extras
topoetry install
: Flag to install all extras python-poetry/poetry#3413For bumping version for release there exists the
poetry version
command that can bump patch, minor and major parts, but that applies only to the version string inpyproject.toml
. There are also poetry plugins with different customizations (also for modifying version strings in any file, e.g. monim67/poetry-bumpversion), but it seems that the current approach with bumpversion is well applicable. Importantly the now-used bumpversion handles the git tag creation and commit, which I did not find any Poetry tool/plugin to be doing, and also allows bumping to*-dev
versions. For now the bumpversion config should still be kept in setup.cfg; there is an open issue for pyproject.toml support.I still try to refine the GH Actions pipeline to make a system-wide installation (I thought this should be working with setting
POETRY_VIRTUALENVS_CREATE: false
, but it is not) and by adding caching. To verify the release process works, I think a test release to test-PyPI could be done.