Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def from_data(cls, data):
sources = [
sections.Source.load(s)
for s in data.pop("source", DEFAULT_SOURCES)
]
requires = sections.Requires.load(data.pop("requires", {}))
packages = {
k: Requirement.from_pipfile(k, s)
for k, s in data.pop("packages", {}).items()
}
dev_packages = {
k: Requirement.from_pipfile(k, s)
for k, s in data.pop("dev-packages", {}).items()
}
return cls(
packages=packages, dev_packages=dev_packages,
sources=sources, requires=requires, data=data,
)
groupcoll = _group_installed_names(self.packages)
installed = set()
updated = set()
cleaned = set()
# TODO: Show a prompt to confirm cleaning. We will need to implement a
# reporter pattern for this as well.
if self.clean_unneeded:
names = _clean(groupcoll.unneeded)
cleaned.update(names)
# TODO: Specify installation order? (pypa/pipenv#2274)
installers = []
for name, package in self.packages.items():
r = requirementslib.Requirement.from_pipfile(name, package)
name = r.normalized_name
if name in groupcoll.uptodate:
continue
markers = r.markers
if markers and not packaging.markers.Marker(markers).evaluate():
continue
r.markers = None
if r.editable:
installer = EditableInstaller(r)
else:
installer = WheelInstaller(r, self.sources, self.paths)
try:
installer.prepare()
except Exception as e:
if os.environ.get("PASSA_NO_SUPPRESS_EXCEPTIONS"):
raise
def freeze(project=None, default=True, dev=True, include_hashes=None, target=None):
from requirementslib import Requirement
lockfile = project.lockfile
if not lockfile:
print("Pipfile.lock is required to export.", file=sys.stderr)
return 1
section_names = []
if default:
section_names.append("default")
if dev:
section_names.append("develop")
requirements = [
Requirement.from_pipfile(key, entry._data)
for key, entry in itertools.chain.from_iterable(
lockfile.get(name, {}).items()
for name in section_names
)
]
if include_hashes is None:
include_hashes = all(r.is_named for r in requirements)
sources = lockfile.meta.sources._data
source_lines = list(vistir.misc.dedup(itertools.chain(
itertools.chain.from_iterable(
_source_as_lines(source, False)
for source in sources[:1]
),
def _get_requirements(pipfile, section_name):
"""Produce a mapping of identifier: requirement from the section.
"""
return {identify_requirment(r): r for r in (
Requirement.from_pipfile(name, package._data)
for name, package in pipfile.get(section_name, {}).items()
)}