def checksum(self): """ The SHA1 checksum of the requirement's source distribution archive(s) (a string). The value of this property is based on the :attr:`related_archives` property. If no related archives are found the SHA1 digest of the empty string is reported. """ return hash_files('sha1', *sorted(self.related_archives))
def decorate_arguments(self, arguments): """ Change pathnames of local files into ``file://`` URLs with ``#md5=...`` fragments. :param arguments: The command line arguments to ``pip install ...`` (a list of strings). :returns: A copy of the command line arguments with pathnames of local files rewritten to ``file://`` URLs. When pip-accel calls pip to download missing distribution archives and the user specified the pathname of a local distribution archive on the command line, pip will (by default) *not* copy the archive into the download directory if an archive for the same package name and version is already present. This can lead to the confusing situation where the user specifies a local distribution archive to install, a different (older) archive for the same package and version is present in the download directory and `pip-accel` installs the older archive instead of the newer archive. To avoid this confusing behavior, the :func:`decorate_arguments()` method rewrites the command line arguments given to ``pip install`` so that pathnames of local archives are changed into ``file://`` URLs that include a fragment with the hash of the file's contents. Here's an example: - Local pathname: ``/tmp/pep8-1.6.3a0.tar.gz`` - File URL: ``file:///tmp/pep8-1.6.3a0.tar.gz#md5=19cbf0b633498ead63fb3c66e5f1caf6`` When pip fills the download directory and encounters a previously cached distribution archive it will check the hash, realize the contents have changed and replace the archive in the download directory. """ arguments = list(arguments) for i, value in enumerate(arguments): is_constraint_file = (i >= 1 and match_option( arguments[i - 1], '-c', '--constraint')) is_requirement_file = (i >= 1 and match_option( arguments[i - 1], '-r', '--requirement')) if not is_constraint_file and not is_requirement_file and os.path.isfile( value): arguments[i] = '%s#md5=%s' % (create_file_url(value), hash_files('md5', value)) return arguments
def decorate_arguments(self, arguments): """ Change pathnames of local files into ``file://`` URLs with ``#md5=...`` fragments. :param arguments: The command line arguments to ``pip install ...`` (a list of strings). :returns: A copy of the command line arguments with pathnames of local files rewritten to ``file://`` URLs. When pip-accel calls pip to download missing distribution archives and the user specified the pathname of a local distribution archive on the command line, pip will (by default) *not* copy the archive into the download directory if an archive for the same package name and version is already present. This can lead to the confusing situation where the user specifies a local distribution archive to install, a different (older) archive for the same package and version is present in the download directory and `pip-accel` installs the older archive instead of the newer archive. To avoid this confusing behavior, the :func:`decorate_arguments()` method rewrites the command line arguments given to ``pip install`` so that pathnames of local archives are changed into ``file://`` URLs that include a fragment with the hash of the file's contents. Here's an example: - Local pathname: ``/tmp/pep8-1.6.3a0.tar.gz`` - File URL: ``file:///tmp/pep8-1.6.3a0.tar.gz#md5=19cbf0b633498ead63fb3c66e5f1caf6`` When pip fills the download directory and encounters a previously cached distribution archive it will check the hash, realize the contents have changed and replace the archive in the download directory. """ arguments = list(arguments) for i, value in enumerate(arguments): is_constraint_file = (i >= 1 and match_option(arguments[i - 1], '-c', '--constraint')) is_requirement_file = (i >= 1 and match_option(arguments[i - 1], '-r', '--requirement')) if not is_constraint_file and not is_requirement_file and os.path.isfile(value): arguments[i] = '%s#md5=%s' % (create_file_url(value), hash_files('md5', value)) return arguments