mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Include markers when they are included at top lvl
Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
+13
-5
@@ -1007,6 +1007,8 @@ def do_lock(
|
||||
write=True,
|
||||
):
|
||||
"""Executes the freeze functionality."""
|
||||
from notpip._vendor.distlib.markers import Evaluator
|
||||
allowed_marker_keys = ['markers'] + [k for k in Evaluator.allowed_values.keys()]
|
||||
cached_lockfile = {}
|
||||
if keep_outdated:
|
||||
if not project.lockfile_exists:
|
||||
@@ -1064,9 +1066,12 @@ def do_lock(
|
||||
# Add index metadata to lockfile.
|
||||
if 'index' in dep:
|
||||
lockfile['develop'][dep['name']]['index'] = dep['index']
|
||||
# Add PEP 508 specifier metadata to lockfile if dep isnt top level.
|
||||
if 'markers' in dep and not any(dep['name'] in section for section in [dev_packages, project.packages]):
|
||||
lockfile['develop'][dep['name']]['markers'] = dep['markers']
|
||||
# Add PEP 508 specifier metadata to lockfile if dep isnt top level
|
||||
# or top level dep doesn't itself have markers
|
||||
if 'markers' in dep:
|
||||
if dep['name'] in dev_packages and not any(key in dev_packages[dep['name']] for key in allowed_marker_keys):
|
||||
continue
|
||||
lockfile['develop'][dep['name']]['markers'] = dep[marker_key]
|
||||
# Add refs for VCS installs.
|
||||
# TODO: be smarter about this.
|
||||
vcs_deps = convert_deps_to_pip(project.vcs_dev_packages, project, r=False)
|
||||
@@ -1120,8 +1125,11 @@ def do_lock(
|
||||
# Add index metadata to lockfile.
|
||||
if 'index' in dep:
|
||||
lockfile['default'][dep['name']]['index'] = dep['index']
|
||||
# Add PEP 508 specifier metadata to lockfile if dep isn't top level.
|
||||
if 'markers' in dep and dep['name'] not in project.packages:
|
||||
# Add PEP 508 specifier metadata to lockfile if dep isn't top level
|
||||
# or top level dep has no specifiers itself
|
||||
if 'markers' in dep:
|
||||
if dep['name'] in project.packages and not any(key in project.packages[dep['name']] for key in allowed_marker_keys):
|
||||
continue
|
||||
lockfile['default'][dep['name']]['markers'] = dep['markers']
|
||||
# Add refs for VCS installs.
|
||||
# TODO: be smarter about this.
|
||||
|
||||
@@ -558,9 +558,9 @@ tpfd = "*"
|
||||
@pytest.mark.run
|
||||
@pytest.mark.markers
|
||||
@pytest.mark.install
|
||||
def test_package_environment_markers(self):
|
||||
def test_package_environment_markers(self, pypi):
|
||||
|
||||
with PipenvInstance() as p:
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
contents = """
|
||||
[packages]
|
||||
@@ -570,7 +570,6 @@ requests = {version = "*", markers="os_name=='splashwear'"}
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
|
||||
assert 'Ignoring' in c.out
|
||||
assert 'markers' in p.lockfile['default']['requests']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user