Skip to content

Commit

Permalink
try new appveyor config
Browse files Browse the repository at this point in the history
Signed-off-by: Kale Franz <[email protected]>
  • Loading branch information
kalefranz committed Apr 18, 2018
1 parent fb94b1a commit bf0cbcb
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 101 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ record.txt
Vagrantfile
docs/_build
env/
dev-init.bat
devenv/
Miniconda*.sh
miniconda*.sh
.pytest_cache/
63 changes: 19 additions & 44 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,41 @@ environment:
- PYTHON: "C:\\Python36_64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
PYTHON_ROOT: "C:\\Miniconda36-x64"

- PYTHON: "C:\\Python36_64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
SHELL_INTEGRATION: true
PYTHON_ROOT: "C:\\Miniconda36-x64"

- PYTHON: "C:\\Python27_32"
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "32"
PYTHON_ROOT: "C:\\Miniconda"

init:
- ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH% %HOME%


install:
# If there is a newer build queued for the same PR, cancel this one.
# The AppVeyor 'rollout builds' option is supposed to serve the same
# purpose but it is problematic because it tends to cancel builds pushed
# directly to master instead of just PR builds (or the converse).
# credits: JuliaLang developers.
# - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
# https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
# Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
# throw "There are newer queued builds for this pull request, failing early." }
- bash -c "source utils/functions.sh && run_setup"
# # - utils/win_build_env.cmd
# - powershell ./utils/install.ps1
# # set PATH for current shell
# - set "ANACONDA_PATH=%PYTHON%;%PYTHON%/Scripts;%$PYTHON%/Library/bin;%$PYTHON%/Library/usr/bin;%$PYTHON%/Library/mingw-64/bin"
# - setx ANACONDA_PATH "%ANACONDA_PATH%"
# - set "PATH=%ANACONDA_PATH%;%PATH%"
# # this one is user-local, and affects new shells
# - setx PATH "%ANACONDA_PATH%"
# - conda info
# - conda config --set always_yes yes
# - conda update conda
# - conda install -q psutil ruamel_yaml requests
# # - conda info python
# - python -c "import sys; print(sys.version)"
# - python -c "import sys; print(sys.executable)"
# - python -c "import sys; print(sys.prefix)"
# - conda install -q python=%PYTHON_VERSION%
# - conda install -q pytest mock
# - conda install -q pycrypto pyflakes pycosat
# - conda install -q git menuinst
# - conda install -q ruamel_yaml
# - conda install -q anaconda-client
# - conda install -q nbformat
# - conda install -q enum34 || WHOAMI
# - pip install flake8 pytest-cov pytest-timeout responses
# - python --version
# - python -c "import struct; print(struct.calcsize('P') * 8)"
# - python utils\setup-testing.py install
- >
%PYTHON_ROOT%\\Scripts\\conda install -y -c defaults -c conda-forge
python=%PYTHON_VERSION% pycosat conda requests ruamel_yaml
anaconda-client nbformat
pytest pytest-cov pytest-timeout mock responses pexpect xonsh
- %PYTHON_ROOT%\\Scripts\\pip install codecov
- %PYTHON_ROOT%\\python -m conda init --dev

# Not a .NET project, we build scikit-image in the install step instead
build: false

test_script:
- bash -c "source utils/functions.sh && run_tests"
# - py.test --cov-report xml --cov-report term-missing --cov-append --cov conda -m "not integration and not installed"
# - py.test --cov-report xml --cov-report term-missing --cov-append --cov conda -m "integration and not installed"
# - py.test --cov-report xml --cov-report term-missing --cov-append --cov conda -m "installed" --shell=cmd.exe --shell=bash.exe

