Skip to content

Commit

Permalink
initial scripts stab
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethreitz committed Jan 16, 2018
1 parent 761073f commit 6703339
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
2 changes: 2 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
9.1.0:
- Support for [scripts]!
9.0.2:
- Massive booting speedups, thanks to module lazy-loading.
- PIP_INDEX_URL and PIP_EXTRA_INDEX_URL will automatically be honored, when creating a new Pipfile.
Expand Down
4 changes: 4 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ pytest-xdist = "*"
[packages]

"e1839a8" = {path = ".", editable = true}

[scripts]

test = "make test"
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.2'
__version__ = '9.1.0'
22 changes: 14 additions & 8 deletions pipenv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
from glob import glob
import json as simplejson

import lazyload
for module in [
'urllib3', 'background', 'dotenv', 'delegator', 'pexpect',
'requests', 'pip', 'pipfile', 'pipdeptree', 'requirements',
'semver', 'flake8', 'pipreqs', 'blindspin', 'click_didyoumean',
'.project', '.utils', 'click', 'dotenv'
]:
lazyload.make_lazy(module)
# Skip lazy-loading in Travis environment.
if 'CI' not in os.environ:
import lazyload
for module in [
'urllib3', 'background', 'dotenv', 'delegator', 'pexpect',
'requests', 'pip', 'pipfile', 'pipdeptree', 'requirements',
'semver', 'flake8', 'pipreqs', 'blindspin', 'click_didyoumean',
'.project', '.utils', 'click', 'dotenv'
]:
lazyload.make_lazy(module)

import urllib3
import background
Expand Down Expand Up @@ -2251,6 +2253,10 @@ def run(command, args, three=None, python=False):
# Activate virtualenv under the current interpreter's environment
inline_activate_virtualenv()

# If script is defined, load that instead.
if command in project.scripts:
command = project.scripts[command]

# Windows!
if os.name == 'nt':
import subprocess
Expand Down
9 changes: 9 additions & 0 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ def lockfile_content(self):
with open(self.lockfile_location) as lock:
return json.load(lock)

@property
def scripts(self):
"""Returns a dictionry of scripts, defined in the Pipfile."""
scripts = {}
for k, v in self.parsed_pipfile.get('scripts', {}).items():
scripts[k] = v

return scripts

@property
def vcs_packages(self):
"""Returns a list of VCS packages, for not pip-tools to consume."""
Expand Down
11 changes: 6 additions & 5 deletions pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
except ImportError:
from pathlib2 import Path

import lazyload
for module in [
'piptools', 'contetxlib', 'distutils'
]:
lazyload.make_lazy(module)
if 'CI' not in os.environ:
import lazyload
for module in [
'piptools', 'contextlib', 'distutils'
]:
lazyload.make_lazy(module)


from distutils.spawn import find_executable
Expand Down

0 comments on commit 6703339

Please sign in to comment.