Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kennethreitz/pipenv
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethreitz committed Jan 6, 2018
2 parents 462ffc3 + 7847324 commit 14b7c1a
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6.3
FROM python:3.6.4

# -- Install Pipenv:
RUN set -ex && pip install pipenv --upgrade
Expand Down
4 changes: 3 additions & 1 deletion HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- Fixed regression causing development packages to always be installed
9.0.1:
- Fixed issue with specifiers being treated as paths on Windows.
- Fixed regression causing development packages to always be installed.
9.0.0:
- Fixed bug where packages beginning with vcs names (e.g. git) weren't installed correctly.
- Fixed url parsing for <vcs>+<vcs>:// style urls.
Expand Down
10 changes: 7 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
pytest = "*"
mock = "*"
sphinx = "<=1.5.5"
"-e ." = "*"
twine = "*"
"sphinx-click" = "*"
"pytest-xdist" = "*"
sphinx-click = "*"
pytest-xdist = "*"


[packages]

"e1839a8" = {path = ".", editable = true}
6 changes: 0 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ Installation

$ pip install pipenv

Or if you are on macOS, you can install Pipenv via `Homebrew <https://brew.sh/>`_ with:

::

$ brew install pipenv

✨🍰✨

☤ User Testimonials
Expand Down
9 changes: 5 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ It automatically creates and manages a virtualenv for your projects, as well as
The problems that Pipenv seeks to solve are multi-faceted:

- You no longer need to use ``pip`` and ``virtualenv`` separately. They work together.
- Managing a ``requirements.txt`` file `can be problematic <https://www.kennethreitz.org/essays/a-better-pip-workflow>`_, so Pipenv uses the upcoming ``Pipfile`` and ``Pipfile.lock`` instead, which is superior for basic use cases.
- Managing a ``requirements.txt`` file `can be problematic <https://www.kennethreitz.org/essays/a-better-pip-workflow>`_, so Pipenv uses ``Pipfile`` and ``Pipfile.lock`` to separate abstract dependency declarations from the last tested combination.
- Hashes are used everywhere, always. Security. Automatically expose security vulnerabilities.
- Strongly encourage the use of the latest versions of dependencies to minimize security risks `arising from outdated components <https://www.owasp.org/index.php/Top_10-2017_A9-Using_Components_with_Known_Vulnerabilities>`_.
- Give you insight into your dependency graph (e.g. ``$ pipenv graph``).
- Streamline development workflow by loading ``.env`` files.

Expand All @@ -57,9 +58,9 @@ Pipenv is a python package and so can be installed using ``pip`` as you would ex
If you have excellent taste, there are various other installation methods which
prevent pipenv and its dependencies from interfering with the rest of your
Python installation. These include
`Pipsi <https://docs.pipenv.org/install.html#fancy-installation-of-pipenv>`_,
`Nix <https://docs.pipenv.org/install.html#referentially-transparent-installation-of-pipenv>`_
and `Homebrew <https://docs.pipenv.org/install.html#homebrew-installation-of-pipenv>`_.
`Pipsi <https://docs.pipenv.org/install/#fancy-installation-of-pipenv>`_,
`Nix <https://docs.pipenv.org/install/#referentially-transparent-installation-of-pipenv>`_
and `Homebrew <https://docs.pipenv.org/install/#homebrew-installation-of-pipenv>`_.

.. toctree::
:maxdepth: 2
Expand Down
17 changes: 0 additions & 17 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,6 @@ To upgrade pipenv at any time::

.. _crude_installation:

☤ Homebrew Installation of Pipenv
=================================

Homebrew is a popular open-source package management system for macOS.

Installing pipenv via Homebrew will keep pipenv and all of its dependencies in
an isolated virtual environment so it doesn't interfere with the rest of your
Python installation.

Once you have installed `Homebrew <https://brew.sh/>`_ simply run::

$ brew install pipenv

To upgrade pipenv at any time::

$ brew upgrade pipenv

