Skip to content

Fix pypy3 tests #4663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ matrix:
python: nightly
allow_failures:
- python: nightly
- python: pypy3

install: travis_retry .travis/install.sh
script: .travis/run.sh
Expand Down
15 changes: 11 additions & 4 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import shutil

import scripttest
import six
import virtualenv

from tests.lib.path import Path, curdir
Expand All @@ -35,6 +36,15 @@ def path_to_url(path):
return 'file://' + url


# workaround for https://github.com/pypa/virtualenv/issues/306
def virtualenv_lib_path(venv_home, venv_lib):
if not hasattr(sys, "pypy_version_info"):
return venv_lib
version_fmt = '{0}' if six.PY3 else '{0}.{1}'
version_dir = version_fmt.format(*sys.version_info)
return os.path.join(venv_home, 'lib-python', version_dir)


def create_file(path, contents=None):
"""Create a file on the path, with the given contents
"""
Expand Down Expand Up @@ -262,11 +272,8 @@ def __init__(self, base_path, *args, **kwargs):
path_locations = virtualenv.path_locations(_virtualenv)
# Make sure we have test.lib.path.Path objects
venv, lib, include, bin = map(Path, path_locations)
# workaround for https://github.com/pypa/virtualenv/issues/306
if hasattr(sys, "pypy_version_info"):
lib = os.path.join(venv, 'lib-python', pyversion)
self.venv_path = venv
self.lib_path = lib
self.lib_path = virtualenv_lib_path(venv, lib)
self.include_path = include
self.bin_path = bin

Expand Down
7 changes: 2 additions & 5 deletions tests/lib/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import os
import subprocess
import sys

import virtualenv as _virtualenv

from . import virtualenv_lib_path
from .path import Path

# On Python < 3.3 we don't have subprocess.DEVNULL
Expand All @@ -27,10 +27,7 @@ def __init__(self, location, *args, **kwargs):
self._system_site_packages = kwargs.pop("system_site_packages", False)

home, lib, inc, bin = _virtualenv.path_locations(self.location)
# workaround for https://github.com/pypa/virtualenv/issues/306
if hasattr(sys, "pypy_version_info"):
lib = os.path.join(home, 'lib-python', sys.version[:3])
self.lib = Path(lib)
self.lib = Path(virtualenv_lib_path(home, lib))
self.bin = Path(bin)

super(VirtualEnvironment, self).__init__(*args, **kwargs)
Expand Down