Skip to content

Commit

Permalink
Merge branch 'master' into separate-conda-package-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan authored May 10, 2019
2 parents 258e926 + aa8c876 commit 32aaae3
Show file tree
Hide file tree
Showing 20 changed files with 780 additions and 333 deletions.
8 changes: 3 additions & 5 deletions .cla-signers
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# New contributors should email [email protected] to request a Contributor License Agreement
# that can be electronically signed. A signed contributor license agreement for a pull request
# author needs to be on file with Anaconda, Inc. for pull requests to be merged. This file,
# while not an official record, is used by conda-bot for the purposes of CLA status on pull
# requests.
# A signed contributor license agreement for a pull request author needs to be on file with
# Anaconda, Inc. for pull requests to be merged. This file, while not an official record,
# is used by conda-bot for the purposes of CLA status on pull requests.

# Each row in this file has three fields. The first field is github username. The second field
# is git id, the output of `git log -n1 --format="%aN <%aE>"` when HEAD is at a specific user's
Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ In case you're new to CLAs, this is rather standard procedure for larger project

### Process

New contributors should email [email protected] to request a Contributor License Agreement that
can be electronically signed. A signed contributor license agreement for a pull request author
needs to be on file with Anaconda, Inc. for pull requests to be merged. A record of signatories is
kept in the [`.cla-signers`](https://github.com/conda/conda/blob/master/.cla-signers) file in the
New contributors should complete the Conda Contributor License Agreement located
[here](https://conda.io/en/latest/contributing.html#conda-contributor-license-agreement). A
signed contributor license agreement for a pull request author needs to be on file with
Anaconda, Inc. for pull requests to be merged. A record of signatories is kept in the
[`.cla-signers`](https://github.com/conda/conda/blob/master/.cla-signers) file in the
project root.

### Individual Contributor License Agreement – Conda Code Organization
Expand Down
11 changes: 9 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ conda_build_test: &conda_build_test
echo "safety_checks: disabled" >> ~/.condarc
echo "local_repodata_ttl: 1800" >> ~/.condarc
conda create -n blarg -yq --download-only python=2.7
conda create -n blarg -yq --download-only python=3.4
conda create -n blarg -yq -c https://repo.anaconda.com/pkgs/free --download-only python=3.4
conda create -n blarg -yq --download-only python=3.5
conda create -n blarg -yq --download-only python=3.6
conda create -n blarg -yq --download-only python=3.7
conda create -n blarg -yq --download-only python setuptools cython certifi
conda create -n blarg -yq --download-only libpng=1.6.17
conda create -n blarg -yq -c https://repo.anaconda.com/pkgs/free --download-only libpng=1.6.17
- run:
name: conda-build conda
Expand Down Expand Up @@ -141,6 +141,9 @@ conda_build_test: &conda_build_test
echo "Only docs changed detected, skipping tests"
else
eval "$(sudo /opt/conda/bin/python -m conda init --dev bash)"
conda config --add default_channels https://repo.anaconda.com/pkgs/free
conda config --add default_channels https://repo.anaconda.com/pkgs/r
conda config --add default_channels https://repo.anaconda.com/pkgs/main
conda info
cd ~/conda-build
py.test --basetemp /tmp/cb -v --durations=20 -n 2 -m "not serial" tests -k "$CONDABUILD_SKIP"
Expand Down Expand Up @@ -169,6 +172,10 @@ conda_build_test: &conda_build_test
echo "Only docs changed detected, skipping tests"
else
eval "$(sudo /opt/conda/bin/python -m conda init --dev bash)"
conda config --add default_channels https://repo.anaconda.com/pkgs/free
conda config --add default_channels https://repo.anaconda.com/pkgs/r
conda config --add default_channels https://repo.anaconda.com/pkgs/main
conda info
cd ~/conda-build
py.test --basetemp /tmp/cb -v --durations=20 -n 0 -m "serial" tests -k "$CONDABUILD_SKIP"
/opt/conda/bin/python -m conda.common.io
Expand Down
4 changes: 2 additions & 2 deletions conda/activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def __init__(self, arguments=None):
self.sep = '/'
self.path_conversion = native_path_to_unix
self.script_extension = '.xsh'
self.tempfile_extension = '.xsh'
self.tempfile_extension = None
self.command_join = '\n'

self.unset_var_tmpl = 'del $%s'
Expand All @@ -851,7 +851,7 @@ def __init__(self, arguments=None):
super(XonshActivator, self).__init__(arguments)

def _hook_preamble(self):
return 'CONDA_EXE = "%s"' % context.conda_exe
return '$CONDA_EXE = "%s"' % context.conda_exe


class CmdExeActivator(_Activator):
Expand Down
2 changes: 0 additions & 2 deletions conda/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,11 @@

DEFAULT_CHANNELS_UNIX = (
'https://repo.anaconda.com/pkgs/main',
'https://repo.anaconda.com/pkgs/free',
'https://repo.anaconda.com/pkgs/r',
)

DEFAULT_CHANNELS_WIN = (
'https://repo.anaconda.com/pkgs/main',
'https://repo.anaconda.com/pkgs/free',
'https://repo.anaconda.com/pkgs/r',
'https://repo.anaconda.com/pkgs/msys2',
)
Expand Down
12 changes: 11 additions & 1 deletion conda/base/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class Context(Configuration):
show_channel_urls = PrimitiveParameter(None, element_type=(bool, NoneType))
use_local = PrimitiveParameter(False)
whitelist_channels = SequenceParameter(string_types, expandvars=True)
restore_free_channel = PrimitiveParameter(False)

always_softlink = PrimitiveParameter(False, aliases=('softlink',))
always_copy = PrimitiveParameter(False, aliases=('copy',))
Expand Down Expand Up @@ -544,8 +545,12 @@ def default_channels(self):
def custom_multichannels(self):
from ..models.channel import Channel

default_channels = list(self._default_channels)
if self.restore_free_channel:
default_channels.insert(1, 'https://repo.anaconda.com/pkgs/free')

reserved_multichannel_urls = odict((
(DEFAULTS_CHANNEL_NAME, self._default_channels),
(DEFAULTS_CHANNEL_NAME, default_channels),
('local', self.conda_build_local_urls),
))
reserved_multichannels = odict(
Expand Down Expand Up @@ -713,6 +718,7 @@ def category_map(self):
'migrated_custom_channels',
'add_anaconda_token',
'allow_non_channel_urls',
'restore_free_channel',
)),
('Basic Conda Configuration', ( # TODO: Is there a better category name here?
'envs_dirs',
Expand Down Expand Up @@ -1062,6 +1068,10 @@ def description_map(self):
reports are anonymous, with only the error stack trace and information given
by `conda info` being sent.
"""),
'restore_free_channel': dals(""""
Add the "free" channel back into defaults, behind "main" in priority. The "free"
channel was removed from the collection of default channels in conda 4.7.0.
"""),
'rollback_enabled': dals("""
Should any error occur during an unlink/link transaction, revert any disk
mutations made to that point in the transaction.
Expand Down
115 changes: 113 additions & 2 deletions conda/core/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def make_install_plan(conda_prefix):
plan.append({
'function': install_conda_xsh.__name__,
'kwargs': {
'target_path': join(site_packages_dir, 'xonsh', 'conda.xsh'),
'target_path': join(site_packages_dir, 'xontrib', 'conda.xsh'),
'conda_prefix': conda_prefix,
},
})
Expand Down Expand Up @@ -493,6 +493,32 @@ def make_initialize_plan(conda_prefix, shells, for_user, for_system, anaconda_pr
},
})

if 'xonsh' in shells:
if for_user:
config_xonsh_path = expand(join('~', '.xonshrc'))
plan.append({
'function': init_xonsh_user.__name__,
'kwargs': {
'target_path': config_xonsh_path,
'conda_prefix': conda_prefix,
'reverse': reverse,
},
})

if for_system:
if on_win:
config_xonsh_path = expand(join('%ALLUSERSPROFILE%', 'xonsh', 'xonshrc'))
else:
config_xonsh_path = '/etc/xonshrc'
plan.append({
'function': init_xonsh_user.__name__,
'kwargs': {
'target_path': config_xonsh_path,
'conda_prefix': conda_prefix,
'reverse': reverse,
},
})

if 'tcsh' in shells and for_user:
tcshrc_path = expand(join('~', '.tcshrc'))
plan.append({
Expand Down Expand Up @@ -973,7 +999,7 @@ def _config_fish_content(conda_prefix):
conda_initialize_content = dals("""
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
eval (eval %(conda_exe)s "shell.fish" "hook" $argv)
eval %(conda_exe)s "shell.fish" "hook" $argv | source
# <<< conda initialize <<<
""") % {
'conda_exe': conda_exe,
Expand Down Expand Up @@ -1066,6 +1092,91 @@ def init_fish_user(target_path, conda_prefix, reverse):
return Result.NO_CHANGE


def _config_xonsh_content(conda_prefix):
if on_win:
from ..activate import native_path_to_unix
conda_exe = native_path_to_unix(join(conda_prefix, 'Scripts', 'conda.exe'))
else:
conda_exe = join(conda_prefix, 'bin', 'conda')
conda_initialize_content = dals("""
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
import sys as _sys
from types import ModuleType as _ModuleType
_mod = _ModuleType("xontrib.conda",
"Autogenerated from $({conda_exe} shell.xonsh hook)")
__xonsh__.execer.exec($("{conda_exe}" "shell.xonsh" "hook"),
glbs=_mod.__dict__,
filename="$({conda_exe} shell.xonsh hook)")
_sys.modules["xontrib.conda"] = _mod
del _sys, _mod, _ModuleType
# <<< conda initialize <<<
""").format(conda_exe=conda_exe)
return conda_initialize_content


def init_xonsh_user(target_path, conda_prefix, reverse):
# target_path: ~/.xonshrc
user_rc_path = target_path

try:
with open(user_rc_path) as fh:
rc_content = fh.read()
except FileNotFoundError:
rc_content = ''
except:
raise

rc_original_content = rc_content

conda_init_comment = "# commented out by conda initialize"
conda_initialize_content = _config_xonsh_content(conda_prefix)
if reverse:
# uncomment any lines that were commented by prior conda init run
rc_content = re.sub(
r"#\s(.*?)\s*{}".format(conda_init_comment),
r"\1",
rc_content,
flags=re.MULTILINE,
)

# remove any conda init sections added
rc_content = re.sub(
r"^\s*" + CONDA_INITIALIZE_RE_BLOCK,
"",
rc_content,
flags=re.DOTALL | re.MULTILINE
)
else:
replace_str = "__CONDA_REPLACE_ME_123__"
rc_content = re.sub(
CONDA_INITIALIZE_RE_BLOCK,
replace_str,
rc_content,
flags=re.MULTILINE,
)
# TODO: maybe remove all but last of replace_str, if there's more than one occurrence
rc_content = rc_content.replace(replace_str, conda_initialize_content)

if "# >>> conda initialize >>>" not in rc_content:
rc_content += '\n{0}\n'.format(conda_initialize_content)

if rc_content != rc_original_content:
if context.verbosity:
print('\n')
print(target_path)
print(make_diff(rc_original_content, rc_content))
if not context.dry_run:
# Make the directory if needed.
if not exists(dirname(user_rc_path)):
mkdir_p(dirname(user_rc_path))
with open(user_rc_path, 'w') as fh:
fh.write(rc_content)
return Result.MODIFIED
else:
return Result.NO_CHANGE


def _bashrc_content(conda_prefix, shell):
if on_win:
from ..activate import native_path_to_unix
Expand Down
Loading

0 comments on commit 32aaae3

Please sign in to comment.