- dev-init
- conda info
- set "ADD_COV=--cov-report xml --cov-report term-missing --cov conda"
- IF NOT DEFINED SHELL_INTEGRATION py.test %ADD_COV% -m "not integration and not installed" -v
- IF NOT DEFINED SHELL_INTEGRATION py.test %ADD_COV% --cov-append -m "integration and not installed" -v
- IF NOT DEFINED SHELL_INTEGRATION codecov --env PYTHON_VERSION --flags integration --required
- IF NOT DEFINED SHELL_INTEGRATION python -m conda.common.io
- IF DEFINED SHELL_INTEGRATION python -m conda._vendor.auxlib.packaging conda # this hard-codes __version__ in conda/__init__.py to speed up tests
- IF DEFINED SHELL_INTEGRATION py.test %ADD_COV% -m "installed" --shell=bash.exe --shell=cmd.exe
12 changes: 6 additions & 6 deletions conda/cli/conda_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,12 @@ def configure_parser_init(sub_parsers):
# # Write commands to stdout, suitable for bash `eval`, that sets up the current
# # shell as a dev environment.
#
# $ git clone [email protected]:conda/conda ~/conda
# $ curl -L https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
# -o ~/Miniconda3-latest-Linux-x86_64.sh
# $ bash ~/Miniconda3-latest-Linux-x86_64.sh -bfp ~/conda/devenv
# $ cd ~/conda
# $ eval `./devenv/bin/python -m conda init --dev bash`
# $ CONDA_PROJECT_ROOT="~/conda"
# $ git clone [email protected]:conda/conda "$CONDA_PROJECT_ROOT"
# $ cd "$CONDA_PROJECT_ROOT"
# $ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
# $ bash Miniconda3-latest-Linux-x86_64.sh -bfp ./devenv
# $ eval "$(./devenv/bin/python -m conda init --dev bash)"
#
#
# """)
Expand Down
114 changes: 63 additions & 51 deletions conda/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import json
from logging import getLogger
import os
from os.path import dirname, exists, expanduser, isdir, isfile, join
from os.path import dirname, exists, expanduser, isdir, isfile, join, abspath
from random import randint
import re
import sys
Expand Down Expand Up @@ -128,38 +128,30 @@ def initialize_dev(shell, dev_env_prefix=None, conda_source_root=None):
print("Operation failed.", file=sys.stderr)
return 1

stuff = {
'python_version': python_version[0],
'test_platform': 'win' if on_win else 'unix',
'pythonhashseed': randint(0, 4294967296),
'conda_source_root': conda_source_root,
'dev_env_prefix': dev_env_prefix,

env_vars = {
'ADD_COV': '--cov-report xml --cov-report term-missing --cov conda',
'PYTHONHASHSEED': randint(0, 4294967296),
'PYTHON_MAJOR_VERSION': python_version[0],
'TEST_PLATFORM': 'win' if on_win else 'unix',
}

if shell == "bash":
builder = [
"export PYTHON_MAJOR_VERSION='%(python_version)s'",
"export TEST_PLATFORM='%(test_platform)s'",
"export PYTHONHASHSEED='%(pythonhashseed)d'",
"export _CONDA_ROOT='%(conda_source_root)s'",
". conda/shell/etc/profile.d/conda.sh",
"conda activate '%(dev_env_prefix)s'",
builder = ["export %s='%s'" % (key, env_vars[key]) for key in sorted(env_vars)]
builder += [
"eval \"$(%s -m conda shell.bash hook)\"" % abspath(sys.executable),
"conda activate '%s'" % dev_env_prefix,
]
print("\n".join(builder) % stuff)
print("\n".join(builder))
elif shell == 'cmd_exe':
builder = [
'set "PYTHON_MAJOR_VERSION=%(python_version)s"',
'set "TEST_PLATFORM=%(test_platform)s"',
'set "PYTHONHASHSEED=%(pythonhashseed)d"',
'set "_CONDA_ROOT=%(conda_source_root)s"',
'conda activate "%(dev_env_prefix)s"',
builder = ['set %s="%s"' % (key, env_vars[key]) for key in sorted(env_vars)]
builder += [
'@conda activate "%s"' % dev_env_prefix,
]
if not context.dry_run:
with open('dev-init.bat', 'w') as fh:
fh.write('\n'.join(builder) % stuff)
fh.write('\n'.join(builder))
if context.verbosity:
print('\n'.join(builder) % stuff)
print('\n'.join(builder))
print("now run > .\\dev-init.bat")
else:
raise NotImplementedError()
Expand Down Expand Up @@ -306,13 +298,22 @@ def make_initialize_plan(conda_prefix, shells, for_user, for_system, desktop_pro
})

if shells & {'fish', }:
raise NotImplementedError()
if for_user:
raise NotImplementedError()
if for_system:
raise NotImplementedError()

if shells & {'tcsh', }:
raise NotImplementedError()
if for_user:
raise NotImplementedError()
if for_system:
raise NotImplementedError()

if shells & {'powershell', }:
raise NotImplementedError()
if for_user:
raise NotImplementedError()
if for_system:
raise NotImplementedError()

if shells & {'cmd_exe', }:
# TODO: make sure cmd_exe and cmd.exe are consistently used; choose one
Expand All @@ -325,22 +326,30 @@ def make_initialize_plan(conda_prefix, shells, for_user, for_system, desktop_pro
'conda_prefix': conda_prefix,
},
})

