Skip to content

Commit

Permalink
adding pypy support.
Browse files Browse the repository at this point in the history
  • Loading branch information
toumorokoshi committed Apr 19, 2017
1 parent 9ff8ea7 commit 3efb82a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ lib/
.pydistutils.cfg
.coverage*
VERSION


**/site-packages/**
**/lib-python/**
**/lib_pypy/**
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ language: python
python:
- "2.7"
- "3.5"
- "3.6"
script: "make test"
16 changes: 16 additions & 0 deletions ubuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,19 @@ def publish(build):
"python", "setup.py",
"bdist_wheel", "--universal", "upload", "--release"
])


def uninstall(build):
build.packages.install("pyyaml")
import yaml
assert yaml is not None
build.packages.uninstall("pyyaml")

import importlib
try:
importlib.reload(yaml)
exist = True
except Exception:
exist = False

assert exist == False
4 changes: 3 additions & 1 deletion uranium/lib/sandbox/venv/activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def activate_virtualenv(root):

activate_this_path = os.path.join(root, 'bin', 'activate_this.py')
with open(activate_this_path) as fh:
exec(fh.read(), {'__file__': activate_this_path}, {})
l = {"__file__": activate_this_path}
bytecode = compile(fh.read(), activate_this_path, "exec")
exec(bytecode, l, l)
sys.exec_prefix = sys.prefix
sys.base_exec_prefix = sys.prefix

Expand Down
2 changes: 2 additions & 0 deletions uranium/lib/sandbox/venv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
import sys
import virtualenv
from .activate_this import write_activate_this

LOGGER = logging.getLogger(__name__)

Expand All @@ -22,6 +23,7 @@ def install_virtualenv(install_dir):
"--always-copy",
install_dir
])
write_activate_this(install_dir)

VIRTUALENV_FILES = {
'activate file': os.path.join('bin', 'activate')
Expand Down
23 changes: 19 additions & 4 deletions uranium/scripts/activate_this.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,28 @@

base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

def _get_site_packages():
"""
try a variety of site package directories, finding one that works.
"""
paths_to_try = [
# typically win32
os.path.join(base, 'Lib', 'site-packages'),
# standard
os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages'),
# typically pypy
os.path.join(base, 'site-packages'),
]
for p in paths_to_try:
if os.path.isdir(p):
return p
return os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages'),


old_os_path = os.environ.get('PATH', '')
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
if sys.platform == 'win32':
site_packages = os.path.join(base, 'Lib', 'site-packages')
else:
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
prev_sys_path = list(sys.path)
site_packages = _get_site_packages()
import site
site.addsitedir(site_packages)
if not hasattr(sys, "real_prefix"):
Expand Down

0 comments on commit 3efb82a

Please sign in to comment.