Skip to content

Commit

Permalink
Allow for adding requirements objects directly to pipfile
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed Sep 4, 2018
1 parent 337a98d commit e484256
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ def do_install(
)
# Add the package to the Pipfile.
try:
project.add_package_to_pipfile(pkg_requirement.as_line(), dev)
project.add_package_to_pipfile(pkg_requirement, dev)
except ValueError as e:
click.echo(
"{0} {1}".format(crayons.red("ERROR (PACKAGE NOT INSTALLED):"), e)
Expand Down
5 changes: 3 additions & 2 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,13 +770,14 @@ def remove_package_from_pipfile(self, package_name, dev=False):
del p[key][name]
self.write_toml(p)

def add_package_to_pipfile(self, package_name, dev=False):
def add_package_to_pipfile(self, package, dev=False):
from .vendor.requirementslib import Requirement

# Read and append Pipfile.
p = self.parsed_pipfile
# Don't re-capitalize file URLs or VCSs.
package = Requirement.from_line(package_name.strip())
if not isinstance(package, Requirement):
package = Requirement.from_line(package.strip())
_, converted = package.pipfile_entry
key = "dev-packages" if dev else "packages"
# Set empty group if it doesn't exist yet.
Expand Down

0 comments on commit e484256

Please sign in to comment.