diff --git a/.cirrus.yml b/.cirrus.yml index 1da0aba52b..891245be22 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -15,7 +15,7 @@ fedora_35_task: # Latest LTS release is 103.x - AVOCADO_SRC: avocado-framework<104.0 matrix: - - SETUP: setup.py develop --user + - SETUP: -m pip install --user -e . - SETUP: -m pip install . - SETUP: -m pip install PYPI_UPLOAD/*.whl matrix: @@ -25,6 +25,7 @@ fedora_35_task: - (echo $SETUP | grep -v PYPI_UPLOAD) || make pypi setup_script: &setup_scr - python3 --version + - python3 -m pip install --upgrade pip - test -z $AVOCADO_SRC || python3 -m pip install $AVOCADO_SRC - python3 $SETUP bootstrap_script: &bootstrap_scr @@ -61,7 +62,7 @@ avocado_devel_task: # 103lts tree (from where new 103.x releases will come) - AVOCADO_SRC: git+https://github.com/avocado-framework/avocado@103lts#egg=avocado_framework matrix: - - SETUP: setup.py develop --user + - SETUP: -m pip install --user -e . - SETUP: -m pip install . - SETUP: -m pip install PYPI_UPLOAD/*.whl matrix: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5d7f69531..5c40aaf618 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,6 @@ jobs: working-directory: ./avocado-libs run: | python -m pip install --upgrade pip - pip install 'setuptools-rust==1.1.2' pip install -e . - name: Finish installing dependencies run: | diff --git a/CODING_STYLE b/CODING_STYLE index cb1028c927..9901c6d61c 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -15,7 +15,7 @@ Base coding style The coding style for all Python code is the one enforced by black (see https://black.readthedocs.io/en/stable/the_black_code_style/). The -selftests/style.sh script can be used to verify the code style matches. +"hatch fmt -f" command can be used to verify the code style matches. Variable names and UpPeR cAsE diff --git a/Makefile b/Makefile index 63109feb28..842dfce1f6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,7 @@ ifndef PYTHON -PYTHON=$(shell which python3 2>/dev/null || which python2 2>/dev/null || which python 2>/dev/null) +PYTHON=$(shell which python3 2>/dev/null || which python 2>/dev/null) endif -VERSION=$(shell $(PYTHON) setup.py --version 2>/dev/null) -PYTHON_DEVELOP_ARGS=$(shell if ($(PYTHON) setup.py develop --help 2>/dev/null | grep -q '\-\-user'); then echo "--user"; else echo ""; fi) +VERSION=$(shell $(PYTHON) -m hatchling version 2>/dev/null) DESTDIR=/ AVOCADO_DIRNAME?=avocado @@ -14,15 +13,17 @@ COMMIT_DATE=$(shell git log --pretty='format:%cd' --date='format:%Y%m%d' -n 1) SHORT_COMMIT=$(shell git log --abbrev=8 --pretty=format:'%h' -n 1) MOCK_CONFIG=default ARCHIVE_BASE_NAME=avocado-vt +PKG_NAME=avocado-framework-plugin-vt RPM_BASE_NAME=avocado-plugins-vt +CLEAN_LIST := MANIFEST BUILD BUILDROOT SPECS RPMS SRPMS SOURCES PYPI_UPLOAD build dist all: @echo @echo "Development related targets:" @echo "check: Runs tree static check, unittests and fast functional tests" - @echo "develop: Runs 'python setup.py --develop' on this tree alone" - @echo "link: Runs 'python setup.py --develop' in all subprojects and links the needed resources" + @echo "develop: Runs 'python -m pip install -e .' on this tree alone" + @echo "link: Runs 'python -m pip install -e .' in all subprojects and links the needed resources" @echo "clean: Get rid of scratch, byte files and removes the links to other subprojects" @echo "unlink: Disables egg links and unlinks needed resources" @echo @@ -42,25 +43,23 @@ all: include Makefile.include -requirements: pip - - $(PYTHON) -m pip install -r requirements.txt - check: - ./selftests/style.sh - ./selftests/isort.sh - inspekt lint --disable W,R,C,E0203,E0601,E1002,E1101,E1102,E1103,E1120,F0401,I0011,E1003,W605,I1101 --exclude avocado-libs,scripts/github - pylint --errors-only --disable=all --enable=spelling --spelling-dict=en_US --spelling-private-dict-file=spell.ignore * + hatch fmt --check + inspekt lint --disable W,R,C,E0203,E0601,E1002,E1101,E1102,E1103,E1120,F0401,I0011,E1003,W605,I1101 --exclude scripts/github clean: - $(PYTHON) setup.py clean + rm -rf $(CLEAN_LIST) + for pattern in "*.pyc" "__pycache__"; do \ + find . -name "$$pattern" -exec rm -rf {} +; \ + done develop: - $(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS) + $(PYTHON) -m pip install --user -e . link: develop unlink: - $(PYTHON) setup.py develop --uninstall $(PYTHON_DEVELOP_ARGS) + $(PYTHON) -m pip uninstall -y $(PKG_NAME) # For compatibility reasons remove old symlinks for NAME in $$(ls -1 avocado_vt/conf.d); do\ CONF="etc/avocado/conf.d/$$NAME";\ @@ -70,8 +69,8 @@ unlink: pypi: clean if test ! -d PYPI_UPLOAD; then mkdir PYPI_UPLOAD; fi - $(PYTHON) setup.py bdist_wheel -d PYPI_UPLOAD - $(PYTHON) setup.py sdist -d PYPI_UPLOAD + $(PYTHON) -m pip install build + $(PYTHON) -m build -o PYPI_UPLOAD @echo @echo "Please use the files on PYPI_UPLOAD dir to upload a new version to PyPI" @echo "The URL to do that may be a bit tricky to find, so here it is:" diff --git a/Makefile.include b/Makefile.include index 3505c31209..54e1faec8e 100644 --- a/Makefile.include +++ b/Makefile.include @@ -7,11 +7,7 @@ source-release: clean git archive --prefix="$(ARCHIVE_BASE_NAME)-$(VERSION)/" -o "SOURCES/$(ARCHIVE_BASE_NAME)-$(VERSION).tar.gz" $(VERSION) install: - if [ "$$($(PYTHON) --version 2>&1 | cut -d' ' -f2 | cut -d'.' -f1)" == "2" ]; then \ - $(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE); \ - else \ - $(PYTHON) -m pip install --prefix $(DESTDIR) --upgrade .; \ - fi + $(PYTHON) -m pip install --prefix $(DESTDIR) --upgrade . srpm: source if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi diff --git a/avocado-plugins-vt.spec b/avocado-plugins-vt.spec index e5c4d717a8..dd761c3a64 100644 --- a/avocado-plugins-vt.spec +++ b/avocado-plugins-vt.spec @@ -43,7 +43,7 @@ Source0: https://github.com/avocado-framework/%{srcname}/archive/%{commit}.tar.g # old way of retrieving snapshot sources #Source0: https://github.com/avocado-framework/%{srcname}/archive/%{commit}/%{srcname}-%{version}-%{shortcommit}.tar.gz %endif -BuildRequires: python3-devel, python3-setuptools, python3-six +BuildRequires: python3-devel, python3-six, python3-hatchling, python3-wheel Requires: python3-six BuildArch: noarch Requires: autotest-framework, xz, tcpdump, iproute, iputils, gcc, glibc-headers, nc, git @@ -88,7 +88,7 @@ Xunit output, among others. %install %{__mkdir} -p %{buildroot}%{_sysconfdir}/avocado/conf.d -%{__python3} setup.py install --root %{buildroot} --skip-build +%{__python3} -m pip install --prefix=%{buildroot} --no-build-isolation . %{__mv} %{buildroot}%{python3_sitelib}/avocado_vt/conf.d/* %{buildroot}%{_sysconfdir}/avocado/conf.d %files -n python3-%{name} diff --git a/contrib/packages/debian/Makefile b/contrib/packages/debian/Makefile index 6485e3a2f7..2e76150722 100644 --- a/contrib/packages/debian/Makefile +++ b/contrib/packages/debian/Makefile @@ -12,7 +12,7 @@ prepare-source: # build the source package in the parent directory # then rename it to project_version.orig.tar.gz dch -D "bionic" -M -v "$(VERSION)" "Automated (make builddeb) build." - $(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../ --prune + $(PYTHON) -m build --sdist --outdir=../ rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* deb-src: prepare-source diff --git a/docs/source/contributing/Guidelines.rst b/docs/source/contributing/Guidelines.rst index 7d6e25606b..94b28fc86e 100644 --- a/docs/source/contributing/Guidelines.rst +++ b/docs/source/contributing/Guidelines.rst @@ -77,7 +77,7 @@ Rules for Maintainers Rules for Contributors ====================== -1. [Must] Coding style should conform to what's enforced by black (see ``selftests/style.sh``) +1. [Must] Coding style should conform to what's enforced by black and isort (see black configuration in ``pyproject.toml``) 2. [Must] PR commit message is meaningful. Refer to the link on how to write a good commit message 3. [Must] Travis CI pass and no conflict 4. [Must] Provide test results. If no, provide justification. Apply to any PR diff --git a/requirements-travis.txt b/requirements-travis.txt index e08c76d8fc..fe8b0b6054 100644 --- a/requirements-travis.txt +++ b/requirements-travis.txt @@ -7,3 +7,4 @@ netifaces==0.11.0 pyenchant==3.2.2 black==22.3.0 isort==5.10.1 +hatch diff --git a/selftests/isort.sh b/selftests/isort.sh deleted file mode 100755 index f0309ac66d..0000000000 --- a/selftests/isort.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -isort --check-only . diff --git a/selftests/style.sh b/selftests/style.sh deleted file mode 100755 index 18ad91b79f..0000000000 --- a/selftests/style.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -e -echo "** Running black..." - -black --check --diff --color . diff --git a/virttest/utils_test/__init__.py b/virttest/utils_test/__init__.py index d05926f56e..f77b872803 100755 --- a/virttest/utils_test/__init__.py +++ b/virttest/utils_test/__init__.py @@ -1034,7 +1034,7 @@ def env_check(self): if self.session.cmd_status(cmd, timeout=self.timeout) != 0: LOG.error("Failed to restart libvirtd inside guest") return False - pip_pack = ["setuptools", "netifaces", "aexpect"] + pip_pack = ["hatchling", "netifaces", "aexpect"] cmd = "" for each in pip_pack: cmd = "%s install %s --upgrade" % (self.pip_bin, each) @@ -1091,7 +1091,7 @@ def install_avocado(self): return False for plugin in self.plugins[self.installtype]: cmd = "cd %s;" % os.path.join(self.plugins_path, plugin) - cmd += "%s setup.py install" % self.python + cmd += "%s install ." % self.pip_bin if self.session.cmd_status(cmd, timeout=self.timeout) != 0: LOG.error("Avocado plugin %s git " "installation failed", plugin) return False @@ -1121,7 +1121,7 @@ def git_install(self, repo_path, branch="", make="", install=True): if make: cmd += "make %s;" % make if install: - cmd += "%s setup.py install" % self.python + cmd += "%s install ." % self.pip_bin return self.session.cmd_status(cmd, timeout=self.timeout) == 0 def repo_name(self, repo_path):