Skip to content

rfe: Deprecate distutils module - #3920

Merged
YvanY0 merged 2 commits into
avocado-framework:masterfrom
YvanY0:deprecate-distutils
Jul 11, 2025
Merged

rfe: Deprecate distutils module#3920
YvanY0 merged 2 commits into
avocado-framework:masterfrom
YvanY0:deprecate-distutils

Conversation

@YvanY0

@YvanY0 YvanY0 commented Jun 3, 2024

Copy link
Copy Markdown
Contributor

distutils will be formally marked as deprecated since python3.10, and will no longer work from python3.12. To enable python3.12 in avocado framework, this patch will replace distutils to use other modules.

ID: 2433
ref: https://peps.python.org/pep-0632

@YvanY0
YvanY0 force-pushed the deprecate-distutils branch from 0147dca to dc787e0 Compare June 3, 2024 09:17
@YvanY0

YvanY0 commented Jun 3, 2024

Copy link
Copy Markdown
Contributor Author

https://github.com/avocado-framework/avocado-vt/blob/master/virttest/shared/scripts/virtio_console_guest.py
this file is used in guest, even though it also uses distutils module, but I didn't modify it together, cause I am not sure about the guest python version.
cc @nanliu-r

@YvanY0
YvanY0 force-pushed the deprecate-distutils branch 2 times, most recently from fb14fb0 to 1cafcb4 Compare June 3, 2024 09:22
@YvanY0

YvanY0 commented Jun 3, 2024

Copy link
Copy Markdown
Contributor Author

Hello @clebergnu @luckyh, please help to review and raise your concerns.

Another one is I noticed setup.py would also be deprecated, do we plan to migrate to the modern pyproject.toml? https://packaging.python.org/en/latest/guides/modernize-setup-py-project/#modernize-setup-py-project

Besides pyproject.toml, I tried using pip install -e . to install avocado-vt, and this works, and with pip install but not python setup.py install/develop, the CleanCommand in setup.py is not a must.

Comment thread setup.py
luckyh
luckyh previously requested changes Aug 5, 2024

@luckyh luckyh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @PaulYuuu , thanks for raising this up! I think the overall idea is good, however, I also have the following concerns.

Comment thread virttest/bootstrap.py Outdated
Comment thread setup.py Outdated
Comment thread virttest/utils_version.py
@YvanY0
YvanY0 force-pushed the deprecate-distutils branch from 1cafcb4 to 89e2a62 Compare August 6, 2024 06:54
@YvanY0
YvanY0 marked this pull request as draft September 18, 2024 09:20
@pevogam

pevogam commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Hi @PaulYuuu, have you considered moving the setup.py entirely to a pyproject.toml file as described in PEP 621? Perhaps this could make things simpler? Other than that what is the current status of this pull request? I guess it was converted to a draft since it is not considered to be the way forward or has a big roadblock ahead of it?

@YvanY0

YvanY0 commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

Hi @PaulYuuu, have you considered moving the setup.py entirely to a pyproject.toml file as described in PEP 621? Perhaps this could make things simpler? Other than that what is the current status of this pull request? I guess it was converted to a draft since it is not considered to be the way forward or has a big roadblock ahead of it?

Good question! The answer is yes, please refer to #3924

However, avocado still uses setup.py, so for avocado-vt, I am not sure if avocado-vt can go one step ahead. And this is a big milestone; it may break something, and it needs all maintainers to identify the risk.

@pevogam

pevogam commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Hmmm I see, the difference is that Avocado already added Python 3.12 and 3.13 support while the setup procedures in VT are still outdated. So I assume we are not sure if it is worth investing the time to merge this and deal with any breakage until Avocado makes the pyproject.toml step which could save us effort?

@YvanY0

YvanY0 commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

Hmmm I see, the difference is that Avocado already added Python 3.12 and 3.13 support while the setup procedures in VT are still outdated. So I assume we are not sure if it is worth investing the time to merge this and deal with any breakage until Avocado makes the pyproject.toml step which could save us effort?

I have no idea. Let me cc other maintainers here for the discussion. @luckyh @richtja @clebergnu @YongxueHong @chunfuwen

@richtja

richtja commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Hi @PaulYuuu and @pevogam, in avocado we plan to move from distils avocado-framework/avocado#5159 and migrate to pyproject.toml avocado-framework/avocado#5754. Unfortunately, we don't have anyone who would be working on that, so we hare postponing it. For now, we have solved this by adding settuptools as avocado dependency to support python3.12 and 3.13 avocado-framework/avocado#5789

@YvanY0
YvanY0 force-pushed the deprecate-distutils branch 2 times, most recently from 117a594 to 9691c3c Compare April 22, 2025 12:48
@YvanY0
YvanY0 marked this pull request as ready for review April 22, 2025 13:56
@YvanY0

YvanY0 commented Apr 23, 2025

Copy link
Copy Markdown
Contributor Author

