-
Notifications
You must be signed in to change notification settings - Fork 5
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
[DPE-3062] Removing binary deps #179
Conversation
ec52ae7
to
a4d93f1
Compare
a4d93f1
to
e859d71
Compare
8613adb
to
9fe0f84
Compare
- libpq-dev | ||
libpq: | ||
build-packages: | ||
- libpq-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be installed by the other plugin but might as well.
charmcraft.yaml
Outdated
organize: | ||
"*-linux-gnu/libpq.so*": binlibs/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only want libpq SOs
src/charm.py
Outdated
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/env python3 | |||
#!/usr/bin/env -S LD_LIBRARY_PATH=binlibs python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is magical, but seems to also work in focal. Alternatively, we can try to override the hooks to also add this, but I'm not sure there is a clean way to do that either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, it's cleaner to keep it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be cleaner to override dispatch
(which overrides all the hooks)
You can grab the default dispatch
from charmcraft's repo, override it, and charmcraft will use that instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should rely on the structure of the charmcraft repo. We won't notice if anything changes there.
tox.ini
Outdated
@@ -69,7 +69,7 @@ commands = | |||
[testenv:unit] | |||
description = Run unit tests | |||
commands_pre = | |||
poetry install --only main,charm-libs,unit --no-root | |||
poetry install --only charm-libs,unit --no-root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had issues installing psycopg3 locally for the unit tests, may end up not being necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solution looks very clean. I liked it.
src/charm.py
Outdated
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/env python3 | |||
#!/usr/bin/env -S LD_LIBRARY_PATH=binlibs python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, it's cleaner to keep it here.
In general LGTM, we can try LD_LIBRARY_PATH approach. |
The build without cached psycopg on this PR took ~4 mins. I don't think it will be drastically affected. |
organize: | ||
"*-linux-gnu/libpq.so*": lib/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@delgod requested moving the SO to lib.
pyproject.toml
Outdated
[tool.poetry.group.cdeps] | ||
optional = true | ||
|
||
[tool.poetry.group.cdeps.dependencies] | ||
psycopg2 = "^2.9.9" | ||
psycopg = {extras = ["c"], version = "^3.1.17"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If installing psycopg in the main group. It will be compiled at each unit test run and the unit tests won't be able to run on systems that do not have libpq installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! This is superb!!! Well done!
pyproject.toml
Outdated
[tool.poetry.group.cdeps] | ||
optional = true | ||
|
||
[tool.poetry.group.cdeps.dependencies] | ||
psycopg2 = "^2.9.9" | ||
psycopg = {extras = ["c"], version = "^3.1.17"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't this this group is necessary or should be added
Installing pyscopg2 without --no-binary
(aka with poetry, during unit tests) works fine on Ubuntu
Installing pyscopg2 with --no-binary
(aka with charmcraft pack), with the changes Dragomir made, works fine
So, it's possible to only have pyscopg2
and pyscopg
in the main dependency group, remove psycopg2-binary
from the unit dependency group, and remove the c dependency group entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Libpq was not present for sure on the self-hosted runner images nor is it a given that unit tests would be run on Ubuntu flavour that has libpq. Using compiled psycopg also means that CI unit tests would have to recompile on each run. @marceloneppel @taurus-forever what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit tests would have to recompile on each run
wdym by recompile?
fwiw pip install pyscopg2
on ubuntu runs quite quickly (few seconds)—I believe it's building a wheel from source but it doesn't seem to be any slower than a normal pip install from a binary wheel download
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this version unit tests task passes in ~10s: https://github.com/canonical/pgbouncer-k8s-operator/actions/runs/7714293497/job/21026204594?pr=179
If using just psycopg2 from the main group unit tests task takes ~30s: https://github.com/canonical/pgbouncer-k8s-operator/actions/runs/7714361605/job/21026430075?pr=203
Considering that the difference is up to declaring dependencies differently, I think this is the better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like something weird is going on
poetry add pyscopg2 takes 8 seconds (including venv creation) on a fresh gh runner: https://github.com/canonical/pgbouncer-k8s-operator/actions/runs/7723418033/job/21053662267
that doesn't account for a >= 20 second difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pip installing the packages has ~8s difference: https://github.com/canonical/pgbouncer-k8s-operator/actions/runs/7725456003/job/21059694185?pr=207
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing pre-compiled binary here has a way bigger strategic effect comparing to 20 seconds saving.
BTW, 20 seconds is a noticeable time, we can safe, but as a separate PR IMHO.
Please, branch this to a new bugreport and unblock this huge merge please (as both options are safe and does the job). Tnx!
Remove charmcraft binary python packages and instead bundle necessary SO libraries to build from source.