repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
flit | flit_core/tests_core/test_sdist.py | .py | from io import BytesIO
import os.path as osp
from pathlib import Path
import tarfile
from testpath import assert_isfile
from flit_core import sdist
samples_dir = Path(__file__).parent / 'samples'
def test_make_sdist(tmp_path):
# Smoke test of making a complete sdist
builder = sdist.SdistBuilder.from_ini_path... | 85 | 2,616 |
flit | flit_core/tests_core/test_versionno.py | .py | import pytest
from flit_core.common import InvalidVersion
from flit_core.versionno import normalise_version
def test_normalise_version():
nv = normalise_version
assert nv('4.3.1') == '4.3.1'
assert nv('1.0b2') == '1.0b2'
assert nv('2!1.3') == '2!1.3'
# Prereleases
assert nv('1.0B2') == '1.0b2... | 41 | 1,170 |
flit | flit_core/tests_core/test_common.py | .py | import email.parser
import email.policy
from io import StringIO
from pathlib import Path
import pytest
from unittest import TestCase
from flit_core import config
from flit_core.common import (
Module, get_info_from_module, InvalidVersion, NoVersionError, check_version,
normalize_file_permissions, Metadata, mak... | 243 | 8,951 |
flit | flit_core/tests_core/samples/moduleunimportable.py | .py |
"""
A sample unimportable module
"""
raise ImportError()
__version__ = "0.1"
| 9 | 80 |
flit | flit_core/tests_core/samples/invalid_version1.py | .py | """Sample module with invalid __version__ string"""
__version__ = "not starting with a number"
| 4 | 96 |
flit | flit_core/tests_core/samples/module1.py | .py | """Example module"""
__version__ = '0.1'
| 4 | 42 |
flit | flit_core/tests_core/samples/module2.py | .py | """
Docstring formatted like this.
"""
a = {}
# An assignment to a subscript (a['test']) broke introspection
# https://github.com/pypa/flit/issues/343
a['test'] = 6
__version__ = '7.0'
| 11 | 187 |
flit | flit_core/tests_core/samples/moduleunimportabledouble.py | .py |
"""
A sample unimportable module with double assignment
"""
raise ImportError()
VERSION = __version__ = "0.1"
| 9 | 113 |
flit | flit_core/tests_core/samples/annotated_version/module1.py | .py |
"""This module has a __version__ that has a type annotation"""
__version__: str = '0.1'
| 5 | 90 |
flit | flit_core/tests_core/samples/imported_version/package1/_version.py | .py | """Imposter docstring that shouldn't be used"""
__version__ = '0.5.8'
| 4 | 71 |
flit | flit_core/tests_core/samples/imported_version/package1/__init__.py | .py | """This module has a __version__ that requires a relative import"""
from ._version import __version__
import a_package_that_doesnt_exist
| 6 | 139 |
flit | flit_core/tests_core/samples/constructed_version/module1.py | .py |
"""This module has a __version__ that requires runtime interpretation"""
__version__ = ".".join(["1", "2", "3"])
| 5 | 115 |
flit | flit_core/tests_core/samples/package1/__init__.py | .py | """A sample package"""
__version__ = '0.1'
def main():
print("package1 main")
| 7 | 84 |
flit | flit_core/tests_core/samples/inclusion/module1.py | .py | """For tests"""
__version__ = '0.1'
| 4 | 37 |
flit | flit_core/tests_core/samples/ns1-pkg/ns1/pkg/__init__.py | .py | """
==================
ns1.pkg
==================
"""
__version__ = '0.1'
| 8 | 75 |
flit | flit_core/flit_core/__init__.py | .py | """Flit's core machinery for building packages.
This package provides a standard PEP 517 API to build packages using Flit.
All the convenient development features live in the main 'flit' package.
"""
__version__ = '4.0.2'
| 8 | 224 |
flit | flit_core/flit_core/buildapi.py | .py | """PEP-517 compliant buildsystem API"""
import logging
import os
import os.path as osp
from pathlib import Path
from .common import (
Module, make_metadata, write_entry_points, dist_info_name,
get_docstring_and_version_via_ast,
)
from .config import read_flit_config
from .wheel import make_wheel_in, _write_whe... | 86 | 3,344 |
flit | flit_core/flit_core/sdist.py | .py | from collections import defaultdict
from copy import copy
from glob import glob
from gzip import GzipFile
import io
import logging
import os
import os.path as osp
from pathlib import Path
from posixpath import join as pjoin
import tarfile
from . import common
log = logging.getLogger(__name__)
def clean_tarinfo(ti, ... | 197 | 7,044 |
flit | flit_core/flit_core/common.py | .py | import ast
from contextlib import contextmanager
import hashlib
import logging
import os
import sys
from pathlib import Path
import re
log = logging.getLogger(__name__)
from .versionno import normalise_version
class Module:
"""This represents the module/package that we are going to distribute
"""
in_nam... | 510 | 16,717 |
flit | flit_core/flit_core/wheel.py | .py | from __future__ import annotations
import argparse
from base64 import urlsafe_b64encode
import contextlib
import csv
from datetime import datetime, timezone
import hashlib
from io import StringIO
import logging
import os
import os.path as osp
import stat
import tempfile
from pathlib import Path
from types import Simple... | 260 | 9,279 |
flit | flit_core/flit_core/config.py | .py | import difflib
from email.headerregistry import Address
import errno
import logging
import os
import os.path as osp
from pathlib import Path
import re
try:
import tomllib
except ImportError:
try:
from .vendor import tomli as tomllib
# Some downstream distributors remove the vendored tomli.
# Wh... | 793 | 28,790 |
flit | flit_core/flit_core/versionno.py | .py | """Normalise version number according to PEP 440"""
import logging
import os
import re
log = logging.getLogger(__name__)
# Regex below from packaging, via PEP 440. BSD License:
# Copyright (c) Donald Stufft and individual contributors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with... | 126 | 4,711 |
flit | flit/_get_dirs.py | .py | """get_dirs() is pulled out as a separate file so we can run it in a target Python.
"""
import os
import sys
import sysconfig
def get_dirs(user=True):
"""Get the 'scripts' and 'purelib' directories we'll install into.
This is now a thin wrapper around sysconfig.get_paths(). It's not inlined,
because some ... | 28 | 898 |
flit | flit/sdist_rules.py | .py | """Generate sdist include/exclude rules for Flit
To use: cd into a folder with pyproject.toml set up for Flit, inside a git
repository. Produce any files that should be excluded (e.g. build docs).
Run 'python -m flit.sdist_rules'. It aims to include all files that are tracked
in git, with as few patterns as feasible.
... | 121 | 3,979 |
flit | flit/__main__.py | .py | from . import main
main()
| 4 | 27 |
flit | flit/__init__.py | .py | """A simple packaging tool for simple packages."""
import argparse
import logging
import os
import pathlib
import shutil
import subprocess
import sys
from typing import Optional
from flit_core import common
from .config import ConfigError
from .log import enable_colourful_output
__version__ = '4.0.2'
log = logging.g... | 213 | 8,438 |
flit | flit/buildapi.py | .py | from warnings import warn
warn('A package has specified `build-backend = "flit.buildapi"` and is being '
'built with Flit >= 3.10. This is likely to break in a future version. '
'Please change the backend to flit_core.buildapi, and/or specify a '
'maximum version of Flit.')
from flit_core.buildapi import... | 7 | 323 |
flit | flit/sdist.py | .py | from collections import defaultdict
import io
import logging
import os
from pathlib import Path
from posixpath import join as pjoin
from pprint import pformat
import tarfile
from flit_core.sdist import SdistBuilder as SdistBuilderCore
from flit_core.common import Module, VCSError
from flit.vcs import identify_vcs
log... | 189 | 5,765 |
flit | flit/validate.py | .py | """Validate various pieces of packaging data"""
import errno
import io
import logging
import os
from pathlib import Path
import re
import requests
import sys
from .vendorized.readme.rst import render
log = logging.getLogger(__name__)
CUSTOM_CLASSIFIERS = frozenset({
# https://github.com/pypa/warehouse/pull/5440... | 294 | 9,762 |
flit | flit/install.py | .py | """Install packages locally for development
"""
import logging
import os
import os.path as osp
import csv
import json
import pathlib
import random
import shutil
import site
import sys
import tempfile
from subprocess import check_call, check_output
import sysconfig
from flit_core import common
from .config import read_... | 432 | 16,771 |
flit | flit/log.py | .py | """Nicer log formatting with colours.
Code copied from Tornado, Apache licensed.
"""
# Copyright 2012 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licen... | 110 | 3,967 |
flit | flit/init.py | .py | from datetime import date
import json
import os
from pathlib import Path
import re
import sys
import tomli_w
def get_data_dir():
"""Get the directory path for flit user data files.
"""
home = os.path.realpath(os.path.expanduser('~'))
if sys.platform == 'darwin':
d = Path(home, 'Library')
e... | 249 | 8,785 |
flit | flit/wheel.py | .py | import logging
import flit_core.wheel as core_wheel
log = logging.getLogger(__name__)
def make_wheel_in(ini_path, wheel_directory, editable=False):
return core_wheel.make_wheel_in(ini_path, wheel_directory, editable)
class WheelBuilder(core_wheel.WheelBuilder):
pass
| 12 | 279 |
flit | flit/config.py | .py | import os
from flit_core.config import *
from flit_core.config import read_flit_config as _read_flit_config_core
from .validate import validate_config
def read_flit_config(path):
"""Read and check the `pyproject.toml` or `flit.ini` file with data about the package.
"""
res = _read_flit_config_core(path)
... | 19 | 592 |
flit | flit/tomlify.py | .py | """Convert a flit.ini file to pyproject.toml
"""
import argparse
from collections import OrderedDict
import configparser
import os
from pathlib import Path
import tomli_w
from .config import metadata_list_fields
TEMPLATE = """\
[build-system]
requires = ["flit_core >=2,<4"]
build-backend = "flit_core.buildapi"
[too... | 84 | 2,281 |
flit | flit/logo.py | .py | """White and colored version for flit"""
logo = """
._ ._
```. ```. .--.______
`. `-. `. / °,-—´
`. `~-.>.' /
`. .` |
-..;. /
/ /___ _____
/r_,.´| | | |
,' `/ |—— | | |
.´... | 21 | 448 |
flit | flit/upload.py | .py | """Code to communicate with PyPI to register distributions and upload files.
This is cribbed heavily from distutils.command.(upgrade|register), which as part
of Python is under the PSF license.
"""
import configparser
import getpass
import hashlib
import logging
import os
from pathlib import Path
import re
import requ... | 322 | 10,472 |
flit | flit/build.py | .py | """flit build - build both wheel and sdist"""
from contextlib import contextmanager
import logging
import os
from pathlib import Path
import tarfile
from tempfile import TemporaryDirectory
from types import SimpleNamespace
import sys
from .config import read_flit_config, ConfigError
from .sdist import SdistBuilder
fr... | 63 | 2,249 |
flit | flit/vcs/__init__.py | .py | from pathlib import Path
from . import hg
from . import git
def identify_vcs(directory: Path):
directory = directory.resolve()
for p in [directory] + list(directory.parents):
# In a linked git worktree (`git worktree add ...`) or inside a
# git submodule, `.git` is a regular file containing a
... | 19 | 560 |
flit | flit/vcs/hg.py | .py | import os
from subprocess import check_output
name = 'hg'
def find_repo_root(directory):
for p in [directory] + list(directory.parents):
if (p / '.hg').is_dir():
return p
def _repo_paths_to_directory_paths(paths, directory):
# 'hg status' gives paths from repo root, which may not be our d... | 35 | 1,258 |
flit | flit/vcs/git.py | .py | import os
from subprocess import check_output
name = 'git'
def list_tracked_files(directory):
outb = check_output(['git', 'ls-files', '--recurse-submodules', '-z'],
cwd=str(directory))
return [os.fsdecode(l) for l in outb.strip(b'\0').split(b'\0') if l]
def list_untracked_deleted_file... | 16 | 574 |
flit | flit/vendorized/readme/rst.py | .py | # Copyright 2014 Donald Stufft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, so... | 137 | 4,521 |
flit | flit/vendorized/readme/clean.py | .py | ## shim readme clean to simplify vendorizing of readme.rst
clean = lambda x:x
| 3 | 78 |
flit | tests/test_find_python_executable.py | .py | from os.path import isabs, basename, dirname
import os
import re
import sys
import venv
import pytest
from flit import PythonNotFoundError, find_python_executable
def test_default():
assert find_python_executable(None) == sys.executable
def test_self():
assert find_python_executable(sys.executable) == sys... | 50 | 1,255 |
flit | tests/test_vcs.py | .py | from contextlib import contextmanager
import os
from pathlib import Path
from tempfile import TemporaryDirectory
from flit import vcs
@contextmanager
def cwd(path):
if isinstance(path, Path):
path = str(path)
old_wd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(... | 38 | 1,046 |
flit | tests/test_config.py | .py | from pathlib import Path
import pytest
from flit.config import read_flit_config, ConfigError
samples_dir = Path(__file__).parent / 'samples'
def test_invalid_classifier():
with pytest.raises(ConfigError):
read_flit_config(samples_dir / 'invalid_classifier.toml')
| 11 | 278 |
flit | tests/test_wheel.py | .py | import configparser
import csv
import io
import os
import stat
from pathlib import Path
import tempfile
from unittest import skipIf
import zipfile
import pytest
from testpath import assert_isfile, assert_isdir, assert_not_path_exists
from flit.wheel import WheelBuilder, make_wheel_in
from flit.config import ConfigErr... | 255 | 9,669 |
flit | tests/test_tomlify.py | .py | from pathlib import Path
try:
import tomllib
except ImportError:
import tomli as tomllib
from testpath import assert_isfile
from flit import tomlify
samples_dir = Path(__file__).parent / 'samples'
def test_tomlify(copy_sample, monkeypatch):
td = copy_sample('with_flit_ini')
monkeypatch.chdir(td)
... | 31 | 754 |
flit | tests/test_build.py | .py | from pathlib import Path
import pytest
import shutil
import sys
from tempfile import TemporaryDirectory
from testpath import assert_isdir, MockCommand
from flit_core import common
from flit import build
samples_dir = Path(__file__).parent / 'samples'
LIST_FILES_TEMPLATE = """\
#!{python}
import sys
from os.path impo... | 85 | 2,932 |
flit | tests/test_command.py | .py | from subprocess import Popen, PIPE, STDOUT
import sys
def test_flit_help():
p = Popen([sys.executable, '-m', 'flit', '--help'], stdout=PIPE, stderr=STDOUT)
out, _ = p.communicate()
assert 'Build wheel' in out.decode('utf-8', 'replace')
def test_flit_usage():
p = Popen([sys.executable, '-m', 'flit'], s... | 14 | 460 |
flit | tests/test_upload.py | .py | from contextlib import contextmanager
from tempfile import NamedTemporaryFile
import os
import io
import pathlib
import pytest
import responses
from testpath import modified_env
from unittest.mock import patch
from flit import upload
from flit.build import ALL_FORMATS
from flit.upload import get_repository, RepoDetai... | 157 | 4,498 |
flit | tests/test_sdist.py | .py | import ast
from os.path import join as pjoin
from pathlib import Path
import pytest
from shutil import which, copytree
import sys
import tarfile
from tempfile import TemporaryDirectory
from testpath import assert_isfile, MockCommand
from flit import sdist, common
samples_dir = Path(__file__).parent / 'samples'
def t... | 95 | 2,846 |
flit | tests/test_validate.py | .py | import errno
import pytest
import responses
from flit import validate as fv
def test_validate_entrypoints():
assert fv.validate_entrypoints(
{'console_scripts': {'flit': 'flit:main'}}) == []
assert fv.validate_entrypoints(
{'some.group': {'flit': 'flit.buildapi'}}) == []
res = fv.validate... | 244 | 7,482 |
flit | tests/test_install.py | .py | import json
import os
import pathlib
import sys
import tempfile
from unittest import TestCase, SkipTest, skipIf
from unittest.mock import patch
import pytest
from testpath import (
assert_isfile, assert_isdir, assert_islink, assert_not_path_exists, MockCommand
)
from flit import install
from flit.install import I... | 371 | 15,849 |
flit | tests/test_init.py | .py | import builtins
from contextlib import contextmanager
from pathlib import Path
from tempfile import TemporaryDirectory
from testpath import assert_isfile
from unittest.mock import patch
import pytest
try:
import tomllib
except ImportError:
import tomli as tomllib
from flit import init
@contextmanager
def pa... | 258 | 8,470 |
flit | tests/conftest.py | .py | from pathlib import Path
import pytest
from shutil import copytree
samples_dir = Path(__file__).parent / 'samples'
@pytest.fixture
def copy_sample(tmp_path):
"""Copy a subdirectory from the samples dir to a temp dir"""
def copy(dirname):
dst = tmp_path / dirname
copytree(str(samples_dir / dirn... | 16 | 372 |
flit | tests/samples/module2.py | .py | """
Docstring formatted like this.
"""
__version__ = '7.0'
| 6 | 60 |
flit | tests/samples/modulewithlocalversion/modulewithlocalversion.py | .py | """
A module with a local version specifier
"""
__version__ = "0.1.dev0+test"
| 6 | 79 |
flit | tests/samples/ns1-pkg-mod/ns1/module.py | .py | """An example single file module in a namespace package
"""
__version__ = '0.1'
| 5 | 81 |
flit | tests/samples/ns1-pkg2/ns1/pkg2/__init__.py | .py | """
==================
ns1.pkg2
==================
"""
__version__ = '0.1'
| 8 | 76 |
conda | conda/misc.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Miscellaneous utility functions."""
from __future__ import annotations
import os
import re
import shutil
from logging import getLogger
from os.path import abspath, dirname, isdir, isfile, join, relpath
from typing import TYPE_CHECKING
from... | 389 | 12,509 |
conda | conda/utils.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Utility functions."""
from __future__ import annotations
import logging
import re
import sys
from functools import cache, wraps
from os import environ
from os.path import abspath, basename, dirname, isfile, join
from pathlib import Path
fro... | 392 | 14,290 |
conda | conda/resolve.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Low-level SAT solver wrapper/interface for the classic solver.
See conda.core.solver.Solver for the high-level API.
"""
from __future__ import annotations
import itertools
from collections import defaultdict, deque
from functools import ca... | 1,697 | 69,688 |
conda | conda/activate.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Conda activate and deactivate logic.
Implementation for all shell interface logic exposed via
`conda shell.* [activate|deactivate|reactivate|hook|commands]`. This includes a custom argument
parser, an abstract shell class, and special path h... | 1,191 | 45,132 |
conda | conda/exceptions.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Conda exceptions."""
from __future__ import annotations
import os
import sys
from collections import defaultdict
from datetime import timedelta
from logging import getLogger
from os.path import join
from textwrap import dedent, indent
from ... | 1,897 | 63,451 |
conda | conda/exception_handler.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Error handling and error reporting."""
from __future__ import annotations
import os
import sys
from functools import cached_property, partial
from logging import getLogger
from typing import TYPE_CHECKING
from .common.compat import ensure_... | 437 | 15,454 |
conda | conda/deprecations.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Tools to aid in deprecating code."""
from __future__ import annotations
import sys
import warnings
from argparse import SUPPRESS, Action
from dataclasses import dataclass, field
from functools import wraps
from types import ModuleType
from ... | 531 | 19,273 |
conda | conda/__main__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Conda as a module entry point."""
import sys
from .cli import main
sys.exit(main())
| 10 | 165 |
conda | conda/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""OS-agnostic, system-level binary package manager."""
from __future__ import annotations
import os
import sys
from json import JSONEncoder # noqa: TID251
from os.path import abspath, dirname
from typing import TYPE_CHECKING
if TYPE_CHECKIN... | 256 | 8,079 |
conda | conda/instructions.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Define the instruction set (constants) for conda operations."""
from logging import getLogger
from os.path import isfile, join
from .core.link import UnlinkLinkTransaction
from .core.package_cache_data import ProgressiveFetchExtract
from .d... | 114 | 2,862 |
conda | conda/history.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Tools interfacing with conda's history file."""
from __future__ import annotations
import logging
import os
import re
import sys
import time
import warnings
from ast import literal_eval
from errno import EACCES, EPERM, EROFS
from itertools ... | 427 | 15,693 |
conda | conda/api.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of conda's high-level APIs."""
from .base.constants import DepsModifier as _DepsModifier
from .base.constants import UpdateModifier as _UpdateModifier
from .base.context import context
from .common.constants import NULL
from .core... | 502 | 17,522 |
conda | conda/exports.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Backported exports for conda-build."""
from __future__ import annotations
from builtins import input # noqa: UP029
from io import StringIO
from . import CondaError
from .base.constants import (
DEFAULT_CHANNELS,
DEFAULT_CHANNELS_U... | 390 | 9,263 |
conda | conda/reporters.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Holds functions for output rendering in conda
"""
from __future__ import annotations
import logging
import sys
from functools import cache
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from contextlib import AbstractContextManage... | 104 | 2,787 |
conda | conda/testing/http_test_server.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
HTTP test server for serving local files during tests.
This module provides a local HTTP server that can be used in pytest fixtures
to serve files from a specified directory. The server runs on a random port
and supports both IPv4 and IPv6.... | 86 | 2,920 |
conda | conda/testing/solver_helpers.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Helpers for testing the solver."""
from __future__ import annotations
import collections
import functools
import pathlib
import time
from tempfile import TemporaryDirectory
import pytest
from ..base.context import context
from ..common.se... | 1,339 | 47,555 |
conda | conda/testing/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
# Attempt to move any conda entries in PATH to the front of it.
# IDEs have their own ideas about how PATH should be managed and
# they do dumb stuff like add /usr/bin to the front of it
# meaning conda takes a submissive role and the wrong stuf... | 70 | 2,954 |
conda | conda/testing/fixtures.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of pytest fixtures used in conda tests."""
from __future__ import annotations
import os
import subprocess
import uuid
import warnings
from contextlib import contextmanager, nullcontext
from dataclasses import dataclass
from itert... | 887 | 27,928 |
conda | conda/testing/integration.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
These helpers were originally defined in tests/test_create.py,
but were refactored here so downstream projects can benefit from
them too.
"""
from __future__ import annotations
import os
import sys
from logging import getLogger
from os.pat... | 133 | 4,037 |
conda | conda/testing/helpers.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of helper functions used in conda tests."""
from __future__ import annotations
import os
import subprocess
import sys
from contextlib import contextmanager
from functools import cache
from os.path import abspath, dirname, join
fr... | 768 | 23,312 |
conda | conda/testing/cases.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Extends unittest.TestCase to include select pytest fixtures."""
import unittest
import pytest
class BaseTestCase(unittest.TestCase):
fixture_names = ("tmpdir",)
@pytest.fixture(autouse=True)
def auto_injector_fixture(self, re... | 18 | 453 |
conda | conda/testing/gateways/fixtures.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of pytest fixtures used in conda.gateways tests."""
import os
import socket
from pathlib import Path
from shutil import which
import pytest
from xprocess import ProcessStarter
from ...common.serialize import json
MINIO_EXE = wh... | 132 | 4,383 |
conda | conda/testing/notices/fixtures.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of pytest fixtures used in conda.notices tests."""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
from unittest import mock
import pytest
from ...base.constants import DEFAULTS_CHAN... | 49 | 1,394 |
conda | conda/testing/notices/helpers.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of helper functions used in conda.notices tests."""
from __future__ import annotations
import datetime
import os
import uuid
from itertools import chain, repeat
from pathlib import Path
from typing import TYPE_CHECKING
from ...c... | 139 | 3,959 |
conda | conda/base/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Code in ``conda.base`` is the lowest level of the application stack. It is loaded and executed
virtually every time the application is executed. Any code within, and any of its imports, must
be highly performant.
Conda modules importable f... | 19 | 520 |
conda | conda/base/constants.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
This file should hold most string literals and magic numbers used throughout the code base.
The exception is if a literal is specifically meant to be private to and isolated within a module.
Think of this as a "more static" source of configu... | 456 | 12,901 |
conda | conda/base/context.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Conda's global configuration object.
The context aggregates all configuration files, environment variables, and command line arguments
into one global stateful object to be used across all of conda.
"""
from __future__ import annotations
i... | 2,350 | 88,229 |
conda | conda/gateways/logging.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Configure logging for conda."""
import logging
import sys
from datetime import datetime, timezone
from functools import cache
from logging import (
DEBUG,
INFO,
WARNING,
Filter,
Formatter,
StreamHandler,
getLogger... | 208 | 7,076 |
conda | conda/gateways/anaconda_client.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Anaconda-client (binstar) token management for CondaSession."""
import os
import re
from logging import getLogger
from os.path import isdir, isfile, join
from stat import S_IREAD, S_IWRITE
from platformdirs import user_config_dir
from ..co... | 69 | 1,893 |
conda | conda/gateways/streams.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Helper functions for streaming output to stdout and stderr."""
import re
import sys
_TOKEN_URL_PATTERN = re.compile(
r"(|https?://)" # \1 scheme
r"(|\s" # \2 space, or
r"|(?:(?:\d{1,3}\.){3}\d{1,3})" # ipv4, or
r"|(?:" ... | 50 | 1,379 |
conda | conda/gateways/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Gateways isolate interaction of conda code with the outside world. Disk manipulation,
database interaction, and remote requests should all be through various gateways. Functions
and methods in ``conda.gateways`` must use ``conda.models`` f... | 28 | 732 |
conda | conda/gateways/subprocess.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Helpler functions for subprocess."""
from __future__ import annotations
import os
import sys
from collections import namedtuple
from logging import getLogger
from os.path import abspath
from subprocess import PIPE, CalledProcessError, Popen... | 172 | 5,035 |
conda | conda/gateways/connection/download.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Download logic for conda indices and packages."""
from __future__ import annotations
import hashlib
import os
import tempfile
import warnings
from contextlib import contextmanager
from logging import DEBUG, getLogger
from os.path import bas... | 470 | 16,681 |
conda | conda/gateways/connection/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING, Protocol, runtime_checkable
from requests import ConnectionError, HTTPError, Session # noqa: F401, TID253
from requests.adapters import ( # noqa: F401, TID253
DEFAULT_P... | 58 | 2,117 |
conda | conda/gateways/connection/session.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Requests session configured with all accepted scheme adapters."""
from __future__ import annotations
from fnmatch import fnmatch
from functools import cache
from logging import getLogger
from threading import local
from typing import TYPE_C... | 440 | 14,781 |
conda | conda/gateways/connection/adapters/ftp.py | .py | # Copyright (C) 2012 Cory Benfield
# SPDX-License-Identifier: Apache-2.0
"""Defines FTP transport adapter for CondaSession (requests.Session).
Taken from requests-ftp (https://github.com/Lukasa/requests-ftp/blob/master/requests_ftp/ftp.py).
Licensed under the Apache License, Version 2.0 (the "License");
you may not u... | 279 | 9,554 |
conda | conda/gateways/connection/adapters/s3.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Defines S3 transport adapter for CondaSession (requests.Session)."""
from __future__ import annotations
from logging import LoggerAdapter, getLogger
from tempfile import SpooledTemporaryFile
from typing import TYPE_CHECKING
from ....common... | 174 | 5,849 |
conda | conda/gateways/connection/adapters/http.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2008-2023 The pip developers
# SPDX-License-Identifier: MIT
#
"""Defines HTTP transport adapter for CondaSession (requests.Session).
Closely derived from pip:
https://github.com/pypa/pip/blob/8c24fd2a80bad21aa29aec02fb48bd89a1e... | 92 | 3,245 |
conda | conda/gateways/connection/adapters/localfs.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Defines local filesystem transport adapter for CondaSession (requests.Session)."""
from email.utils import formatdate
from logging import getLogger
from mimetypes import guess_type
from os import stat
from tempfile import SpooledTemporaryFil... | 60 | 1,821 |
conda | conda/gateways/disk/delete.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Disk utility functions for deleting files and folders."""
from __future__ import annotations
import fnmatch
import os
import shutil
import sys
from logging import getLogger
from os.path import (
abspath,
basename,
dirname,
e... | 287 | 10,410 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.