if on_win and desktop_prompt:
plan.append({
'function': install_conda_shortcut.__name__,
'kwargs': {
'target_path': join(conda_prefix, 'condacmd', 'Conda Prompt.lnk'),
'conda_prefix': conda_prefix,
},
})
plan.append({
'function': install_conda_shortcut.__name__,
'kwargs': {
'target_path': join(os.environ["HOMEPATH"], "Desktop", "Conda Prompt.lnk"),
'conda_prefix': conda_prefix,
},
})
if for_system:
plan.append({
'function': init_cmd_exe_user.__name__,
'kwargs': {
'target_path': 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\'
'Command Processor\\AutoRun',
'conda_prefix': conda_prefix,
},
})
if desktop_prompt:
plan.append({
'function': install_conda_shortcut.__name__,
'kwargs': {
'target_path': join(conda_prefix, 'condacmd', 'Conda Prompt.lnk'),
'conda_prefix': conda_prefix,
},
})
plan.append({
'function': install_conda_shortcut.__name__,
'kwargs': {
'target_path': join(os.environ["HOMEPATH"], "Desktop", "Conda Prompt.lnk"),
'conda_prefix': conda_prefix,
},
})

return plan

Expand All @@ -352,8 +361,8 @@ def run_plan(plan):
continue
try:
result = globals()[step['function']](*step.get('args', ()), **step.get('kwargs', {}))
except (IOError, OSError) as e:
log.error("%s: %r", step['function'], e, exc_info=True)
except EnvironmentError as e:
log.info("%s: %r", step['function'], e, exc_info=True)
result = Result.NEEDS_SUDO
step['result'] = result

Expand All @@ -377,7 +386,7 @@ def run_plan_elevated(plan):
# the default mode is 'w+b', and universal new lines don't work in that mode
tf.write(ensure_binary(json.dumps(plan, ensure_ascii=False)))
temp_path = tf.name
rc = runAsAdmin('%s -m conda.initialize \'%s\'' % (sys.executable, temp_path))
rc = runAsAdmin((sys.executable, '-m', 'conda.initialize', '"%s"' % temp_path))
assert rc == 0

with open(temp_path) as fh:
Expand Down Expand Up @@ -687,16 +696,19 @@ def init_sh_system(target_path, conda_prefix):
def init_cmd_exe_user(target_path, conda_prefix):
# HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
# HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
key_str = r'Software\Microsoft\Command Processor'
main_key, the_rest = target_path.split('\\', 1)
subkey_str, value_name = the_rest.rsplit('\\', 1)
main_key = getattr(winreg, main_key)

try:
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_str, 0, winreg.KEY_ALL_ACCESS)
key = winreg.OpenKey(main_key, subkey_str, 0, winreg.KEY_ALL_ACCESS)
except EnvironmentError as e:
if e.errno != ENOENT:
raise
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, key_str)
key = winreg.CreateKey(main_key, subkey_str)
try:
try:
value = winreg.QueryValueEx(key, "AutoRun")
value = winreg.QueryValueEx(key, value_name)
prev_value = value[0].strip()
value_type = value[1]
except EnvironmentError as e:
Expand Down Expand Up @@ -727,7 +739,7 @@ def init_cmd_exe_user(target_path, conda_prefix):
print(target_path)
print(make_diff(prev_value, new_value))
if not context.dry_run:
winreg.SetValueEx(key, "AutoRun", 0, value_type, new_value)
winreg.SetValueEx(key, value_name, 0, value_type, new_value)
return Result.MODIFIED
else:
return Result.NO_CHANGE
Expand Down

0 comments on commit bf0cbcb

Please sign in to comment.