☤ Crude Installation of Pipenv
==============================

Expand Down
2 changes: 1 addition & 1 deletion pipenv/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# //___/ / / / //___/ / // // / / || / /
# // / / // ((____ // / / ||/ /

__version__ = '9.0.0'
__version__ = '9.0.1'
56 changes: 29 additions & 27 deletions pipenv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def spinner():

def load_dot_env():
if not PIPENV_DONT_LOAD_ENV:
denv = dotenv.find_dotenv(PIPENV_DOTENV_LOCATION or os.sep.join([project.project_directory, '.env']))
# If the project doesn't exist yet, check current directory for a .env file
project_directory = project.project_directory or '.'

denv = dotenv.find_dotenv(PIPENV_DOTENV_LOCATION or os.sep.join([project_directory, '.env']))
if os.path.isfile(denv):
click.echo(crayons.normal('Loading .env environment variables…', bold=True), err=True)
dotenv.load_dotenv(denv, override=True)
Expand Down Expand Up @@ -783,7 +786,7 @@ def cleanup_procs(procs, concurrent):
# Allow pip to resolve dependencies when in skip-lock mode.
no_deps = (not skip_lock)

deps_list, dev_deps_list = merge_deps(
deps_list, requirements_deps_list = merge_deps(
lockfile,
project,
dev=dev,
Expand All @@ -794,15 +797,8 @@ def cleanup_procs(procs, concurrent):
)
failed_deps_list = []
if requirements:
# Output only default dependencies
if not dev:
click.echo('\n'.join(d[0] for d in deps_list))
sys.exit(0)

# Output only dev dependencies
if dev:
click.echo('\n'.join(d[0] for d in dev_deps_list))
sys.exit(0)
click.echo('\n'.join(d[0] for d in requirements_deps_list))
sys.exit(0)

procs = []

Expand Down Expand Up @@ -1035,7 +1031,8 @@ def do_lock(verbose=False, system=False, clear=False, pre=False):
which=which,
which_pip=which_pip,
project=project,
pre=pre
pre=pre,
allow_global=system
)

# Add develop dependencies to lockfile.
Expand Down Expand Up @@ -1096,7 +1093,8 @@ def do_lock(verbose=False, system=False, clear=False, pre=False):
which=which,
which_pip=which_pip,
project=project,
pre=pre
pre=pre,
allow_global=system
)

