Skip to content

Commit

Permalink
fix flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Apr 18, 2018
1 parent 77cd462 commit b28a1f4
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 56 deletions.
79 changes: 40 additions & 39 deletions conda/cli/conda_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,69 +537,70 @@ def configure_parser_init(sub_parsers):
descr = help

epilog = dedent("""
Key parts of conda's functionality require that it interact directly with the shell
within which conda is being invoked. The `conda activate` and `conda deactivate` commands
specifically are shell-level commands. That is, they affect the state (e.g. environment
variables) of the shell context being interacted with. Other core commands, like
`conda create` and `conda install`, also necessarily interact with the shell environment.
They're therefore implemented in ways specific to each shell. Each shell must be configured
Key parts of conda's functionality require that it interact directly with the shell
within which conda is being invoked. The `conda activate` and `conda deactivate` commands
specifically are shell-level commands. That is, they affect the state (e.g. environment
variables) of the shell context being interacted with. Other core commands, like
`conda create` and `conda install`, also necessarily interact with the shell environment.
They're therefore implemented in ways specific to each shell. Each shell must be configured
to make use of them.
Examples:
# Make the conda command available in all detected shells for the *current user*.
# For example, if the bash shell is among those detected on your system, this command
# will modify your user's `~/.bashrc` file (`~/.bash_profile` on macOS). In addition to,
# the 'conda' command being made available, the 'base' conda environment is automatically
# activated (i.e. environment variables set and all executables put on PATH).
$ conda init
# Make the conda command available to every user on the system. For example, if the bash
# Make the conda command available to every user on the system. For example, if the bash
# shell is among those detected on your system, a file `/etc/profile.d/conda.sh` will be
# created, which will be sourced when your shell is initialized.
$ conda init --system
# Initialize conda in all detected shells for the current user. Additionally, make *only*
# the 'conda' command available to the shell, and *do not* automatically activate the
# base environment. Executables in the base environment, like python, will not be
# the 'conda' command available to the shell, and *do not* automatically activate the
# base environment. Executables in the base environment, like python, will not be
# available on PATH until running 'conda activate base'.
$ conda init --no-auto-activate
# When executed from a bash shell, ensure that conda is properly installed in the prefix
# for the first python on PATH (e.g. following a `python -m pip install conda`). Make the
# 'conda' command available to the current shell process, and activate the 'base'
# When executed from a bash shell, ensure that conda is properly installed in the prefix
# for the first python on PATH (e.g. following a `python -m pip install conda`). Make the
# 'conda' command available to the current shell process, and activate the 'base'
# environment. Does not modify `~/.bashrc` for example, so has no effect on future shell
# sessions.
$ eval `python -m conda init --install-only bash`
IMPORTANT: After running `conda init`, most shells will need to be closed and restarted
for changes to take effect.
""")
dev_example = dedent("""
# An example for creating an environment to develop on conda's own code. Clone the
# conda repo and install a dedicated miniconda within it. Remove all remnants of
# conda source files in the `site-packages` directory associated with
# `~/conda/devenv/bin/python`. Write a `conda.pth` file in that `site-packages`
# directory pointing to source code in `~/conda`, the current working directory.
# 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`
""")

# dev_example = dedent("""
# # An example for creating an environment to develop on conda's own code. Clone the
# # conda repo and install a dedicated miniconda within it. Remove all remnants of
# # conda source files in the `site-packages` directory associated with
# # `~/conda/devenv/bin/python`. Write a `conda.pth` file in that `site-packages`
# # directory pointing to source code in `~/conda`, the current working directory.
# # 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`
#
#
# """)

p = sub_parsers.add_parser(
'init',
description=descr,
Expand Down
2 changes: 0 additions & 2 deletions conda/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

import sys

import os

PARSER = None


Expand Down
4 changes: 2 additions & 2 deletions conda/cli/main_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def pip_installed_post_parse_hook(args, p):
if args.cmd not in ('init', 'info'):
raise CondaError(dals("""
Conda has not been initialized.
To enable full conda functionality, please run 'conda init'.
For additional information, see 'conda init --help'.
"""))


Expand Down
2 changes: 0 additions & 2 deletions conda/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ def xsh(self):

on_win = bool(sys.platform == "win32")



"""
eval "$(conda hook posix)"
Expand Down
24 changes: 13 additions & 11 deletions conda/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def _get_python_info(prefix):
else: # pragma: no cover
raise ValueError("No python version information available.")

site_packages_dir = join(prefix, win_path_ok(get_python_site_packages_short_path(python_version)))
site_packages_dir = join(prefix,
win_path_ok(get_python_site_packages_short_path(python_version)))
return python_exe, python_version, site_packages_dir


Expand Down Expand Up @@ -101,7 +102,7 @@ def initialize_dev(shell, dev_env_prefix=None, conda_source_dir=None):
builder = [
"export PYTHON_MAJOR_VERSION='%s'" % python_version[0],
"export TEST_PLATFORM='%s'" % ('win' if sys.platform.startswith('win') else 'unix'),
"export PYTHONHASHSEED='%d'" % randint(0,4294967296),
"export PYTHONHASHSEED='%d'" % randint(0, 4294967296),
"export _CONDA_ROOT='%s'" % conda_source_dir,
". conda/shell/etc/profile.d/conda.sh",
"conda activate '%s'" % dev_env_prefix,
Expand Down Expand Up @@ -256,8 +257,8 @@ def run_plan_elevated(plan):
if any(step['result'] == Result.NEEDS_SUDO for step in plan):
stdin = json.dumps(plan)
if on_win:
# https://github.com/ContinuumIO/menuinst/blob/master/menuinst/windows/win_elevate.py # no stdin / stdout / stderr pipe support
# https://github.com/saltstack/salt-windows-install/blob/master/deps/salt/python/App/Lib/site-packages/win32/Demos/pipes/runproc.py
# https://github.com/ContinuumIO/menuinst/blob/master/menuinst/windows/win_elevate.py # no stdin / stdout / stderr pipe support # NOQA
# https://github.com/saltstack/salt-windows-install/blob/master/deps/salt/python/App/Lib/site-packages/win32/Demos/pipes/runproc.py # NOQA
# https://github.com/twonds/twisted/blob/master/twisted/internet/_dumbwin32proc.py
# https://stackoverflow.com/a/19982092/2127762
# https://www.codeproject.com/Articles/19165/Vista-UAC-The-Definitive-Guide
Expand All @@ -266,8 +267,8 @@ def run_plan_elevated(plan):
result = subprocess_call(
'sudo %s -m conda.initialize' % sys.executable,
env={},
cwd=os.getcwd(),
stdin=stdin,
path=os.getcwd(),
stdin=stdin
)
stderr = result.stderr.strip()
if stderr:
Expand All @@ -292,7 +293,8 @@ def print_plan_results(plan, stream=sys.stdout):

changed = any(step['result'] == Result.MODIFIED for step in plan)
if changed:
print("\n==> For changes to take effect, close and re-open your current shell. <==\n", file=stream)
print("\n==> For changes to take effect, close and re-open your current shell. <==\n",
file=stream)
else:
print("No action taken.", file=stream)

Expand Down Expand Up @@ -485,7 +487,8 @@ def init_conda_fish(target_path, conda_prefix):

if on_win:
new_conda_fish = 'set _CONDA_ROOT (cygpath %s)\n' % conda_prefix
new_conda_fish += 'set _CONDA_EXE (cygpath %s)\n' % join(conda_prefix, 'Scripts', 'conda.exe')
new_conda_fish += 'set _CONDA_EXE (cygpath %s)\n' % join(conda_prefix,
'Scripts', 'conda.exe')
else:
new_conda_fish = 'set _CONDA_ROOT "%s"\n' % conda_prefix
new_conda_fish += 'set _CONDA_EXE "%s"\n' % join(conda_prefix, 'bin', 'conda')
Expand Down Expand Up @@ -544,7 +547,8 @@ def init_conda_csh(target_path, conda_prefix):

if on_win:
new_conda_csh = 'setenv _CONDA_ROOT `cygpath %s`\n' % conda_prefix
new_conda_csh += 'setenv _CONDA_EXE `cygpath %s`\n' % join(conda_prefix, 'Scripts', 'conda.exe')
new_conda_csh += 'setenv _CONDA_EXE `cygpath %s`\n' % join(conda_prefix,
'Scripts', 'conda.exe')
else:
new_conda_csh = 'setenv _CONDA_ROOT "%s"\n' % conda_prefix
new_conda_csh += 'setenv _CONDA_EXE "%s"\n' % join(conda_prefix, 'bin', 'conda')
Expand Down Expand Up @@ -600,5 +604,3 @@ def make_conda_pth(target_path, conda_source_dir):

if __name__ == "__main__":
run_plan_from_stdin()


0 comments on commit b28a1f4

Please sign in to comment.