From 4f6ee159414e94e36f231fc6b62685e7c3ef6ad7 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Tue, 22 Oct 2024 12:12:10 +0100 Subject: [PATCH] Prefer the ``venv`` module over virtualenv virtualenv 20.27.0 dropped support to create Python 3.7 virtual environments. Also: - Drop unused `release` Make target - Use new `build` tox target in GitHub workflow - Clean also `.mypy_cache` directories --- .github/workflows/deploy.yaml | 9 +++------ .github/workflows/test.yaml | 2 +- .gitignore | 2 +- Makefile | 19 +++++-------------- run_bioblend_tests.sh | 10 +++++++--- tox.ini | 12 ++++++++++++ 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index b4ec25eb9..f44313766 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -8,14 +8,11 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.13' - - name: Install dependencies + - name: Install tox run: | - python3 -m pip install --upgrade pip setuptools - python3 -m pip install --upgrade build twine + python3 -m pip install 'tox>=1.8.0' - name: Create and check sdist and wheel packages - run: | - python3 -m build - twine check dist/* + run: tox -e build - name: Publish to PyPI if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'galaxyproject' uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6d344f4a..8df6d5e7f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -128,7 +128,7 @@ jobs: - name: Install tox run: | python3 -m pip install --upgrade pip setuptools - python3 -m pip install 'tox>=1.8.0' 'virtualenv>=20.0.14' + python3 -m pip install 'tox>=1.8.0' - name: Set up Python for Galaxy uses: actions/setup-python@v5 with: diff --git a/.gitignore b/.gitignore index 06981d39d..9ecd06b44 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,5 @@ cover # compiled docs docs/_build -# Python virtualenv +# Python virtual environment .venv diff --git a/Makefile b/Makefile index 47d90f9d9..695dd3364 100644 --- a/Makefile +++ b/Makefile @@ -7,22 +7,13 @@ all: clean: rm -rf bioblend.egg-info/ build/ dist/ + find . -type d -name '.mypy_cache' -exec rm -rf {} + make -C docs/ clean venv: # Create and activate a virtual environment - [ -f .venv/bin/activate ] || virtualenv -p python3 .venv - ( $(IN_VENV) && \ - # Install latest versions of pip and setuptools \ - python3 -m pip install --upgrade pip setuptools && \ - # Install latest versions of other needed packages in the virtualenv \ - python3 -m pip install --upgrade twine wheel \ - ) - -release: clean venv - ( $(IN_VENV) && \ - # Create files in dist/ \ - python3 setup.py sdist bdist_wheel && \ - twine check dist/* && \ - twine upload dist/* + [ -f .venv/bin/activate ] || python3 -m venv .venv || virtualenv -p python3 .venv + # Install latest versions of pip and setuptools + ( $(IN_VENV) \ + && python3 -m pip install --upgrade pip setuptools \ ) diff --git a/run_bioblend_tests.sh b/run_bioblend_tests.sh index 89cc4a11a..0862664c9 100755 --- a/run_bioblend_tests.sh +++ b/run_bioblend_tests.sh @@ -62,7 +62,7 @@ BIOBLEND_DIR=$(get_abs_dirname "$(dirname "$0")") if ! command -v tox >/dev/null; then cd "${BIOBLEND_DIR}" if [ ! -d .venv ]; then - virtualenv -p python3 .venv + python3 -m venv .venv fi . .venv/bin/activate python3 -m pip install --upgrade "tox>=1.8.0" @@ -88,10 +88,14 @@ else esac fi -# Setup Galaxy virtualenv +# Setup Galaxy virtual environment if [ -n "${GALAXY_PYTHON}" ]; then if [ ! -d .venv ]; then - virtualenv -p "${GALAXY_PYTHON}" .venv + if ! "${GALAXY_PYTHON}" -m venv .venv; then + echo "Creating the Python virtual environment for Galaxy using the venv standard library module failed." + echo "Trying with virtualenv now." + virtualenv -p "$GALAXY_PYTHON" .venv + fi fi export GALAXY_PYTHON fi diff --git a/tox.ini b/tox.ini index 0eb7b0508..adb58ceb4 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,18 @@ passenv = GALAXY_VERSION BIOBLEND_TOOLSHED_URL +[testenv:build] +commands = + make clean + python3 -m build + twine check dist/* +deps = + build + twine +allowlist_externals = + make +skip_install = true + [testenv:lint] commands = ruff check .