mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge branch 'master' into activate-custom-virtualenv
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Update the index names in lock file when source name in Pipfile is changed.
|
||||
+5
-3
@@ -241,9 +241,11 @@ def get_resolver_metadata(deps, index_lookup, markers_lookup, project, sources):
|
||||
dep = " ".join(remainder)
|
||||
req = Requirement.from_line(dep)
|
||||
constraints.append(req.constraint_line)
|
||||
|
||||
if url:
|
||||
index_lookup[req.name] = project.get_source(url=url).get("name")
|
||||
source = first(
|
||||
s for s in sources if s.get("url") and url.startswith(s["url"]))
|
||||
if source:
|
||||
index_lookup[req.name] = source.get("name")
|
||||
# strip the marker and re-add it later after resolution
|
||||
# but we will need a fallback in case resolution fails
|
||||
# eg pypiwin32
|
||||
@@ -843,7 +845,7 @@ def convert_deps_to_pip(deps, project=None, r=True, include_index=True):
|
||||
|
||||
dependencies = []
|
||||
for dep_name, dep in deps.items():
|
||||
indexes = project.sources if hasattr(project, "sources") else []
|
||||
indexes = project.pipfile_sources if hasattr(project, "pipfile_sources") else []
|
||||
new_dep = Requirement.from_pipfile(dep_name, dep)
|
||||
if new_dep.index:
|
||||
include_index = True
|
||||
|
||||
@@ -129,7 +129,7 @@ class _Pipfile(object):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
self.document = tomlkit.document()
|
||||
self.document["sources"] = tomlkit.aot()
|
||||
self.document["source"] = tomlkit.aot()
|
||||
self.document["requires"] = tomlkit.table()
|
||||
self.document["packages"] = tomlkit.table()
|
||||
self.document["dev_packages"] = tomlkit.table()
|
||||
@@ -155,7 +155,7 @@ class _Pipfile(object):
|
||||
source_table["url"] = os.environ.get("PIPENV_TEST_INDEX")
|
||||
source_table["verify_ssl"] = False
|
||||
source_table["name"] = "pipenv_test_index"
|
||||
self.document["sources"].append(source_table)
|
||||
self.document["source"].append(source_table)
|
||||
return tomlkit.dumps(self.document)
|
||||
|
||||
def write(self):
|
||||
|
||||
@@ -564,3 +564,27 @@ def test_vcs_lock_respects_top_level_pins(PipenvInstance, pypi):
|
||||
assert "git" in p.lockfile["default"]["requests"]
|
||||
assert "urllib3" in p.lockfile["default"]
|
||||
assert p.lockfile["default"]["urllib3"]["version"] == "==1.21.1"
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
def test_lock_after_update_source_name(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi, chdir=True) as p:
|
||||
contents = """
|
||||
[[source]]
|
||||
url = "https://test.pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "test"
|
||||
|
||||
[packages]
|
||||
six = "*"
|
||||
""".strip()
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
f.write(contents)
|
||||
c = p.pipenv("lock")
|
||||
assert c.return_code == 0
|
||||
assert p.lockfile["default"]["six"]["index"] == "test"
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
f.write(contents.replace('name = "test"', 'name = "custom"'))
|
||||
c = p.pipenv("lock")
|
||||
assert c.return_code == 0
|
||||
assert p.lockfile["default"]["six"]["index"] == "custom"
|
||||
|
||||
Reference in New Issue
Block a user