aboutsummaryrefslogtreecommitdiff
path: root/delivery_merge
diff options
context:
space:
mode:
Diffstat (limited to 'delivery_merge')
-rw-r--r--delivery_merge/cli/merge.py3
-rw-r--r--delivery_merge/conda.py32
-rw-r--r--delivery_merge/merge.py40
-rw-r--r--delivery_merge/utils.py3
4 files changed, 57 insertions, 21 deletions
diff --git a/delivery_merge/cli/merge.py b/delivery_merge/cli/merge.py
index 45adf64..a9b94b4 100644
--- a/delivery_merge/cli/merge.py
+++ b/delivery_merge/cli/merge.py
@@ -1,5 +1,5 @@
import os
-from ..conda import conda, conda_installer, conda_init_path
+from ..conda import conda, conda_installer, conda_init_path, ei_touch
from ..merge import (
env_combine,
testable_packages,
@@ -44,6 +44,7 @@ def main():
prefix = conda_installer(args.installer_version)
conda_init_path(prefix)
+ ei_touch()
if not os.path.exists(os.path.join(prefix, 'envs', name)):
print(f"Creating environment {name}...")
diff --git a/delivery_merge/conda.py b/delivery_merge/conda.py
index cc265f1..6dd29b1 100644
--- a/delivery_merge/conda.py
+++ b/delivery_merge/conda.py
@@ -13,6 +13,22 @@ class BadPlatform(Exception):
pass
+def ei_touch():
+ py_version = sh('python', '--version').stdout.decode().strip().split()[1]
+ py_version = '.'.join(py_version.split('.')[:2])
+ root = run("python -c 'import sys; print(sys.prefix)'",
+ capture_output=True,
+ shell=True,
+ env=os.environ).stdout.decode().strip()
+ libsp = ['lib', f'python{py_version}', 'site-packages']
+ site_packages = os.path.join(root, *libsp)
+ pthfile = os.path.join(site_packages, 'easy-install.pth')
+
+ print('PTHFILE = {}'.format(pthfile))
+ if not os.path.exists(pthfile):
+ open(pthfile, 'w+').write('')
+
+
def conda_installer(ver, prefix='./miniconda3'):
""" Install miniconda into a user-defined prefix and return its path
@@ -59,7 +75,7 @@ def conda_installer(ver, prefix='./miniconda3'):
os.chmod(installer, 0o755)
# Perform installation
- run(install_command).check_returncode()
+ run(install_command, env=os.environ).check_returncode()
return prefix
@@ -78,6 +94,17 @@ def conda_init_path(prefix):
os.environ['PATH']])
+def conda_site():
+ """ Retrieve current environment's site-packages path
+ """
+ result = run("python -c 'import site; print(site.getsitepackages()[-1])'",
+ capture_output=True,
+ shell=True,
+ env=os.environ)
+ result.check_returncode()
+ return result.stdout.decode().strip()
+
+
def conda_activate(env_name):
""" Activate a conda environment
@@ -90,7 +117,8 @@ def conda_activate(env_name):
"""
proc = run(f". activate {env_name} && env",
capture_output=True,
- shell=True)
+ shell=True,
+ env=os.environ)
proc.check_returncode()
return getenv(proc.stdout.decode()).copy()
diff --git a/delivery_merge/merge.py b/delivery_merge/merge.py
index f99c542..c58da77 100644
--- a/delivery_merge/merge.py
+++ b/delivery_merge/merge.py
@@ -1,7 +1,7 @@
import os
import re
import sys
-from .conda import conda, conda_env_load, conda_cmd_channels
+from .conda import conda, conda_env_load, conda_cmd_channels, ei_touch
from .utils import comment_find, git, pushd, sh
from configparser import ConfigParser
from glob import glob
@@ -74,15 +74,19 @@ def env_combine(filename, conda_env, conda_channels=[]):
packages.append(f"'{record['fullspec']}'")
packages_result = ' '.join([x for x in packages])
- proc = conda('install', '-q', '-y',
- '-n', conda_env,
- conda_cmd_channels(conda_channels),
- packages_result)
- if proc.stderr:
- print(proc.stderr.decode())
+ with conda_env_load(conda_env):
+ ei_touch()
+ # Perform package installation
+ proc = conda('install', '-q', '-y',
+ '-n', conda_env,
+ conda_cmd_channels(conda_channels),
+ packages_result)
- proc.check_returncode()
+ if proc.stderr:
+ print(proc.stderr.decode())
+
+ proc.check_returncode()
def testable_packages(filename, prefix):
@@ -159,29 +163,33 @@ def integration_test(pkg_data, conda_env, results_root='.'):
force_xunit2()
with conda_env_load(conda_env):
+ ei_touch()
results = os.path.abspath(os.path.join(results_root,
repo_root,
'result.xml'))
- proc_pip_install = sh("pip", "install --upgrade pip")
+
+ conda("uninstall", "-y", repo_root)
+
+ proc_pip_install = sh("python", "-m pip install --upgrade pip pytest ci-watson")
if proc_pip_install.returncode:
print(proc_pip_install.stdout.decode())
print(proc_pip_install.stderr.decode())
- proc_pip = sh("pip", "install -v -e .[test] pytest ci_watson")
+ proc_pip = sh("python", "-m pip install -v .[test]")
proc_pip_stderr = proc_pip.stderr.decode()
if proc_pip.returncode:
print(proc_pip.stdout.decode())
print(proc_pip.stderr.decode())
- # Setuptools is busted in conda. Ignore errors related to
- # easy_install.pth
- if 'easy-install.pth' not in proc_pip_stderr:
- proc_pip.check_returncode()
-
if 'consider upgrading' not in proc_pip_stderr:
proc_pip.check_returncode()
- proc_pytest = sh("pytest", f"-v --basetemp=.tmp --junitxml={results}")
+ proc_egg = sh("python", "setup.py egg_info")
+ if proc_egg.returncode:
+ print(proc_egg.stdout.decode())
+ print(proc_egg.stderr.decode())
+
+ proc_pytest = sh("python", "-m pytest", f"-v --basetemp=.tmp --junitxml={results}")
print(proc_pytest.stdout.decode())
if proc_pytest.returncode:
print(proc_pytest.stderr.decode())
diff --git a/delivery_merge/utils.py b/delivery_merge/utils.py
index 705eaf2..e3d43c0 100644
--- a/delivery_merge/utils.py
+++ b/delivery_merge/utils.py
@@ -32,7 +32,7 @@ def sh(prog, *args):
command += tmp
print(f'Running: {" ".join(command)}')
- return run(command, capture_output=True)
+ return run(command, capture_output=True, env=os.environ)
def git(*args):
@@ -70,4 +70,3 @@ def pushd(path):
yield
finally:
os.chdir(last)
-