From 92815e29d03517ad3eef2c15cc20ebc2dbb94a83 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Mon, 7 Mar 2022 13:50:51 -0800 Subject: [PATCH] github/workflows: use a virtualenv for setuptools We need to "python setup.py develop" so that setuptools uses our distutils.commands entry points. The setuptools in Ubuntu 20.04 is too old. Activate a newer one using a Python virtualenv. Set SETUPTOOLS_USE_DISTUTILS=stdlib to prevent problems with the newer setuptools built-in distutils setup in ubuntu-latest. TODO: can we remove build_mo and build_pot from the setup process? Signed-off-by: David Aguilar --- .github/workflows/main.yml | 16 +++++++++++----- Makefile | 13 ++++++++----- requirements/requirements-dev.txt | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cf5ec83b..30b20f01 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,7 @@ jobs: - name: Install Dependencies run: | + set -x sudo apt-get update sudo apt-get install \ black \ @@ -45,6 +46,7 @@ jobs: pylint \ python-is-python3 \ python-pytest \ + python-setuptools-scm \ python3-pytest \ python3-pytest-flake8 # Runtime dependencies (required) @@ -54,18 +56,22 @@ jobs: # Runtime dependencies (optional) sudo apt-get install \ python3-send2trash - # Development environment - make requirements-dev - # These requirements are already satisfied by python3-send2trash. - # make requirements-optional + python -m venv --system-site-packages env + source env/bin/activate + export SETUPTOOLS_USE_DISTUTILS=stdlib + make develop - name: Build Translations - run: make i18n + run: | + source env/bin/activate + export SETUPTOOLS_USE_DISTUTILS=stdlib + make i18n - name: Run Unit Tests run: | git config --global user.name "Git Cola" git config --global user.email git-cola@localhost + export SETUPTOOLS_USE_DISTUTILS=stdlib make test - name: Run Linter diff --git a/Makefile b/Makefile index 05c90598..fd705dc3 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ all:: # Development # ----------- +# make develop # python setup.py develop ~ one-time virtualenv development setup # make V=1 # generate files; V=1 increases verbosity # make test [flags=...] # run tests; flags=-x fails fast, --ff failed first # make test V=2 # V=2 increases test verbosity @@ -91,8 +92,7 @@ endif # These values can be overridden on the command-line or via config.mak prefix = $(HOME) bindir = $(prefix)/bin -python_code := "import sys; print('%s.%s' % (sys.version_info[0], sys.version_info[1]))" -python_version := $(shell $(PYTHON) -c $(python_code)) +python_version := $(shell $(PYTHON) -c 'import sys; print("%s.%s" % sys.version_info[:2])') python_lib = python$(python_version)/site-packages pythondir = $(prefix)/lib/$(python_lib) # DESTDIR = @@ -109,9 +109,6 @@ cola_dist := $(cola_base)-$(cola_version) SETUP ?= $(PYTHON) setup.py build_args += build -ifdef USE_ENV_PYTHON - build_args += --use-env-python -endif install_args += install ifdef DESTDIR @@ -293,6 +290,12 @@ format:: $(GREP) -v ^qtpy | \ $(XARGS) $(BLACK) --skip-string-normalization +# Run "make develop" from inside a newly created virtualenv to setup the build system +# using "python setup.py develop". +.PHONY: develop +develop:: + $(SETUP) develop + .PHONY: requirements requirements:: $(PIP) install --requirement requirements/requirements.txt diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 41ffacd5..f8f970b0 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -2,7 +2,7 @@ ## Build tools build; python_version >= '3.0' -setuptools>=42.0.0 +setuptools>=42 setuptools_scm[toml] >= 3.4.1 wheel -- 2.11.4.GIT