This commit is contained in:
2017-01-20 17:45:26 -05:00
parent 4b18cf07c9
commit 3c6ef52cc2
4 changed files with 18 additions and 6 deletions
+1 -2
View File
@@ -3,7 +3,6 @@ url = "https://pypi.org/"
verify_ssl = true
[packages]
toml = "*"
crayons = "*"
"delegator.py" = "*"
toml = "*"
click = "*"
+1 -1
View File
@@ -1 +1 @@
{"default": {"crayons": "==0.1.1", "colorama": "==0.3.7", "daemon": "==1.1", "delegator.py": "==0.0.1", "pexpect": "==4.2.1", "toml": "==0.9.2", "click": "==6.7", "ptyprocess": "==0.5.1"}, "develop": {}, "_meta": {"sources": [{"url": "https://pypi.org/", "verify_ssl": true}], "requires": {}, "Pipfile-sha256": "5eb186a8c4b74d956d45fb4c7135a49bed60a8b884bbdcc5f5233562e88caef7"}}
{"default": {"colorama": "==0.3.7", "crayons": "==0.1.1", "toml": "==0.9.2", "click": "==6.7"}, "develop": {}, "_meta": {"sources": [{"url": "https://pypi.org/", "verify_ssl": true}], "requires": {}, "Pipfile-sha256": "8cfe2a7c071e7058f9a2cd8a8e6f02b6f3384eb2f8c107565e9ad8f98a0b10ed"}}
+4 -1
View File
@@ -116,7 +116,10 @@ class Pipfile(object):
if i < max_depth:
if 'Pipfile':
return '{}/Pipfile'.format(c)
p = '{}/Pipfile'.format(c)
if os.path.isfile(p):
return p
raise RuntimeError('No Pipfile found!')
@classmethod
def load(klass, filename):
+12 -2
View File
@@ -23,7 +23,7 @@ class Project(object):
@property
def pipfile_exists(self):
return self.pipfile_location
return bool(self.pipfile_location())
@staticmethod
def virtualenv_location():
@@ -31,7 +31,11 @@ class Project(object):
@staticmethod
def pipfile_location():
return pipfile.Pipfile.find()
try:
return pipfile.Pipfile.find()
except RuntimeError:
return None
def lockfile_location(self):
return '{}.freeze'.format(self.pipfile_location())
@@ -138,6 +142,7 @@ def convert_deps_from_pip(dep):
dependency[r[0]] = {'extras': r[1].split(',')}
# TODO: Editable installs.
# if dep.startswith('-e'):
# Bare dependencies: e.g. requests
else:
@@ -274,6 +279,9 @@ def do_freeze():
with open(project.lockfile_location(), 'w') as f:
f.write(json.dumps(lockfile))
click.echo(crayons.yellow('Note: ') + 'your project now has only default packages installed.')
click.echo('To install dev-packages, run: $ {}'.format(crayons.red('pipenv init --dev')))
def activate_virtualenv():
"""Returns the string to activate a virtualenv."""
return 'source {}/bin/activate'.format(project.virtualenv_location())
@@ -320,8 +328,10 @@ def cli(*args, **kwargs):
@click.option('--dev', '-d', is_flag=True, default=False)
def init(dev=False):
print project.pipfile_location
# Assert Pipfile exists.
if not project.pipfile_exists:
click.echo(crayons.yellow('Creating a Pipfile for this project...'))
# Create the pipfile if it doesn't exist.