The PR is ready for review. Let me clarify some concerns regarding the above comments.

  1. class CleanCommand(Command) https://github.com/avocado-framework/avocado-vt/pull/3920/files#r1703862017: I don't define the --all user option for the clean sub-command, we have cleaning_list, the dir to be cleaned of the native --all option will be covered in the cleaning_list. And, Python does not suggest running setup.py directly, we may move setup.py install to pip install, setup.py clean to make clean in the Makefile in the future. ref: https://packaging.python.org/en/latest/discussions/setup-py-deprecated/
  2. dir_util.copy_tree can be safely replaced with shutil.copytree right now, avocado-vt currently only supports python>=3.8
  3. LooseVersion cannot handle post version, but packaging.version.parse can. ref: https://peps.python.org/pep-0440/
>>> from packaging.version import parse
>>> from distutils.version import LooseVersion
>>> version_packaging = parse("1.0.0-1")
>>> version_distutils = LooseVersion("1.0.0-1")
<stdin>:1: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
>>> version_packaging
<Version('1.0.0.post1')>
>>> version_distutils
LooseVersion ('1.0.0-1')
>>> version_packaging.base_version
'1.0.0'
>>> version_distutils.version
[1, 0, 0, '-', 1]

@YvanY0

YvanY0 commented Apr 23, 2025

Copy link
Copy Markdown
Contributor Author

Hello @richtja, I have a question: Will we still maintain the Cirrus CI? I saw that most of the quay images are quite old, like Fedora-35 and Centos-8.1, which causes some CI jobs to fail.

@richtja

richtja commented Apr 23, 2025

Copy link
Copy Markdown
Contributor

Hello @richtja, I have a question: Will we still maintain the Cirrus CI? I saw that most of the quay images are quite old, like Fedora-35 and Centos-8.1, which causes some CI jobs to fail.

Hi @PaulYuuu AFAIK we removed Cirrus CI from avocado CI in avocado-framework/avocado#5239, but I don't know why it has been kept in avocado-vt, maybe @clebergnu will have more details. IMO there is no need to keep Cirrus CI, and we could migrate to GitHub Actions.

About the quay images I know that on avocado we maintain and use only the check-copr-rpm-version image.

@YvanY0
YvanY0 force-pushed the deprecate-distutils branch from 9691c3c to e7427f5 Compare April 24, 2025 00:48
@YvanY0

YvanY0 commented May 8, 2025

Copy link
Copy Markdown
Contributor Author

Hey guys, is there any update here? If no, I can start by removing the centos_8_1 task from Cirrus CI since CentOS8 has been EOL for a long time.

@YvanY0
YvanY0 force-pushed the deprecate-distutils branch from e7427f5 to 4255383 Compare May 22, 2025 06:42
@YvanY0
YvanY0 force-pushed the deprecate-distutils branch 2 times, most recently from 17ce6f0 to 2578f23 Compare June 4, 2025 06:52
@YvanY0
YvanY0 requested review from luckyh and richtja June 4, 2025 09:44
Yihuang Yu added 2 commits June 9, 2025 17:20
distutils will be formally marked as deprecated since python3.10,
and will no longer work from python3.12. To enable python3.12 in
avocado framework, this patch will replace distutils to use other
modules.

Signed-off-by: Yihuang Yu <yihyu@redhat.com>
The `setup.py clean` command is deprecated in modern Python packaging
tools like Hatchling and setuptools ≥61. As the Python packaging
ecosystem transitions away from `setup.py`, relying on it for cleanup
introduces inconsistencies and future maintenance issues.

Instead, the cleanup logic has been moved to the Makefile under the
`make clean` target, which is more maintainable and aligns with modern
Python project practices.

This change helps simplify the build system and makes the project more
future-proof.

Signed-off-by: Yihuang Yu <yihyu@redhat.com>
@YvanY0
YvanY0 force-pushed the deprecate-distutils branch from 2578f23 to 66cc9cc Compare June 9, 2025 09:21
@richtja
richtja requested a review from clebergnu June 25, 2025 13:13

@richtja richtja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @PaulYuuu, thank you, I think we can learn from this and apply it to avocado as well. LGTM

@luckyh
luckyh dismissed their stale review July 1, 2025 06:06

Out-of-date

@YvanY0

YvanY0 commented Jul 2, 2025

Copy link
Copy Markdown
Contributor Author

Hi @pevogam,
Would you be able to apply this PR and bootstrap it in your environment to verify if it introduces any regressions in your tests? From my side, I don’t see any risks, but since you’re using Python 3.13, I want to make sure it won’t interfere with your setup.
Let me know if you encounter any issues!

And after this gets merged, your PR #4101 may be can rebase and then continue to review.

@pevogam

pevogam commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Hi @pevogam, Would you be able to apply this PR and bootstrap it in your environment to verify if it introduces any regressions in your tests? From my side, I don’t see any risks, but since you’re using Python 3.13, I want to make sure it won’t interfere with your setup. Let me know if you encounter any issues!

And after this gets merged, your PR #4101 may be can rebase and then continue to review.

Sorry I took a while, will do this tomorrow right away

@pevogam

pevogam commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

Ok, I see no problem with these changes ✔️

@YvanY0

YvanY0 commented Jul 11, 2025

Copy link
Copy Markdown
Contributor Author

Thank you all, I will merge this PR soon, let's see later if it will introduce any negative impact. If so, I will follow up on it.

@YvanY0
YvanY0 merged commit 7bd0d8c into avocado-framework:master Jul 11, 2025
@YvanY0
YvanY0 deleted the deprecate-distutils branch July 11, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants