Skip to content
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

Use modern tomllib/tomli modules for reading TOML files #214

Merged
merged 1 commit into from Nov 4, 2022

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Oct 14, 2022

Replace the unmaintained toml/pytoml dependencies with the modern alternatives: the built-in tomllib module in Python 3.11, and tomli in older Python versions. Preserving backwards compatibility does not seem necessary, as podman-py no longer supports Python versions older than 3.6.

Signed-off-by: Michał Górny mgorny@gentoo.org

@mgorny
Copy link
Contributor Author

mgorny commented Oct 14, 2022

I don't think that pylint failure is my fault.

@jwhonce jwhonce requested a review from lsm5 October 14, 2022 16:08
@jwhonce
Copy link
Member

jwhonce commented Oct 14, 2022

@cdoern @lsm5 Please verify those libraries are available across all supported OS version as packages.

@jwhonce
Copy link
Member

jwhonce commented Oct 14, 2022

@mgorny I would guess the linter has been updated on the image a caught this issue.

@cdoern FYI I was not able to reproduce the pylint issue with the following env:

pylint --version
pylint 2.14.4
astroid 2.12.10
Python 3.11.0rc2 (main, Sep 13 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-1)]

@cdoern
Copy link
Collaborator

cdoern commented Oct 14, 2022

@mgorny would you mind re pushing? also try a rebase just in case. If it fails again, I suggest following the error message and moving the podman import up

@mgorny
Copy link
Contributor Author

mgorny commented Oct 14, 2022

@mgorny would you mind re pushing? also try a rebase just in case. If it fails again, I suggest following the error message and moving the podman import up

Re-pushed. There was nothing to rebase on, i.e. it was already at the latest.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 14, 2022

@mgorny I would guess the linter has been updated on the image a caught this issue.

@cdoern FYI I was not able to reproduce the pylint issue with the following env:

pylint --version
pylint 2.14.4
astroid 2.12.10
Python 3.11.0rc2 (main, Sep 13 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-1)]

I actually see it with tox -e pylint. It's using pylint==2.15.4 apparently.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 14, 2022

Moving the import fixes one error but leaves the two others:

************* Module /tmp/podman-py/.pylintrc
.pylintrc:1:0: E0015: Unrecognized option found: no-space-check, argument-name-hint, variable-name-hint (unrecognized-option)
************* Module podman.api.__init__
podman/api/__init__.py:1:0: R0401: Cyclic import (podman.api -> podman.api.client) (cyclic-import)

@lsm5
Copy link
Member

lsm5 commented Oct 17, 2022

I can't find any tomli packages for rhel 8 and 9 so I suspect this would break those distros. Can we please keep toml as a fallback if tomli isn't available?

@mgorny
Copy link
Contributor Author

mgorny commented Oct 17, 2022

I can't find any tomli packages for rhel 8 and 9 so I suspect this would break those distros. Can we please keep toml as a fallback if tomli isn't available?

I suppose I can make the code compatible with it but I don't see how to make Python-level requires happy with either package. That said, I don't understand why it's listed as build system dependency in the first place.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 17, 2022

I can't find any tomli packages for rhel 8 and 9 so I suspect this would break those distros. Can we please keep toml as a fallback if tomli isn't available?

I suppose I can make the code compatible with it but I don't see how to make Python-level requires happy with either package. That said, I don't understand why it's listed as build system dependency in the first place.

Done that.

@lsm5
Copy link
Member

lsm5 commented Oct 18, 2022

let me try building this on copr for centos before we merge.

@lsm5
Copy link
Member

lsm5 commented Oct 18, 2022

So, if epel repos aren't enabled, centos8 will have trouble finding python3-toml and centos9 will have trouble finding python3-tomli. This would mean rhel8 and rhel9 builds would also have trouble since we can't enable epel repos there. See: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/build/4954089/ for details.

@cdoern @umohnani8 how do you wanna go forward with this? Are we ok with having a separate rhel branch or should we make sure main branch itself builds for all rhel8 and rhel9 ?

@lsm5
Copy link
Member

lsm5 commented Oct 21, 2022

@cdoern @umohnani8 PTAL.

@rhatdan
Copy link
Member

rhatdan commented Oct 21, 2022

What would it take to get tomllib/tomli into RHEL? Is this something we can just make available for podman-py? How do we handle this with other python tools?

@lsm5
Copy link
Member

lsm5 commented Oct 21, 2022

What would it take to get tomllib/tomli into RHEL?

I guess the typical process to get a package included in RHEL.

Is this something we can just make available for podman-py?

You mean like bundling tomllib in the podman-py RPM for rhel? No idea how ugly that might get.

How do we handle this with other python tools?

I guess other deps have been available on RHEL so far. Don't quite remember bundling a python dependency in another python-based RPM

@rhatdan
Copy link
Member

rhatdan commented Oct 21, 2022

Bottom line, I don't believe we should block Upstream based on Downstream packaging. We can work to get this packaged in RHEL in the future, but by the same token, we should be careful not to bring in huge libraries, which add little value.

@lsm5
Copy link
Member

lsm5 commented Oct 21, 2022

Bottom line, I don't believe we should block Upstream based on Downstream packaging. We can work to get this packaged in RHEL in the future, but by the same token, we should be careful not to bring in huge libraries, which add little value.

Since we're keeping podman-py versions in sync with podman, RHEL packaging would have to be dealt with rather sooner. If we don't wanna block upstream on RHEL packaging, then having a separate rhel branch seems to be the way to go.

@umohnani8
Copy link
Member

How much effort would it be to maintain a separate rhel branch on github? We would have to make sure we push any new commits to both the main and rhel branch right?
I am fine with a separate rhel branch as long as there is an easy way to maintain it. One more thing to consider is we may run into dep issues with new code that works fine with the modern tomlib/tomli modules and not the old ones we are using for rhel, how would we handle that then?

@rhatdan
Copy link
Member

rhatdan commented Oct 25, 2022

I think is it a mistake to branch them. We are doubling our work rather then just getting the new libraries into RHEL.

@lsm5
Copy link
Member

lsm5 commented Oct 27, 2022

I think is it a mistake to branch them. We are doubling our work rather then just getting the new libraries into RHEL.

I'm fine with that. I guess we can continue RHEL discussion elsewhere (cc: @TomSweeneyRedHat @jnovy)

Copy link
Member

@lsm5 lsm5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builds fine on Fedora and CentOS Stream. So LGTM from me.

@cdoern @umohnani8 PTAL for final review and merge.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 27, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lsm5, mgorny

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Nov 2, 2022

@mgorny needs a rebase.

@mgorny
Copy link
Contributor Author

mgorny commented Nov 2, 2022

Rebased.

@umohnani8
Copy link
Member

@mgorny there is still a conflict, can you please rebase again.

Replace the unmaintained `toml`/`pytoml` dependencies with the modern
alternatives: the built-in `tomllib` module in Python 3.11, and `tomli`
in older Python versions.  Preserving backwards compatibility does not
seem necessary, as podman-py no longer supports Python versions older
than 3.6.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
@mgorny
Copy link
Contributor Author

mgorny commented Nov 3, 2022

Rebased again.

@rhatdan
Copy link
Member

rhatdan commented Nov 4, 2022

LGTM

@rhatdan rhatdan merged commit 80bd583 into containers:main Nov 4, 2022
@mgorny
Copy link
Contributor Author

mgorny commented Nov 4, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants