From 4ffeaa9fa38d4b480db570a7ebe4d1fd4ff74944 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 21 Jan 2017 18:24:03 -0500 Subject: [PATCH] simplification --- README.rst | 14 ++++++++++++-- pipenv/cli.py | 12 +++--------- pipenv/project.py | 4 ++++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 2f45c3e4..06273916 100644 --- a/README.rst +++ b/README.rst @@ -16,13 +16,24 @@ It automatically creates and manages a virtualenv for your projects, as well as - Automatically removes packages from a Pipfile when they are un-installed. - Also automatically updates pip. -The main commands are ``init``, which initializes the environment, ``install`` and ``uninstall``, and ``lock``, which generates a ``Pipfile.lock``. These are intended to replace ``$ pip install`` usage, as well as manual virtualenv management. +The main commands are ```install``, ``uninstall``, and ``lock``, which generates a ``Pipfile.lock``. These are intended to replace ``$ pip install`` usage, as well as manual virtualenv management. + +Basic Concepts +////////////// + +- When no parameters are passed to ``install``, a virtualenv will be created if it doesn't exist, and all packages specified will be installed. +- When no parameters are passed to ``uninstall``, all packages will be uninstalled. + +Other Commands +////////////// - ``shell`` will spawn a shell with the virtualenv activated. - ``python`` will run the Python interpreter from the virtualenv, with any arguments forwarded. - ``where`` will give location information about the current project. - ``check`` asserts that PEP 508 requirements are being met by the current environment. + + ☤ Usage ------- @@ -37,7 +48,6 @@ The main commands are ``init``, which initializes the environment, ``install`` a Commands: check - init install lock python diff --git a/pipenv/cli.py b/pipenv/cli.py index 688fee0b..f155791f 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -179,7 +179,8 @@ def do_init(dev=False, skip_virtualenv=False): # Display where the Project is established. do_where(bare=False) - if not skip_virtualenv: + + if not project.virtualenv_exists: click.echo(crayons.yellow('Creating a virtualenv for this project...')) # Actually create the virtualenv. @@ -243,12 +244,6 @@ def cli(*args, **kwargs): pass -@click.command() -@click.option('--dev', '-d', is_flag=True, default=False) -def init(dev=False): - do_init(dev=dev) - - @click.command() @click.option('--virtualenv', '--venv', '-v', is_flag=True, default=False) @click.option('--bare', '-b', is_flag=True, default=False) @@ -264,7 +259,7 @@ def install(package_name=False, dev=False): # Install all dependencies, if none was provided. if package_name is False: click.echo(crayons.yellow('No package provided, installing all dependencies.')) - do_init(dev=dev, skip_virtualenv=True) + do_init(dev=dev) sys.exit(1) click.echo('Installing {}...'.format(crayons.green(package_name))) @@ -358,7 +353,6 @@ def update(dev=False): # Install click commands. -cli.add_command(init) cli.add_command(where) cli.add_command(install) cli.add_command(uninstall) diff --git a/pipenv/project.py b/pipenv/project.py index e64179d0..44172cc7 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -20,6 +20,10 @@ class Project(object): def pipfile_exists(self): return bool(self.pipfile_location) + @property + def virtualenv_exists(self): + return os.path.isdir(self.virtualenv_location) + @property def virtualenv_location(self): return os.sep.join(self.pipfile_location.split(os.sep)[:-1] + ['.venv'])