Fix a bug that index url is not correctly saved in Pipfile

This commit is contained in:
Frost Ming
2021-11-18 12:48:24 +08:00
parent 3dec34cae9
commit 317a39762c
2 changed files with 12 additions and 6 deletions
+7 -2
View File
@@ -2039,8 +2039,6 @@ def do_install(
sp.write_err(vistir.compat.fs_str("{}: {}".format(crayons.red("WARNING"), e)))
sp.red.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format("Installation Failed"))
sys.exit(1)
if index_url:
pkg_requirement.index = index_url
no_deps = False
sp.text = "Installing..."
try:
@@ -2110,6 +2108,13 @@ def do_install(
)
))
# Add the package to the Pipfile.
indexes = list(filter(None, [index_url, extra_index_url]))
for index in indexes:
index_name = project.add_index_to_pipfile(
index, verify_ssl=index.startswith("https:")
)
if index_url and not extra_index_url:
pkg_requirement.index = index_name
try:
project.add_package_to_pipfile(pkg_requirement, dev)
except ValueError:
+5 -4
View File
@@ -1006,19 +1006,20 @@ class Project:
# Read and append Pipfile.
p = self.parsed_pipfile
try:
self.get_source(url=index)
source = self.get_source(url=index)
except SourceNotFound:
source = {"url": index, "verify_ssl": verify_ssl}
else:
return
return source["name"]
source["name"] = self.src_name_from_url(index)
# Add the package to the group.
if "source" not in p:
p["source"] = [source]
p["source"] = [tomlkit.item(source)]
else:
p["source"].append(source)
p["source"].append(tomlkit.item(source))
# Write Pipfile.
self.write_toml(p)
return source["name"]
def recase_pipfile(self):
if self.ensure_proper_casing():