summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernat Gabor <gaborjbernat@gmail.com>2018-10-28 13:07:54 +0000
committerBernát Gábor <gaborjbernat@gmail.com>2018-10-30 07:51:42 +0000
commit7f2a68f88a07a6a30cabd5c8a23d9f108e897f7c (patch)
tree95ff7cf18c74662b58f74013d516e49ecd26798b
parent57cd97a0111753ee1b1457aaf5fec158d0d798ef (diff)
downloadvirtualenv-7f2a68f88a07a6a30cabd5c8a23d9f108e897f7c.tar.gz
Jython to CI
-rw-r--r--.pre-commit-config.yaml2
-rw-r--r--azure-pipelines.yml3
-rw-r--r--azure-run-tox-env.yml33
-rwxr-xr-xsrc/virtualenv.py13
-rw-r--r--tests/test_virtualenv.py6
-rw-r--r--tox.ini15
6 files changed, 50 insertions, 22 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0d6722c..eab7895 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -34,7 +34,7 @@ repos:
additional_dependencies: ["flake8-bugbear == 18.8.0"]
language_version: python3.7
- repo: https://github.com/asottile/pyupgrade
- rev: v1.9.1
+ rev: v1.10.0
hooks:
- id: pyupgrade
- repo: https://github.com/pre-commit/pygrep-hooks
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 07deb07..e52b060 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -21,6 +21,9 @@ trigger:
jobs:
- template: azure-run-tox-env.yml
+ parameters: {tox: jython, python: 3.7, os: linux}
+
+- template: azure-run-tox-env.yml
parameters: {tox: fix_lint, python: 3.7}
- template: azure-run-tox-env.yml
parameters: {tox: embed, python: 3.7}
diff --git a/azure-run-tox-env.yml b/azure-run-tox-env.yml
index a0338a7..6dd6e56 100644
--- a/azure-run-tox-env.yml
+++ b/azure-run-tox-env.yml
@@ -21,29 +21,46 @@ jobs:
steps:
# ensure the required Python versions are available
- - ${{ if notIn(parameters.python, 'pypy', 'pypy3') }}:
+ - ${{ if notIn(parameters.python, 'pypy', 'pypy3', 'jython') }}:
- task: UsePythonVersion@0
displayName: setup python
inputs:
versionSpec: ${{ parameters.python }}
+ - ${{ if eq(parameters.tox, 'jython') }}:
+ - script: "wget http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7.1/jython-installer-2.7.1.jar -O $(Agent.ToolsDirectory)/jython.jar"
+ displayName: download jython
+
+ - script: "java -jar $(Agent.ToolsDirectory)/jython.jar -sd $(Agent.ToolsDirectory)/jython -e demo src doc"
+ displayName: install jython
+
+ - script: echo "##vso[task.setvariable variable=PATH]$(Agent.ToolsDirectory)/jython/bin:$(PATH)"
+ displayName: setvarStep
+
+ - script: echo $(PATH)
+ displayName: show PATH
+
- script: "$(python) -c \"import sys; print(sys.version); print(sys.executable)\""
displayName: show python information
- - script: "python -m pip install -U pip setuptools --user -v"
- displayName: upgrade pip and setuptools
+ - script: "python -m pip install -U pip setuptools --user"
+ displayName: install pip
- - script: "python -m pip install -U tox --pre --user -v"
+ - script: "python -m pip install -U tox --user -v"
displayName: install tox
- - script: ${{ format('python -m tox -e {0} --notest', parameters.tox) }}
+ - ${{ if eq(parameters.tox, 'jython') }}:
+ - script: "python -m pip install --user $(System.DefaultWorkingDirectory)"
+ displayName: install dev venv for tox
+
+ - script: ${{ format('python -m tox -e {0} --notest --skip-missing-interpreters=false', parameters.tox) }}
displayName: install test dependencies
- ${{ if startsWith(parameters.tox, 'py') }}:
- - script: python -m tox -e coverage --notest
+ - script: python -m tox -e coverage --notest --skip-missing-interpreters=false
displayName: install coverage dependencies
- - script: ${{ format('python -m tox -e {0}', parameters.tox) }}
+ - script: ${{ format('python -m tox --skip-missing-interpreters=false -e {0}', parameters.tox) }}
displayName: run tests
- ${{ if and( startsWith(parameters.tox, 'py'), eq(variables['system.pullrequest.isfork'], false) ) }}:
@@ -56,7 +73,7 @@ jobs:
testRunTitle: ${{ format('{0}_{1}', parameters.os, parameters.tox) }}
- ${{ if startsWith(parameters.tox, 'py') }}:
- - script: "python -m tox -e coverage"
+ - script: "python -m tox --skip-missing-interpreters=false -e coverage"
displayName: create coverag report
condition: succeededOrFailed()
diff --git a/src/virtualenv.py b/src/virtualenv.py
index 1fae20a..7714e80 100755
--- a/src/virtualenv.py
+++ b/src/virtualenv.py
@@ -894,7 +894,7 @@ def install_wheel(project_names, py_executable, search_dirs=None, download=False
search_dirs = file_search_dirs()
wheels = find_wheels(["setuptools", "pip"], search_dirs)
- pythonpath = os.pathsep.join(wheels)
+ python_path = os.pathsep.join(wheels)
# PIP_FIND_LINKS uses space as the path separator and thus cannot have paths
# with spaces in them. Convert any of those to local file:// URL form.
@@ -911,7 +911,6 @@ def install_wheel(project_names, py_executable, search_dirs=None, download=False
return urljoin("file:", pathname2url(os.path.abspath(p)))
findlinks = " ".join(space_path2url(d) for d in search_dirs)
-
SCRIPT = textwrap.dedent(
"""
import sys
@@ -936,14 +935,16 @@ def install_wheel(project_names, py_executable, search_dirs=None, download=False
try:
args = ["install", "--ignore-installed"]
if cert_file is not None:
- args += ["--cert", cert_file.name]
+ args += ["--cert", cert_file.name{}]
args += sys.argv[1:]
sys.exit(_main(args))
finally:
if cert_file is not None:
os.remove(cert_file.name)
- """
+ """.format(
+ ", '--no-cache'" if is_jython else ""
+ )
).encode("utf8")
cmd = [py_executable, "-"] + project_names
@@ -951,8 +952,8 @@ def install_wheel(project_names, py_executable, search_dirs=None, download=False
logger.indent += 2
env = {
- "PYTHONPATH": pythonpath,
- "JYTHONPATH": pythonpath, # for Jython < 3.x
+ "PYTHONPATH": python_path,
+ "JYTHONPATH": python_path, # for Jython < 3.x
"PIP_FIND_LINKS": findlinks,
"PIP_USE_WHEEL": "1",
"PIP_ONLY_BINARY": ":all:",
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index 27f3d10..a48c5e4 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -5,10 +5,14 @@ import sys
import tempfile
import pytest
-from mock import NonCallableMock, call, patch
import virtualenv
+try:
+ from unittest.mock import NonCallableMock, call, patch
+except ImportError:
+ from mock import NonCallableMock, call, patch
+
def test_version():
"""Should have a version string"""
diff --git a/tox.ini b/tox.ini
index 18f1443..17bcd80 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,13 +11,13 @@ setenv = PIP_DISABLE_VERSION_CHECK = 1
extras = testing
commands = coverage run --source=virtualenv \
--rcfile="{toxinidir}/tox.ini" \
- {envbindir}/pytest tests
+ -m pytest tests \
{posargs:\
- --junitxml={env:JUNIT_XML_FILE:{toxworkdir}/.test.{envname}.xml}
+ --junitxml={env:JUNIT_XML_FILE:{toxworkdir}/.test.{envname}.xml} \
!jython: --timeout=180 \
}
coverage combine --rcfile="{toxinidir}/tox.ini"
- !jython: coverage report -m --rcfile="{toxinidir}/tox.ini"
+ !jython: coverage report --show-missing --rcfile="{toxinidir}/tox.ini"
[testenv:.package]
deps =
@@ -38,6 +38,10 @@ source = src
*/src
*\src
+[testenv:jython]
+# pip 18.1 cache does not work with jython
+install_command = python -m pip install {opts} {packages} --no-cache
+
[testenv:coverage]
description = [run locally after tests]: combine coverage data and create report;
generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var)
@@ -47,8 +51,7 @@ extras =
skip_install = True
passenv = DIFF_AGAINST
setenv = COVERAGE_FILE={toxworkdir}/.coverage
-commands = coverage erase --rcfile="{toxinidir}/tox.ini"
- coverage combine --rcfile="{toxinidir}/tox.ini"
+commands = coverage combine --rcfile="{toxinidir}/tox.ini"
coverage report --show-missing --rcfile="{toxinidir}/tox.ini"
coverage xml -o {toxworkdir}/coverage.xml --rcfile="{toxinidir}/tox.ini"
coverage html -d {toxworkdir}/htmlcov --rcfile="{toxinidir}/tox.ini"
@@ -113,7 +116,7 @@ force_grid_wrap = 0
line_length = 120
known_standard_library = ConfigParser
known_first_party = virtualenv
-known_third_party = mock,pytest
+known_third_party = pytest
[flake8]
max-complexity = 22