-
Notifications
You must be signed in to change notification settings - Fork 243
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
rfe: Deprecate distutils module #3920
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,24 +12,27 @@ | |
# Copyright: Red Hat Inc. 2013-2014 | ||
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com> | ||
|
||
# pylint: disable=E0611 | ||
import os | ||
import shutil | ||
from distutils.command.clean import clean | ||
from pathlib import Path | ||
|
||
from setuptools import find_packages, setup | ||
from setuptools import Command, find_packages, setup | ||
|
||
VERSION = open("VERSION", "r").read().strip() | ||
|
||
|
||
class Clean(clean): | ||
"""Our custom command to get rid of scratch files after build.""" | ||
class CleanCommand(Command): | ||
"""Custom command to clean up build and scratch files.""" | ||
|
||
description = "Get rid of scratch, byte files and build stuff." | ||
description = "Custom clean command to tidy up the project root" | ||
user_options = [] | ||
|
||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def run(self): | ||
super().run() | ||
cleaning_list = [ | ||
"MANIFEST", | ||
"BUILD", | ||
|
@@ -46,12 +49,12 @@ def run(self): | |
cleaning_list += list(Path(".").rglob("__pycache__")) | ||
|
||
for e in cleaning_list: | ||
if not os.path.exists(e): | ||
continue | ||
if os.path.isfile(e): | ||
os.remove(e) | ||
if os.path.isdir(e): | ||
shutil.rmtree(e) | ||
path = Path(e) | ||
if path.exists(): | ||
if path.is_file(): | ||
path.unlink() | ||
elif path.is_dir(): | ||
shutil.rmtree(path) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
@@ -96,6 +99,12 @@ def run(self): | |
"avocado-vt = avocado_vt.plugins.vt_runner:VTTestRunner", | ||
], | ||
}, | ||
install_requires=["netifaces", "six", "aexpect", "avocado-framework>=82.1"], | ||
cmdclass={"clean": Clean}, | ||
install_requires=[ | ||
"netifaces", | ||
"packaging", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be in avocado rather than avocado-vt? |
||
"six", | ||
"aexpect", | ||
"avocado-framework>=82.1", | ||
], | ||
cmdclass={"clean": CleanCommand}, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import re | ||
import shutil | ||
import sys | ||
from distutils import dir_util # virtualenv problem pylint: disable=E0611 | ||
|
||
from avocado.utils import cpu, distro, genio, linux_modules | ||
from avocado.utils import path as utils_path | ||
|
@@ -910,7 +909,9 @@ def bootstrap(options, interactive=False): | |
LOG.info("%d - Updating test providers repo configuration from local copy", step) | ||
tp_base_dir = data_dir.get_base_test_providers_dir() | ||
tp_local_dir = data_dir.get_test_providers_dir() | ||
dir_util.copy_tree(tp_base_dir, tp_local_dir) | ||
if os.path.exists(tp_local_dir): | ||
shutil.rmtree(tp_local_dir) | ||
shutil.copytree(tp_base_dir, tp_local_dir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
while
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, as we also support python3.6, I will check the dst first, if it exists, then remove it. |
||
|
||
not_downloaded = asset.test_providers_not_downloaded() | ||
if not_downloaded: | ||
|
@@ -950,7 +951,9 @@ def bootstrap(options, interactive=False): | |
LOG.info( | ||
"%d - Syncing backend dirs %s -> %s", step, base_backend_dir, local_backend_dir | ||
) | ||
dir_util.copy_tree(base_backend_dir, local_backend_dir) | ||
if os.path.exists(local_backend_dir): | ||
shutil.rmtree(local_backend_dir) | ||
shutil.copytree(base_backend_dir, local_backend_dir) | ||
|
||
sync_download_dir(interactive) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import operator | ||
import re | ||
from distutils.version import ( # pylint: disable=no-name-in-module,import-error | ||
LooseVersion, | ||
) | ||
|
||
from packaging.version import parse | ||
|
||
|
||
class VersionInterval(object): | ||
|
@@ -31,8 +30,8 @@ def __init__(self, interval): | |
raise ValueError("Invalid string representation of an interval") | ||
self.opening, lower, upper, self.closing = match.groups() | ||
|
||
self.lower_bound = LooseVersion(lower) if lower else None | ||
self.upper_bound = LooseVersion(upper) if upper else None | ||
self.lower_bound = parse(lower) if lower else None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the implementation of |
||
self.upper_bound = parse(upper) if upper else None | ||
self._check_interval() | ||
|
||
def _check_interval(self): | ||
|
@@ -64,7 +63,7 @@ def __contains__(self, version): | |
"]": operator.ge, | ||
} | ||
in_interval = True | ||
version = LooseVersion(version) | ||
version = parse(version) | ||
if self.lower_bound: | ||
opt = op_mapping.get(self.opening) | ||
in_interval = opt(self.lower_bound, version) | ||
|
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 incompatible with the original use of the
clean
command.[before]
[after]
FYI, see https://github.com/pypa/setuptools/blob/main/setuptools/_distutils/command/clean.py
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.
All clean options are wanna clean sub dir under
build
, however, our customcleaning_list
will clean the entirebuild
dir, which means these options are not used for us.avocado-vt/setup.py
Lines 33 to 43 in 4cfe8c9
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.
And, after we switch to
pip install
in the future, we don't need to care aboutbuild
dir, as it will use thetmp
during build.