# Add default dependencies to lockfile.
Expand Down Expand Up @@ -1350,7 +1348,7 @@ def pip_install(

# Don't specify a source directory when using --system.
if not allow_global and ('PIP_SRC' not in os.environ):
src = '--src {0}'.format(project.virtualenv_src_location)
src = '--src "{0}"'.format(project.virtualenv_src_location)
else:
src = ''
else:
Expand Down Expand Up @@ -1794,26 +1792,31 @@ def install(
remote = True

if requirements:
error, traceback = None, None
click.echo(crayons.normal(u'Requirements file provided! Importing into Pipfile…', bold=True), err=True)
try:
import_requirements(r=project.path_to(requirements), dev=dev)
except (UnicodeDecodeError, pip.exceptions.PipError) as e:
# Don't print the temp file path if remote since it will be deleted.
req_path = requirements_url if remote else project.path_to(requirements)
click.echo(
crayons.red(
u'Unexpected syntax in {0}. Are you sure this is a '
'requirements.txt style file?'.format(req_path)
)
)
click.echo(crayons.blue(str(e)), err=True)
sys.exit(1)
error = (u'Unexpected syntax in {0}. Are you sure this is a '
'requirements.txt style file?'.format(req_path))
traceback = e
except AssertionError as e:
error = (u'Requirements file doesn\'t appear to exist. Please ensure the file exists in your '
'project directory or you provided the correct path.')
traceback = e
finally:
# If requirements file was provided by remote url delete the temporary file
if remote:
os.close(fd) # Close for windows to allow file cleanup.
os.remove(project.path_to(temp_reqs))

if error and traceback:
click.echo(crayons.red(error))
click.echo(crayons.blue(str(traceback)), err=True)
sys.exit(1)

if code:
click.echo(crayons.normal(u'Discovering imports from local codebase…', bold=True))
for req in import_from_code(code):
Expand Down Expand Up @@ -2040,7 +2043,6 @@ def uninstall(
@click.option('--clear', is_flag=True, default=False, help="Clear the dependency cache.")
@click.option('--pre', is_flag=True, default=False, help=u"Allow pre–releases.")
def lock(three=None, python=False, verbose=False, requirements=False, dev=False, clear=False, pre=False):

# Ensure that virtualenv is available.
ensure_project(three=three, python=python)

Expand All @@ -2056,6 +2058,9 @@ def lock(three=None, python=False, verbose=False, requirements=False, dev=False,

def do_shell(three=None, python=False, fancy=False, shell_args=None):

# Ensure that virtualenv is available.
ensure_project(three=three, python=python, validate=False)

# Set an environment variable, so we know we're in the environment.
os.environ['PIPENV_ACTIVE'] = '1'

Expand Down Expand Up @@ -2177,9 +2182,6 @@ def shell(three=None, python=False, fancy=False, shell_args=None, anyway=False):

sys.exit(1)

# Ensure that virtualenv is available.
ensure_project(three=three, python=python, validate=False)

# Load .env file.
load_dot_env()

Expand Down Expand Up @@ -2550,7 +2552,7 @@ def update(ctx, dev=False, three=None, python=None, dry_run=False, bare=False, d
do_purge()

# Lock.
do_lock(pre=pre)
do_lock(clear=clear, pre=pre)

# Install everything.
do_init(dev=dev, verbose=verbose, concurrent=concurrent)
Expand Down
2 changes: 1 addition & 1 deletion pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
PIPENV_YES = bool(os.environ.get('PIPENV_YES'))

# Tells Pipenv how many subprocesses to use when installing.
PIPENV_MAX_SUBPROCESS = int(os.environ.get('PIPENV_MAX_SUBPROCESS', '8'))
PIPENV_MAX_SUBPROCESS = int(os.environ.get('PIPENV_MAX_SUBPROCESS', '16'))

# User-configurable max-depth for Pipfile searching.
# Note: +1 because of a temporary bug in Pipenv.
Expand Down
11 changes: 7 additions & 4 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .utils import (
mkdir_p, convert_deps_from_pip, pep423_name, recase_file,
find_requirements, is_file, is_vcs, python_version, cleanup_toml,
is_installable_file, is_valid_url
is_installable_file, is_valid_url, normalize_drive,
)
from .environments import PIPENV_MAX_DEPTH, PIPENV_VENV_IN_PROJECT
from .environments import PIPENV_VIRTUALENV, PIPENV_PIPFILE
Expand All @@ -23,7 +23,7 @@
if not os.path.isfile(PIPENV_PIPFILE):
raise RuntimeError('Given PIPENV_PIPFILE is not found!')
else:
PIPENV_PIPFILE = os.path.abspath(PIPENV_PIPFILE)
PIPENV_PIPFILE = normalize_drive(os.path.abspath(PIPENV_PIPFILE))


class Project(object):
Expand Down Expand Up @@ -109,7 +109,10 @@ def required_python_version(self):

@property
def project_directory(self):
return os.path.abspath(os.path.join(self.pipfile_location, os.pardir))
if self.pipfile_location is not None:
return os.path.abspath(os.path.join(self.pipfile_location, os.pardir))
else:
return None

@property
def requirements_exists(self):
Expand Down Expand Up @@ -221,7 +224,7 @@ def pipfile_location(self):
loc = pipfile.Pipfile.find(max_depth=PIPENV_MAX_DEPTH)
except RuntimeError:
loc = None
self._pipfile_location = loc
self._pipfile_location = normalize_drive(loc)

return self._pipfile_location

Expand Down

0 comments on commit 14b7c1a

Please sign in to comment.