Skip to content

Commit

Permalink
Prefer the venv module over virtualenv
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nsoranzo committed Oct 22, 2024
1 parent 062a3c9 commit 4f6ee15
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ cover
# compiled docs
docs/_build

# Python virtualenv
# Python virtual environment
.venv
19 changes: 5 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
)
10 changes: 7 additions & 3 deletions run_bioblend_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down

0 comments on commit 4f6ee15

Please sign in to comment.