id
int64
0
1.29M
original_id
stringlengths
32
32
swhid
stringlengths
100
170
sha1
stringlengths
40
40
repo_name
stringlengths
2
45
repo_group
stringclasses
12 values
filepath
stringlengths
5
153
name
stringlengths
1
14.9k
type
stringclasses
3 values
code
stringlengths
7
2.12M
600
edc6404a3d9895006d56afaa46df182d
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1381-1389/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
write_to_version_file(filename, versions)
function
def write_to_version_file(filename, versions): """Write the given version number to the given _version.py file.""" os.unlink(filename) contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": ")) with open(filename, "w") as f: f.write(SHORT_VERSION_...
601
8408b0dbf9fc95a9fc3727ee4fddeea1
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1488-1512/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
render_pep440_post(pieces)
function
def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards (a dirty tree will appear "older" than the corresponding clean one), but you shouldn't be releasing software with -dirty anyways. Exceptions: 1: no tags. 0.postDISTANCE[...
602
4a4a5a5491ddc052d54e32f83dc5da15
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1722-1724/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_version()
function
def get_version(): """Get the short version string for this project.""" return get_versions()["version"]
603
73970bfd5a45b9a0e8597ff8783f3503
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1906-1912/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_cmdclass::cmd_sdist::run(self)
function
def run(self): versions = get_versions() self._versioneer_generated_versions = versions # unless we update this, the command will keep using the old # version self.distribution.metadata.version = versions["version"] return _sdist.run(self)
604
cb59d21152b9d1a85692448ce8203b96
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=297-333/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_root()
function
def get_root(): """Get the project root directory. We require that all commands are run from the project root, i.e. the directory that contains setup.py, setup.cfg, and versioneer.py . """ root = os.path.realpath(os.path.abspath(os.getcwd())) setup_py = os.path.join(root, "setup.py") versio...
605
3956ae9708ad3e76ddb638ac3b6d9ae9
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1392-1396/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
plus_or_dot(pieces)
function
def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+"
606
d1f4a5814ce826d605ffea4748d081dc
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1515-1541/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
render_pep440_post_branch(pieces)
function
def render_pep440_post_branch(pieces): """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . The ".dev0" means not master branch. Exceptions: 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dir...
607
b96fc8191c30801d5ccf7716aef104a2
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1646-1719/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_versions(verbose=False)
function
def get_versions(verbose=False): """Get the project version from whatever source is available. Returns dict with two keys: 'version' and 'full'. """ if "versioneer" in sys.modules: # see the discussion in cmdclass.py:get_cmdclass() del sys.modules["versioneer"] root = get_root() ...
608
1576eb6c09ac7b394c2835bef552459b
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1727-1927/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_cmdclass(cmdclass=None)
function
def get_cmdclass(cmdclass=None): """Get the custom setuptools/distutils subclasses used by Versioneer. If the package uses a different cmdclass (e.g. one from numpy), it should be provide as an argument. """ if "versioneer" in sys.modules: del sys.modules["versioneer"] # this fixes ...
609
272f52f2a6cfb8877708dd780f60fbf8
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1914-1924/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_cmdclass::cmd_sdist::make_release_tree(self, base_dir, files)
function
def make_release_tree(self, base_dir, files): root = get_root() cfg = get_config_from_root(root) _sdist.make_release_tree(self, base_dir, files) # now locate _version.py in the new base_dir directory # (remembering that it may be a hardlink) and replace it wit...
610
a83c049f185e1672081807442cbabf30
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1285-1319/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
do_vcs_install(manifest_in, versionfile_source, ipy)
function
def do_vcs_install(manifest_in, versionfile_source, ipy): """Git-specific installation logic for Versioneer. For Git, this means creating/changing .gitattributes to mark _version.py for export-subst keyword substitution. """ GITS = ["git"] if sys.platform == "win32": GITS = ["git.cmd", ...
611
beb9dc683f86ba0cc9b4644935bf5819
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1544-1563/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
render_pep440_old(pieces)
function
def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. Exceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += ".post%d" % piec...
612
4da22e71a5d13e35bd24499a7b3cfdfb
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1586-1603/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
render_git_describe_long(pieces)
function
def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] ...
613
3414c4fe67fc9709902856ee697e2711
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1798-1809/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_cmdclass::cmd_build_py::run(self)
function
def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() _build_py.run(self) # now locate _version.py in the new build/ directory and replace # it with an updated value if cfg.versionfile_build: ...
614
1156585eb91f340bf99eba653da2d0e8
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1322-1343/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
versions_from_parentdir(parentdir_prefix, root, verbose)
function
def versions_from_parentdir(parentdir_prefix, root, verbose): """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both the project name and a version string. We will also support searching up two directory levels for an ap...
615
2a98b1b4ef8667aecea796904eaf2aa5
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1566-1583/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
render_git_describe(pieces)
function
def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"]: rendered +=...
616
3fab8bc00e62824d90b08da661a02d93
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1606-1639/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
render(pieces, style)
function
def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", "full-revisionid": pieces.get("long"), "dirty": None, "error": pieces["error"], "date": None} ...
617
ff0bb2dc55c63445cfdcc3b8b26f2aa5
swh:1:cnt:1d6cd0796676e39ceb64a1eca3de4a68f1f79c28;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1764-1771/
2b6a520e2d20303fc551d84a0a9b2b550c676698
conda-pack
analytics
versioneer.py
get_cmdclass::cmd_version::run(self)
function
def run(self): vers = get_versions(verbose=True) print("Version: %s" % vers["version"]) print(" full-revisionid: %s" % vers.get("full-revisionid")) print(" dirty: %s" % vers.get("dirty")) print(" date: %s" % vers.get("date")) if vers["error"]: ...
618
4d3fbc8bf064cc336877182067d2c46a
swh:1:cnt:da3a9b4e179e32a64f5dc5dd15ec08c97f54ca6e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=9-18/
9dfd5db56ae3b941aa7e6fffe896a4708b374632
conda-pack
analytics
conda_pack/cli.py
MultiAppendAction
type
class MultiAppendAction(argparse.Action): def __init__(self, option_strings, dest, nargs=None, **kwargs): if nargs is not None: raise ValueError("nargs not allowed") super().__init__(option_strings, dest, **kwargs) def __call__(self, parser, namespace, values, option_string=None): ...
619
c6342d846bcdfe7947860110d1fb669b
swh:1:cnt:da3a9b4e179e32a64f5dc5dd15ec08c97f54ca6e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=10-13/
9dfd5db56ae3b941aa7e6fffe896a4708b374632
conda-pack
analytics
conda_pack/cli.py
MultiAppendAction::__init__(self, option_strings, dest, nargs=None, **kwargs)
function
def __init__(self, option_strings, dest, nargs=None, **kwargs): if nargs is not None: raise ValueError("nargs not allowed") super().__init__(option_strings, dest, **kwargs)
620
b189c4b0bbc0a81befece92c7f1ae339
swh:1:cnt:da3a9b4e179e32a64f5dc5dd15ec08c97f54ca6e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=21-130/
9dfd5db56ae3b941aa7e6fffe896a4708b374632
conda-pack
analytics
conda_pack/cli.py
build_parser()
function
def build_parser(): description = "Package an existing conda environment into an archive file." kwargs = dict(prog="conda-pack", description=description, add_help=False) kwargs["allow_abbrev"] = False parser = argparse.ArgumentParser(**kwargs) parser.add_argument("--name", "-n", ...
621
92f870bf5e5357c8ff9e660c6887e7b4
swh:1:cnt:da3a9b4e179e32a64f5dc5dd15ec08c97f54ca6e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=137-139/
9dfd5db56ae3b941aa7e6fffe896a4708b374632
conda-pack
analytics
conda_pack/cli.py
fail(msg)
function
def fail(msg): print(msg, file=sys.stderr) sys.exit(1)
622
60b1dcb421401d87cfc4bae50b338b13
swh:1:cnt:da3a9b4e179e32a64f5dc5dd15ec08c97f54ca6e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=142-177/
9dfd5db56ae3b941aa7e6fffe896a4708b374632
conda-pack
analytics
conda_pack/cli.py
main(args=None, pack=pack)
function
def main(args=None, pack=pack): args = PARSER.parse_args(args=args) # Manually handle version printing to output to stdout in python < 3.4 if args.version: print('conda-pack %s' % __version__) sys.exit(0) try: with context.set_cli(): pack(name=args.name, ...
623
c25449dd4dfae6b656a10624166567b5
swh:1:cnt:da3a9b4e179e32a64f5dc5dd15ec08c97f54ca6e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=15-18/
9dfd5db56ae3b941aa7e6fffe896a4708b374632
conda-pack
analytics
conda_pack/cli.py
MultiAppendAction::__call__(self, parser, namespace, values, option_string=None)
function
def __call__(self, parser, namespace, values, option_string=None): if getattr(namespace, self.dest) is None: setattr(namespace, self.dest, []) getattr(namespace, self.dest).append((option_string.strip('-'), values))
624
ab3b31306e9520adbc3fa620ea7689cd
swh:1:cnt:8d55e337c05d9561e10dad1f334bff9f4696f69b;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=18-21/
b2e8489781c7369e817550be3fa2c3968df89468
conda-pack
analytics
conda_pack/compat.py
source_from_cache(path)
function
def source_from_cache(path): if path.endswith('.pyc') or path.endswith('.pyo'): return path[:-1] raise ValueError("Path %s is not a python bytecode file" % path)
625
c874f0982f75dded82637ef69f9c2103
swh:1:cnt:8d55e337c05d9561e10dad1f334bff9f4696f69b;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=35-45/
b2e8489781c7369e817550be3fa2c3968df89468
conda-pack
analytics
conda_pack/compat.py
find_py_source(path, ignore=True)
function
def find_py_source(path, ignore=True): """Find the source file for a given bytecode file. If ignore is True, errors are swallowed and None is returned""" if not ignore: return source_from_cache(path) else: try: return source_from_cache(path) except (NotImplementedErr...
626
7ce573d4cab05a5015aed61e388be516
swh:1:cnt:8d55e337c05d9561e10dad1f334bff9f4696f69b;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=25-32/
b2e8489781c7369e817550be3fa2c3968df89468
conda-pack
analytics
conda_pack/compat.py
load_source(name, path)
function
# noqa def load_source(name, path): loader = importlib.machinery.SourceFileLoader(name, path) spec = importlib.util.spec_from_loader(loader.name, loader) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) return mod
627
c706663d5ed6ef3f3d0caf19e34a9320
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=24-26/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaPackException
type
class CondaPackException(Exception): """Internal exception to report to user""" pass
628
5c4262013eaf89add1f8733c1e56b04a
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=397-425/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
File
type
class File: """A single archive record. Parameters ---------- source : str Absolute path to the source. target : str Relative path from the target prefix (e.g. ``lib/foo/bar.py``). is_conda : bool, optional Whether the file was installed by conda, or comes from somewhere...
629
0897d331dd64981d6affef48ef252211
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1020-1186/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
Packer
type
class Packer: def __init__(self, prefix, archive, dest_prefix=None, parcel=None): self.prefix = prefix self.archive = archive self.dest = dest_prefix self.has_dest = dest_prefix is not None self.parcel = parcel self.prefixes = [] self.packages = [] def ad...
630
c925daf05077a84911959eb3c87c4da4
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=48-65/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
_Context
type
class _Context: def __init__(self): self.is_cli = False def warn(self, msg): if self.is_cli: print(msg + "\n", file=sys.stderr) else: warnings.warn(msg) @contextmanager def set_cli(self): old = self.is_cli try: self.is_cli = T...
631
b0e7909df6751eaf5a425aeb110b90ef
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=71-394/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv
type
class CondaEnv: """A Conda environment for packaging. Use :func:`CondaEnv.from_prefix`, :func:`CondaEnv.from_name`, or :func:`CondaEnv.from_default` instead of the default constructor. Attributes ---------- prefix : str The path to the conda environment. files : list of File ...
632
5bcc35ae73a649770bdd3914d3a501be
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=226-258/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::_output_and_format(self, output=None, format='infer')
function
def _output_and_format(self, output=None, format='infer'): if output is None and format == 'infer': format = 'tar.gz' elif format == 'infer': if output.endswith('.parcel'): format = 'parcel' elif output.endswith('.zip'): format = 'zip' ...
633
256e6a81dc5a14a497782ae529f5afc8
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1021-1028/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
Packer::__init__(self, prefix, archive, dest_prefix=None, parcel=None)
function
def __init__(self, prefix, archive, dest_prefix=None, parcel=None): self.prefix = prefix self.archive = archive self.dest = dest_prefix self.has_dest = dest_prefix is not None self.parcel = parcel self.prefixes = [] self.packages = []
634
efecc3c54956113cdb85d8de58ecf7fa
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=416-422/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
File::__init__(self, source, target, is_conda=True, file_mode=None, prefix_placeholder=None)
function
def __init__(self, source, target, is_conda=True, file_mode=None, prefix_placeholder=None): self.source = source self.target = target self.is_conda = is_conda self.file_mode = file_mode self.prefix_placeholder = prefix_placeholder
635
4bc58d473d7698cdab91b296bb81bcb8
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=113-116/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::__init__(self, prefix, files, excluded_files=None)
function
def __init__(self, prefix, files, excluded_files=None): self.prefix = prefix self.files = files self._excluded_files = excluded_files or []
636
959def118998d99a0dce8fdcf994026a
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=133-145/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::from_name(cls, name, **kwargs)
function
def from_name(cls, name, **kwargs): """Create a ``CondaEnv`` from a named environment. Parameters ---------- name : str The name of the conda environment. Returns ------- env : CondaEnv """ return cls.from_prefix(name_to_prefix(name),...
637
1e071a8452b21e1a8cd9fc3375a38078
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=260-272/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::_parcel_output(self, parcel_root, parcel_name, parcel_version, parcel_distro)
function
def _parcel_output(self, parcel_root, parcel_name, parcel_version, parcel_distro): parcel_root = parcel_root or '/opt/cloudera/parcels' parcel_name = parcel_name or self.name parcel_version = parcel_version or datetime.today().strftime(format='%Y.%m.%d') parcel_distro = parcel_distro or ...
638
1e150cda7b09570ad144c125c78cf1ae
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=424-425/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
File::__repr__(self)
function
def __repr__(self): return f"File<{self.target!r}, is_conda={self.is_conda!r}>"
639
7ca564e5eb6d9ddf25042b97ce6b86d7
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1030-1108/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
Packer::add(self, file)
function
def add(self, file): # Windows note: # When adding files to an archive, that archive is generally # case-sensitive. The target paths can be mixed case, and that means # that they will be distinct directories in the archive. # # If those files are then extracted onto a ca...
640
4c699a80fba633bac3328cb39f82c614
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1110-1120/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
Packer::_write_text_file(self, fpath, ftext, executable=False)
function
def _write_text_file(self, fpath, ftext, executable=False): fil = tempfile.NamedTemporaryFile(mode='w', delete=False) try: fil.write(ftext) fil.close() st = os.stat(fil.name) if executable: os.chmod(fil.name, st.st_mode | 0o111) ...
641
a6b73c55c74146ac3a35b5ae7514faa3
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=49-50/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
_Context::__init__(self)
function
def __init__(self): self.is_cli = False
642
cf236e14492e5d8e77c3ba06592ea70f
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=688-704/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
managed_file(is_noarch, site_packages, pkg, _path, prefix_placeholder=None, file_mode=None, **ignored)
function
def managed_file(is_noarch, site_packages, pkg, _path, prefix_placeholder=None, file_mode=None, **ignored): if is_noarch: if _path.startswith('site-packages/'): target = site_packages + _path[13:] elif _path.startswith('python-scripts/'): target = BIN_DIR + _...
643
047b166533c8b8e4b42e408cf1dcd064
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=59-65/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
_Context::set_cli(self)
function
def set_cli(self): old = self.is_cli try: self.is_cli = True yield finally: self.is_cli = old
644
2790b0125bfe22b79627a110e32b622e
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=118-119/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::__repr__(self)
function
def __repr__(self): return 'CondaEnv<%r, %d files>' % (self.prefix, len(self))
645
b0eab5ffb43a668e7422eed5fac3c6b8
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=52-56/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
_Context::warn(self, msg)
function
def warn(self, msg): if self.is_cli: print(msg + "\n", file=sys.stderr) else: warnings.warn(msg)
646
ec842f6ce293dea673b3d5b1bbd715f7
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=128-130/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::name(self)
function
def name(self): """The name of the environment""" return os.path.basename(self.prefix)
647
e1d20a325c5781d68f4168b43f1084c9
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=165-172/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::from_default(cls, **kwargs)
function
def from_default(cls, **kwargs): """Create a ``CondaEnv`` from the current environment. Returns ------- env : CondaEnv """ return cls.from_prefix(name_to_prefix(), **kwargs)
648
4c74b0454bb9d520b139e0fec32b5f2f
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=707-754/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
load_managed_package(info, prefix, site_packages, all_files)
function
def load_managed_package(info, prefix, site_packages, all_files): pkg = info['link']['source'] noarch_type = read_noarch_type(pkg) is_noarch = noarch_type == 'python' if is_noarch and site_packages is None: # pragma: nocover raise CondaPackException("noarch: python package installed (%r), bu...
649
fcd142814ed37a194094ee337b2f8b57
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1010-1017/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
is_binary_file(data)
function
# Deduce file type for unmanaged packages. If decoding utf-8 is # successful, we assume text, otherwise binary. def is_binary_file(data): try: data.decode('utf-8') return False except UnicodeDecodeError: return True
650
943ca1e7d543ca889b2c4c3e8a078630
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=174-199/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::exclude(self, pattern)
function
def exclude(self, pattern): """Exclude all files that match ``pattern`` from being packaged. This can be useful to remove functionality that isn't needed in the archive but is part of the original conda package. Parameters ---------- pattern : str A file pat...
651
9de7a01fbbf1434248f43de8b3aa7231
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=601-625/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
name_to_prefix(name=None)
function
def name_to_prefix(name=None): try: conda_exe = os.environ.get("CONDA_EXE", "conda") info = subprocess.check_output( f"{conda_exe} info --json", shell=True, stderr=subprocess.PIPE ).decode(default_encoding) except subprocess.CalledProcessError as exc: kind = ('current...
652
4ea8ac32ce8e3bf071a65e03df7133d9
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=641-652/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
read_has_prefix(path)
function
def read_has_prefix(path): out = {} with open(path) as fil: for line in fil: rec = tuple(x.strip('"\'') for x in shlex.split(line, posix=False)) if len(rec) == 1: out[rec[0]] = (PREFIX_PLACEHOLDER, 'text') elif len(rec) == 3: out[rec[2]...
653
512d9faa6e7ae0509801f14599bed6f8
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=148-162/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::from_prefix(cls, prefix, **kwargs)
function
def from_prefix(cls, prefix, **kwargs): """Create a ``CondaEnv`` from a given prefix. Parameters ---------- prefix : str The path to the conda environment. Returns ------- env : CondaEnv """ prefix = os.path.abspath(prefix) fi...
654
e88ddb0fc6c172e8d344d60f117f002c
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=201-224/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::include(self, pattern)
function
def include(self, pattern): """Re-add all excluded files that match ``pattern`` Parameters ---------- pattern : str A file pattern. May include shell-style wildcards a-la ``glob``. Returns ------- env : CondaEnv A new env with any matchin...
655
da9a7190e4b3e64c0a16cb4ca2a48e56
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=428-546/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
pack(name=None, prefix=None, output=None, format='infer', arcroot='', dest_prefix=None, parcel_root=None, parcel_name=None, parcel_version=None, parcel_distro=None, verbose=False, force=False, compress_level=4, n_threads=1, zip_symlinks=False, zip_64=True, filters=N...
function
def pack(name=None, prefix=None, output=None, format='infer', arcroot='', dest_prefix=None, parcel_root=None, parcel_name=None, parcel_version=None, parcel_distro=None, verbose=False, force=False, compress_level=4, n_threads=1, zip_symlinks=False, zip_64=True, filte...
656
e987a391a5b3460dfc031c4284ddf031
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=274-394/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::pack(self, output=None, format='infer', arcroot='', dest_prefix=None, parcel_root=None, parcel_name=None, parcel_version=None, parcel_distro=None, verbose=False, force=False, compress_level=4, n_threads=1, zip_symlinks=False, zip_64...
function
def pack(self, output=None, format='infer', arcroot='', dest_prefix=None, parcel_root=None, parcel_name=None, parcel_version=None, parcel_distro=None, verbose=False, force=False, compress_level=4, n_threads=1, zip_symlinks=False, zip_64=True)...
657
bc931d295ca1d066124fea6ca436122d
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=628-638/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
read_noarch_type(pkg)
function
def read_noarch_type(pkg): for file_name in ['link.json', 'package_metadata.json']: path = os.path.join(pkg, 'info', file_name) if os.path.exists(path): with open(path) as fil: info = json.load(fil) try: return info['noarch']['type'] ...
658
317879fb3ecaa7c0e964cdab983de244
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=655-685/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
load_files(prefix)
function
def load_files(prefix): from os.path import isfile, islink, join, relpath ignore = {'pkgs', 'envs', 'conda-bld', '.conda_lock', 'users', 'conda-recipes', '.index', '.unionfs', '.nonadmin', 'python.app', 'Launcher.app'} res = set() for fn in os.listdir(prefix): if f...
659
204d339aed16321aa9ca19e8ad53ee42
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=121-122/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::__len__(self)
function
def __len__(self): return len(self.files)
660
4f53c3575131f421fadefe53cdc342e8
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=549-573/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
find_site_packages(prefix)
function
def find_site_packages(prefix): # Ensure there is at most one version of python installed pythons = [] for fn in glob.glob(os.path.join(prefix, 'conda-meta', 'python-*.json')): with open(fn) as fil: meta = json.load(fil) if meta['name'] == 'python': pythons.append(met...
661
93e76145a3fe06287c684fec33542e14
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=891-920/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
rewrite_shebang(data, target, prefix)
function
def rewrite_shebang(data, target, prefix): """Rewrite a shebang header to ``#!usr/bin/env program...``. Returns ------- data : bytes fixed : bool Whether the file was successfully fixed in the rewrite. """ shebang_match = re.match(SHEBANG_REGEX, data, re.MULTILINE) prefix_b = pr...
662
f1aacbdc1c461222674fc4dc148cf828
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=124-125/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
CondaEnv::__iter__(self)
function
def __iter__(self): return iter(self.files)
663
b2239db17f478d2168b5783e510b6158
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=576-598/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
check_no_editable_packages(prefix, site_packages)
function
def check_no_editable_packages(prefix, site_packages): pth_files = glob.glob(os.path.join(prefix, site_packages, '*.pth')) editable_packages = set() for pth_fil in pth_files: dirname = os.path.dirname(pth_fil) with open(pth_fil) as pth: for line in pth: line = lin...
664
c9798889d6e9f0277f1f032b407296a0
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=784-888/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
load_environment(prefix, on_missing_cache='warn', ignore_editable_packages=False, ignore_missing_files=False)
function
def load_environment(prefix, on_missing_cache='warn', ignore_editable_packages=False, ignore_missing_files=False): # Check if it's a conda environment if not os.path.exists(prefix): raise CondaPackException("Environment path %r doesn't exist" % prefix) conda_meta = os.path.join(...
665
a6b20cbc5c3355a4faaab13dda208af8
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=923-939/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
rewrite_conda_meta(source)
function
def rewrite_conda_meta(source): """Remove absolute paths in conda-meta that reference local install. These are unnecessary for install/uninstall on the destination machine.""" with open(source) as f: original = f.read() data = json.loads(original) for field in ["extracted_package_dir", "pa...
666
dfccd5cce2e6af01b96d5362a45f65d4
swh:1:cnt:3c56b224cc1f738a2fe2e1e4f1e48391ff66b306;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1122-1186/
2cdddbfa7d0383c12d142b80430a0750506a340a
conda-pack
analytics
conda_pack/core.py
Packer::finish(self)
function
def finish(self): from . import __version__ # local import to avoid circular imports from .formats import SquashFSArchive # Parcel mode if self.parcel: src = os.path.join(_current_dir, 'scripts', 'posix', 'parcel') dst = os.path.join('meta', 'conda_env.sh') ...
667
9af9a34e4760df640b4d646c85281bb9
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=31-75/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
archive(fileobj, path, arcroot, format, compress_level=4, zip_symlinks=False, zip_64=True, n_threads=1, verbose=False)
function
def archive(fileobj, path, arcroot, format, compress_level=4, zip_symlinks=False, zip_64=True, n_threads=1, verbose=False): n_threads = _parse_n_threads(n_threads) if format == 'zip': return ZipArchive(fileobj, arcroot, zip_symlinks=zip_symlinks, zip_64=zip_64) ...
668
14d596efbb2f648071bda6727d2b911a
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=174-175/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelGzipFileWriter::_per_buffer_op(self, buffer)
function
def _per_buffer_op(self, buffer): self.crc = zlib.crc32(buffer, self.crc) & 0xffffffff
669
7e1c4f6d1a78bb6f21d6bc6ff662bc70
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=196-198/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelBZ2FileWriter::_init_state(self)
function
def _init_state(self): # bzip2 compresslevel dictates its blocksize of 100 - 900 kb self._block_size = self.compresslevel * 100 * 2**10
670
60d47c413cba8f86a92ce511e7c6b14a
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=367-377/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
SquashFSArchive::__init__(self, fileobj, target_path, arcroot, n_threads, verbose=False, compress_level=4)
function
def __init__(self, fileobj, target_path, arcroot, n_threads, verbose=False, compress_level=4): if shutil.which("mksquashfs") is None: raise SystemError("Command 'mksquashfs' not found. Please install it, " "e.g. 'conda install squashfs-tools'.") ...
671
4d54ae6e804631a54ed179586162252f
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=22-28/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
_parse_n_threads(n_threads=1)
function
def _parse_n_threads(n_threads=1): if n_threads == -1: from multiprocessing import cpu_count return cpu_count() if n_threads < 1: raise CondaPackException("n-threads must be >= 1, or -1 for all cores") return n_threads
672
2ad5f336b2b0cdface07a5195a42d759
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=177-178/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelGzipFileWriter::_write32u(self, value)
function
def _write32u(self, value): self.fileobj.write(struct.pack("<L", value))
673
dc55acb0c64e505a42d30811f0fc7ae4
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=200-202/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelBZ2FileWriter::_new_compressor(self)
function
def _new_compressor(self): import bz2 return bz2.BZ2Compressor(self.compresslevel)
674
804675cc03cc74282cea4bac50ccb2a1
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=213-214/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelBZ2FileWriter::_flush_compressor(self, compressor)
function
def _flush_compressor(self, compressor): return compressor.flush()
675
ffc4ac3fafaf115bb0ce7ca8812ab687
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=379-383/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
SquashFSArchive::__enter__(self)
function
def __enter__(self): # create a staging directory where we will collect # hardlinks to files and make tmpfiles for bytes self._staging_dir = os.path.normpath(tempfile.mkdtemp()) return self
676
2305c291e9af01f0ead8d9a6b923e67b
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=385-386/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
SquashFSArchive::__exit__(self, exc_type, exc_value, traceback)
function
def __exit__(self, exc_type, exc_value, traceback): shutil.rmtree(self._staging_dir)
677
2f2a782fae7eed34ef76b156ab8a3af5
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=218-221/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelXZFileWriter::_init_state(self)
function
def _init_state(self): # from `man lzma`: uses dict sizes between 64 kb and 32 MB for the level presets. # 2-4 times the size (minimum 1 MB) is best for the block size. self._block_size = 4 * max(1, (2**(self.compresslevel - 4))) * 2**10 * 2**10
678
3e2b3ae0c03143724830a0e23e7f56b1
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=230-231/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelXZFileWriter::_write_header(self)
function
def _write_header(self): pass
679
9658337d026801406b8e36e4ba70e100
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=269-272/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
TarArchive::__exit__(self, *args)
function
def __exit__(self, *args): self.archive.close() if self.close_file: self.fileobj.close()
680
01ccf2dfe5d35818e724de7d0a8b61fc
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=134-155/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelFileWriter::close(self)
function
def close(self): if self.fileobj is None: return # Flush any waiting buffers if self.buffers: self.compress_queue.put(self.buffers) # Wait for all work to finish self.compress_queue.put(None) self._consumer_thread.join() # Write the clos...
681
fed58deff505b3da53b21e6f61b830d6
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=204-205/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelBZ2FileWriter::_per_buffer_op(self, buffer)
function
def _per_buffer_op(self, buffer): pass
682
949848fd0db56329039313d6f4a41fda
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=223-225/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelXZFileWriter::_new_compressor(self)
function
def _new_compressor(self): import lzma return lzma.LZMACompressor(preset=self.compresslevel)
683
f5f45e207148689715181fda11914f68
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=233-234/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelXZFileWriter::_write_footer(self)
function
def _write_footer(self): pass
684
a06cfbcb6d858446fc221735139adef3
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=274-275/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
TarArchive::_add(self, source, target)
function
def _add(self, source, target): self.archive.add(source, target, recursive=False)
685
0ef898a3596e30ba04fa8c982a97e406
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=277-280/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
TarArchive::_add_bytes(self, source, sourcebytes, target)
function
def _add_bytes(self, source, sourcebytes, target): info = self.archive.gettarinfo(source, target) info.size = len(sourcebytes) self.archive.addfile(info, BytesIO(sourcebytes))
686
25d04fa36d4529de50c980213eb9d87f
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=460-465/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
SquashFSArchive::_add_bytes(self, source, sourcebytes, target)
function
def _add_bytes(self, source, sourcebytes, target): target_abspath = self._absolute_path(target) self._ensure_parent(target_abspath) with open(target_abspath, "wb") as f: shutil.copystat(source, target_abspath) f.write(sourcebytes)
687
ac5094cbb8eafa072fb1ac8ef70daf4c
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=79-98/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelFileWriter::__init__(self, fileobj, compresslevel=9, n_threads=1)
function
def __init__(self, fileobj, compresslevel=9, n_threads=1): self.fileobj = fileobj self.compresslevel = compresslevel self.n_threads = n_threads # Initialize file state self.size = 0 self._init_state() self._write_header() # Parallel initialization ...
688
b2be306047efd1a416c6bc22a8ad1d1c
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=118-124/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelFileWriter::_consumer(self)
function
def _consumer(self): with closing(self.pool): for buffers in self.pool.imap( self._compress, iter(self.compress_queue.get, None)): for buf in buffers: if len(buf): self.fileobj.write(buf)
689
33a01667ffefc133831c1fec88eb4d72
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=251-257/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
TarArchive::__init__(self, fileobj, arcroot, close_file=False, mode='w', compresslevel=4)
function
def __init__(self, fileobj, arcroot, close_file=False, mode='w', compresslevel=4): self.fileobj = fileobj self.arcroot = arcroot self.close_file = close_file self.mode = mode self.compresslevel = compresslevel
690
8b613a21e1ecfd70e9aeed7509bd5abf
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=309-314/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ZipArchive::__exit__(self, type, value, traceback)
function
def __exit__(self, type, value, traceback): self.archive.close() if isinstance(value, zipfile.LargeZipFile): raise CondaPackException( "Large Zip File: ZIP64 extensions required " "but were disabled")
691
959f77c78e2c006d56c41c8d7a2667f9
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=388-425/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
SquashFSArchive::mksquashfs_from_staging(self)
function
def mksquashfs_from_staging(self): """ After building the staging directory, squash it into file """ cmd = [ "mksquashfs", self._staging_dir, self.target_path, "-noappend", "-processors", str(self.n_threads), ...
692
046ed1fb1113e0f9f3201e342020ed24
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=430-432/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
SquashFSArchive::_ensure_parent(self, path)
function
def _ensure_parent(self, path): dir_path = os.path.dirname(path) os.makedirs(dir_path, exist_ok=True)
693
382a14ca023ec018631d9782a3431f38
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=100-101/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelFileWriter::tell(self)
function
def tell(self): return self.size
694
d3e1499e772a95360073fae76579f2ff
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=103-116/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelFileWriter::write(self, data)
function
def write(self, data): if not isinstance(data, bytes): data = memoryview(data) n = len(data) if n > 0: self._per_buffer_op(data) self.size += n self.buffer_length += n self.buffers.append(data) if self.buffer_length > self._...
695
3e7754dd1ebe25661b1d19b0358b70e3
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=126-132/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelFileWriter::_compress(self, in_bufs)
function
def _compress(self, in_bufs): out_bufs = [] compressor = self._new_compressor() for data in in_bufs: out_bufs.append(compressor.compress(data)) out_bufs.append(self._flush_compressor(compressor)) return out_bufs
696
2f5d30fcd00a1e0f7ef21dd77e1f0324
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=167-168/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelGzipFileWriter::_init_state(self)
function
def _init_state(self): self.crc = zlib.crc32(b"") & 0xffffffff
697
804675cc03cc74282cea4bac50ccb2a1
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=236-237/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ParallelXZFileWriter::_flush_compressor(self, compressor)
function
def _flush_compressor(self, compressor): return compressor.flush()
698
1bed852cfc2a1fd01cadb6776ed20317
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=259-267/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
TarArchive::__enter__(self)
function
def __enter__(self): kwargs = {'compresslevel': self.compresslevel} if self.mode not in {'w', 'w:xz'} else {} # Hard links seem to throw off the tar file format on windows. # Revisit when libarchive is used. self.archive = tarfile.open(fileobj=self.fileobj, ...
699
17daa456fc37510b9847bb536194f55e
swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=316-356/
ad231d08f7023dc0e37aa679805d9e49790c38c1
conda-pack
analytics
conda_pack/formats.py
ZipArchive::_add(self, source, target)
function
def _add(self, source, target): try: st = os.lstat(source) is_link = stat.S_ISLNK(st.st_mode) except (OSError, AttributeError): is_link = False if is_link: if self.zip_symlinks: info = zipfile.ZipInfo(target) info.c...