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
hatch
src/hatch/config/model.py
.py
import os FIELD_TO_PARSE = object() class ConfigurationError(Exception): def __init__(self, *args, location): self.location = location super().__init__(*args) def __str__(self): return f"Error parsing config:\n{self.location}\n {super().__str__()}" def parse_config(obj): if is...
790
25,374
hatch
src/hatch/config/constants.py
.py
class AppEnvVars: ENV = "HATCH_ENV" ENV_ACTIVE = "HATCH_ENV_ACTIVE" ENV_OPTION_PREFIX = "HATCH_ENV_TYPE_" QUIET = "HATCH_QUIET" VERBOSE = "HATCH_VERBOSE" INTERACTIVE = "HATCH_INTERACTIVE" PYTHON = "HATCH_PYTHON" # https://no-color.org NO_COLOR = "NO_COLOR" FORCE_COLOR = "FORCE_CO...
42
1,108
hatch
src/hatch/utils/ci.py
.py
import os def running_in_ci() -> bool: return any(os.environ.get(env_var) in {"true", "1"} for env_var in ("CI", "GITHUB_ACTIONS"))
6
138
hatch
src/hatch/utils/metadata.py
.py
from __future__ import annotations import re def normalize_project_name(name: str) -> str: # https://peps.python.org/pep-0503/#normalized-names return re.sub(r"[-_.]+", "-", name).lower()
9
199
hatch
src/hatch/utils/linehaul.py
.py
from __future__ import annotations import json import os import platform import sys from functools import lru_cache from typing import Any from hatch._version import __version__ def get_linehaul_data() -> dict[str, Any]: data: dict[str, Any] = { "installer": {"name": "hatch", "version": __version__}, ...
137
3,579
hatch
src/hatch/utils/network.py
.py
from __future__ import annotations import time from contextlib import contextmanager from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from collections.abc import Generator import httpx2 from hatch.utils.fs import Path MINIMUM_SLEEP = 2 MAXIMUM_SLEEP = 20 # The timeout should be slightly larger t...
51
1,359
hatch
src/hatch/utils/runner.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from collections.abc import Sequence from hatch.env.plugin.interface import EnvironmentInterface class ExecutionContext: def __init__( self, environment: EnvironmentInterface, *, s...
84
2,617
hatch
src/hatch/utils/toml.py
.py
from __future__ import annotations import sys from typing import Any if sys.version_info >= (3, 11): import tomllib else: import tomli as tomllib def load_toml_data(data: str) -> dict[str, Any]: return tomllib.loads(data) def load_toml_file(path: str) -> dict[str, Any]: with open(path, encoding="u...
19
372
hatch
src/hatch/utils/shells.py
.py
from __future__ import annotations import sys from typing import TYPE_CHECKING from hatch.utils.fs import Path if TYPE_CHECKING: from collections.abc import Callable, Iterable from types import FrameType from hatch.env.plugin.interface import EnvironmentInterface from hatch.utils.platform import Pla...
142
5,243
hatch
src/hatch/utils/platform.py
.py
from __future__ import annotations import os import sys from functools import cache from importlib import import_module from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from collections.abc import Callable, Iterable, Sequence from subprocess import CompletedProcess, Popen from types import ModuleTy...
307
11,399
hatch
src/hatch/utils/structures.py
.py
from __future__ import annotations import os from fnmatch import fnmatch from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Collection, Mapping from types import TracebackType class EnvVars(dict): def __init__( self, env_vars: Mapping | None = None, in...
49
1,349
hatch
src/hatch/utils/fs.py
.py
from __future__ import annotations import os import pathlib import sys from contextlib import contextmanager, suppress from functools import cached_property from typing import TYPE_CHECKING, Any from hatch.utils.structures import EnvVars if TYPE_CHECKING: from collections.abc import Generator from _typeshed...
159
4,377
hatch
src/hatch/utils/env.py
.py
from __future__ import annotations from ast import literal_eval from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from hatch.utils.platform import Platform class PythonInfo: def __init__(self, platform: Platform, executable: str = "python") -> None: self.platform = platform self.execut...
80
2,445
hatch
src/hatch/utils/dep.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any from hatchling.metadata.utils import get_normalized_dependency, normalize_project_name if TYPE_CHECKING: from collections.abc import Callable from packaging.requirements import Requirement from hatch.dep.core import Dependency d...
169
5,484
hatch
src/hatch/cli/lock_cmd.py
.py
"""Top-level ``hatch lock`` — forwards to the same workflow as ``hatch dep lock``.""" from __future__ import annotations from typing import TYPE_CHECKING import click from hatch.cli.env.lock import dependency_lock_click_options, run_dep_lock if TYPE_CHECKING: from hatch.cli.application import Application @cl...
40
1,030
hatch
src/hatch/cli/application.py
.py
from __future__ import annotations import os import signal import sys from functools import cached_property from typing import TYPE_CHECKING, cast from hatch.cli.terminal import Terminal from hatch.config.user import ConfigFile, RootConfig from hatch.project.core import Project from hatch.utils.fs import Path from ha...
231
9,156
hatch
src/hatch/cli/__init__.py
.py
from __future__ import annotations import os from typing import cast import click from hatch._version import __version__ from hatch.cli.application import Application from hatch.cli.build import build from hatch.cli.check import check from hatch.cli.clean import clean from hatch.cli.config import config from hatch.c...
253
7,723
hatch
src/hatch/cli/terminal.py
.py
from __future__ import annotations import os from abc import ABC, abstractmethod from functools import cached_property from textwrap import indent as indent_text from typing import TYPE_CHECKING import click from rich.console import Console from rich.style import Style from rich.text import Text if TYPE_CHECKING: ...
375
13,075
hatch
src/hatch/cli/fmt/__init__.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Format and lint source code", context_settings={"ignore_unknown_options": True}) @click.argument("args", nargs=-1) @click.option("--check",...
84
3,091
hatch
src/hatch/cli/fmt/core.py
.py
from __future__ import annotations from functools import cached_property from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from hatch.env.plugin.interface import EnvironmentInterface from hatch.utils.fs import Path class StaticAnalysisEnvironment: def __init__(self, env: EnvironmentInterface) -> N...
929
16,044
hatch
src/hatch/cli/new/__init__.py
.py
import click @click.command(short_help="Create or initialize a project") @click.argument("name", required=False) @click.argument("location", required=False) @click.option("--interactive", "-i", "interactive", is_flag=True, help="Interactively choose details about the project") @click.option("--cli", "feature_cli", is...
163
6,063
hatch
src/hatch/cli/new/migrate.py
.py
import os import sys FILE = os.path.abspath(__file__) HERE = os.path.dirname(FILE) ENV_VAR_PREFIX = "_HATCHLING_PORT_ADD_" def _apply_env_vars(kwargs): from ast import literal_eval for key, value in os.environ.items(): if key.startswith(ENV_VAR_PREFIX): kwargs[key.replace(ENV_VAR_PREFIX,...
368
13,804
hatch
src/hatch/cli/publish/__init__.py
.py
import click from hatch.config.constants import PublishEnvVars @click.command(short_help="Publish build artifacts") @click.argument("artifacts", nargs=-1) @click.option( "--repo", "-r", envvar=PublishEnvVars.REPO, help="The repository with which to publish artifacts [env var: `HATCH_INDEX_REPO`]", ) ...
116
3,628
hatch
src/hatch/cli/project/metadata.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Display project metadata") @click.argument("field", required=False) @click.pass_obj def metadata(app: Application, field: str | None): ...
58
1,857
hatch
src/hatch/cli/project/__init__.py
.py
import click from hatch.cli.project.metadata import metadata @click.group(short_help="View project information") def project(): pass project.add_command(metadata)
12
172
hatch
src/hatch/cli/check/types.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Type check source code", context_settings={"ignore_unknown_options": True}) @click.argument("args", nargs=-1) @click.option("--summarize", ...
52
1,500
hatch
src/hatch/cli/check/__init__.py
.py
from __future__ import annotations import click from hatch.cli.check.code import code from hatch.cli.check.fmt import fmt from hatch.cli.check.types import types @click.group(short_help="Check source code", invoke_without_command=True) @click.option("--fix", is_flag=True, help="Fix issues rather than just reporting...
29
765
hatch
src/hatch/cli/check/fmt.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Verify formatting", context_settings={"ignore_unknown_options": True}) @click.argument("args", nargs=-1) @click.option("--fix", is_flag=Tru...
75
2,777
hatch
src/hatch/cli/check/code.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Perform static analysis", context_settings={"ignore_unknown_options": True}) @click.argument("args", nargs=-1) @click.option("--fix", is_fl...
75
2,789
hatch
src/hatch/cli/status/__init__.py
.py
import click @click.command(short_help="Show information about the current environment") @click.pass_obj def status(app): """Show information about the current environment.""" def display_pair(key, value, display_func=None, link=None): app.display_info("[", end="") app.display_success(key, en...
28
1,082
hatch
src/hatch/cli/dep/__init__.py
.py
import click from hatch.cli.env.lock import dependency_lock_click_options, run_dep_lock @click.group(short_help="Manage environment dependencies") def dep(): pass @dep.command("lock", short_help="Generate a lockfile for the active environment (`-e` / `HATCH_ENV`)") @dependency_lock_click_options @click.pass_ob...
256
10,698
hatch
src/hatch/cli/self/restore.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command( short_help="Restore the installation", context_settings={"help_option_names": [], "ignore_unknown_options": True} ) @click.argument("args", nargs=...
18
465
hatch
src/hatch/cli/self/__init__.py
.py
import os import click from hatch.cli.self.report import report __management_command = os.environ.get("PYAPP_COMMAND_NAME", "self") @click.group(name=__management_command, short_help="Manage Hatch") def self_command(): pass self_command.add_command(report) if __management_command: from hatch.cli.self.re...
23
462
hatch
src/hatch/cli/self/update.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command( short_help="Install the latest version", context_settings={"help_option_names": [], "ignore_unknown_options": True} ) @click.argument("args", narg...
18
466
hatch
src/hatch/cli/self/report.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any import click if TYPE_CHECKING: from hatch.cli.application import Application def get_install_source(platform_name: str) -> str: import os import sys import sysconfig from platformdirs import user_data_dir from hatch....
130
3,890
hatch
src/hatch/cli/clean/__init__.py
.py
import click @click.command(short_help="Remove build artifacts") @click.argument("location", required=False) @click.option( "--target", "-t", "targets", multiple=True, help=( "The target with which to remove artifacts, overriding project defaults. " "This may be selected multiple t...
42
1,218
hatch
src/hatch/cli/python/__init__.py
.py
import click from hatch.cli.python.find import find from hatch.cli.python.install import install from hatch.cli.python.remove import remove from hatch.cli.python.show import show from hatch.cli.python.update import update @click.group(short_help="Manage Python installations") def python(): pass python.add_comm...
20
437
hatch
src/hatch/cli/python/find.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Locate Python binaries") @click.argument("name") @click.option("-p", "--parent", is_flag=True, help="Show the parent directory of the Pytho...
25
835
hatch
src/hatch/cli/python/update.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click from hatch.cli.python.install import install if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Update Python distributions") @click.argument("names", required=True, nargs=-1) @click.option...
39
1,116
hatch
src/hatch/cli/python/show.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Show the available Python distributions") @click.option("--ascii", "force_ascii", is_flag=True, help="Whether or not to only use ASCII char...
39
1,609
hatch
src/hatch/cli/python/install.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application def ensure_path_public(path: str, shells: list[str]) -> bool: import userpath if userpath.in_current_path(path) or userpath.in_new_path(path, shells): ...
108
3,907
hatch
src/hatch/cli/python/remove.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Remove Python distributions") @click.argument("names", required=True, nargs=-1) @click.option("--dir", "-d", "directory", help="The directo...
37
1,033
hatch
src/hatch/cli/shell/__init__.py
.py
from __future__ import annotations import os from typing import TYPE_CHECKING import click from hatch.config.constants import AppEnvVars if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Enter a shell within a project's environment") @click.argument("env_name", require...
60
2,055
hatch
src/hatch/cli/version/__init__.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="View or set a project's version") @click.argument("desired_version", required=False) @click.option( "--force", "-f", is_flag=Tr...
82
2,920
hatch
src/hatch/cli/config/__init__.py
.py
import os import click @click.group(short_help="Manage the config file") def config(): pass @config.command(short_help="Open the config location in your file manager") @click.pass_obj def explore(app): """Open the config location in your file manager.""" click.launch(str(app.config_file.path), locate=T...
150
4,807
hatch
src/hatch/cli/test/__init__.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application from hatch.env.plugin.interface import EnvironmentInterface @click.command(short_help="Run tests", context_settings={"ignore_unknown_options": True}) @click.argum...
235
9,187
hatch
src/hatch/cli/test/core.py
.py
from __future__ import annotations from functools import cached_property from typing import TYPE_CHECKING if TYPE_CHECKING: from configparser import ConfigParser from hatch.utils.fs import Path class PatchedCoverageConfig: def __init__(self, project_root: Path, data_dir: Path) -> None: self.pro...
57
1,936
hatch
src/hatch/cli/env/prune.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Remove all environments") @click.pass_obj def prune(app: Application): """Remove all environments.""" app.ensure_environment_plugin...
44
1,507
hatch
src/hatch/cli/env/__init__.py
.py
import click from hatch.cli.env.create import create from hatch.cli.env.find import find from hatch.cli.env.lock import lock from hatch.cli.env.prune import prune from hatch.cli.env.remove import remove from hatch.cli.env.run import run from hatch.cli.env.show import show @click.group(short_help="Manage project envi...
24
511
hatch
src/hatch/cli/env/run.py
.py
from __future__ import annotations import os from typing import TYPE_CHECKING import click from hatch.config.constants import AppEnvVars if TYPE_CHECKING: from hatch.cli.application import Application def filter_environments(environments, filter_data): selected_environments = [] for env_name, env_data...
148
5,154
hatch
src/hatch/cli/env/find.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Locate environments") @click.argument("env_name", default="default") @click.pass_obj def find(app: Application, env_name: str): """Loca...
25
681
hatch
src/hatch/cli/env/create.py
.py
from __future__ import annotations import os from typing import TYPE_CHECKING import click from hatch.config.constants import AppEnvVars if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Create environments") @click.argument("env_name", default="default") @click.pass_o...
50
1,566
hatch
src/hatch/cli/env/show.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Show the available environments") @click.argument("envs", required=False, nargs=-1) @click.option("--ascii", "force_ascii", is_flag=True, h...
214
7,863
hatch
src/hatch/cli/env/remove.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command(short_help="Remove environments") @click.argument("env_name", default="default") @click.pass_context def remove(ctx: click.Context, env_name: str): ...
35
1,117
hatch
src/hatch/cli/env/lock.py
.py
from __future__ import annotations import os from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application def dependency_lock_click_options(fn): """Options shared by ``hatch dep lock`` and top-level ``hatch lock``.""" decorators = [ click.option(...
256
9,168
hatch
src/hatch/cli/types/core.py
.py
from __future__ import annotations import os from functools import cached_property from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from hatch.env.plugin.interface import EnvironmentInterface from hatch.utils.fs import Path class TypeCheckEnvironment: def __init__(self, env: EnvironmentInterface)...
236
9,729
hatch
src/hatch/cli/run/__init__.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import click if TYPE_CHECKING: from hatch.cli.application import Application @click.command( short_help="Run commands within project environments", context_settings={"help_option_names": [], "ignore_unknown_options": True}, ) @click.ar...
164
5,866
hatch
src/hatch/plugin/utils.py
.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from hatch.env.collectors.plugin.interface import EnvironmentCollectorInterface def load_plugin_from_script( path: str, script_name: str, plugin_class: type[EnvironmentCollectorInterface], plugin_id: str ) -> type[Environm...
47
1,472
hatch
src/hatch/plugin/manager.py
.py
from hatchling.plugin.manager import PluginManager as _PluginManager class PluginManager(_PluginManager): def initialize(self): super().initialize() from hatch.plugin import specs self.manager.add_hookspecs(specs) def hatch_register_environment(self): from hatch.env.plugin i...
36
887
hatch
src/hatch/plugin/specs.py
.py
from hatchling.plugin.specs import hookspec @hookspec def hatch_register_environment(): """Register new classes that adhere to the environment interface.""" @hookspec def hatch_register_environment_collector(): """Register new classes that adhere to the environment collector interface.""" @hookspec def ha...
32
775
hatch
src/hatch/env/utils.py
.py
from __future__ import annotations import os from hatch.config.constants import AppEnvVars def get_env_var(*, plugin_name: str, option: str) -> str: return f"{AppEnvVars.ENV_OPTION_PREFIX}{plugin_name}_{option.replace('-', '_')}".upper() def get_env_var_option(*, plugin_name: str, option: str, default: str = ...
67
2,163
hatch
src/hatch/env/system.py
.py
import os from hatch.env.plugin.interface import EnvironmentInterface from hatch.utils.env import PythonInfo class SystemEnvironment(EnvironmentInterface): PLUGIN_NAME = "system" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.python_info = PythonInfo(self.platfo...
51
1,663
hatch
src/hatch/env/context.py
.py
from abc import ABC, abstractmethod from hatch.env.utils import get_verbosity_flag from hatchling.utils.context import ContextFormatter class EnvironmentContextFormatterBase(ContextFormatter, ABC): @abstractmethod def formatters(self): return {} class EnvironmentContextFormatter(EnvironmentContextF...
85
2,798
hatch
src/hatch/env/lock.py
.py
""" Resolve and write environment lockfiles (PEP 751 ``pylock.toml``) via pluggable **lockers**. Lockers are registered with ``hatch_register_locker``; built-ins ``uv`` and ``pip`` delegate to ``uv pip compile`` / ``pip lock``. See ``docs/how-to/environment/lockfiles.md``. """ from __future__ import annotations from...
300
10,548
hatch
src/hatch/env/virtual.py
.py
from __future__ import annotations import os import sys import sysconfig from contextlib import contextmanager, nullcontext, suppress from functools import cached_property from os.path import isabs from typing import TYPE_CHECKING from hatch.config.constants import AppEnvVars from hatch.env.plugin.interface import En...
550
21,818
hatch
src/hatch/env/lockers/hooks.py
.py
from hatch.env.lockers.pip import PipLocker from hatch.env.lockers.uv import UvLocker from hatchling.plugin import hookimpl @hookimpl def hatch_register_locker(): return [UvLocker, PipLocker]
9
198
hatch
src/hatch/env/lockers/uv.py
.py
from __future__ import annotations import tempfile from typing import TYPE_CHECKING from hatch.env.lockers.interface import LockerInterface from hatch.env.utils import add_verbosity_flag from hatch.utils.fs import Path if TYPE_CHECKING: from hatch.env.plugin.interface import EnvironmentInterface from hatch.e...
173
5,612
hatch
src/hatch/env/lockers/interface.py
.py
from __future__ import annotations from abc import ABC, abstractmethod from typing import TYPE_CHECKING if TYPE_CHECKING: from hatch.env.plugin.interface import EnvironmentInterface from hatch.utils.fs import Path class LockerInterface(ABC): """ Pluggable dependency locker. Implementations are ...
77
2,323
hatch
src/hatch/env/lockers/pip.py
.py
from __future__ import annotations import tempfile from typing import TYPE_CHECKING from hatch.env.lockers.interface import LockerInterface from hatch.env.utils import add_verbosity_flag from hatch.utils.fs import Path if TYPE_CHECKING: from hatch.env.plugin.interface import EnvironmentInterface class PipLocke...
115
3,806
hatch
src/hatch/env/internal/__init__.py
.py
from __future__ import annotations from typing import Any from hatch.env.utils import ensure_valid_environment def get_internal_env_config() -> dict[str, Any]: from hatch.env.internal import build, static_analysis, test, type_check, uv internal_config = {} for env_name, env_config in ( ("hatch-...
61
2,436
hatch
src/hatch/env/internal/type_check.py
.py
from __future__ import annotations from typing import Any def get_default_config() -> dict[str, Any]: from hatch.env.internal.test import get_default_config as get_test_config test_config = get_test_config() test_deps = test_config.get("dependencies", []) return { "installer": "uv", ...
25
776
hatch
src/hatch/env/internal/uv.py
.py
from __future__ import annotations from typing import Any def get_default_config() -> dict[str, Any]: return { "skip-install": True, "installer": "uv", }
11
181
hatch
src/hatch/env/internal/static_analysis.py
.py
from __future__ import annotations from typing import Any def get_default_config() -> dict[str, Any]: return { "skip-install": True, "installer": "uv", "dependencies": [f"ruff=={RUFF_DEFAULT_VERSION}"], "scripts": { "format-check": "ruff format{env:HATCH_FMT_ARGS:}{env...
45
1,484
hatch
src/hatch/env/internal/test.py
.py
from __future__ import annotations from typing import Any def get_default_config() -> dict[str, Any]: return { "installer": "uv", "dependencies": [ "coverage-enable-subprocess==1.0", "coverage[toml]~=7.11", "pytest~=9.0", "pytest-mock~=3.12", ...
26
794
hatch
src/hatch/env/internal/build.py
.py
from __future__ import annotations from typing import Any def get_default_config() -> dict[str, Any]: return { "skip-install": True, "builder": True, "installer": "uv", }
12
206
hatch
src/hatch/env/collectors/default.py
.py
from hatch.env.collectors.plugin.interface import EnvironmentCollectorInterface from hatch.env.internal import get_internal_env_config from hatch.env.utils import ensure_valid_environment class DefaultEnvironmentCollector(EnvironmentCollectorInterface): PLUGIN_NAME = "default" def get_initial_config(self): ...
14
486
hatch
src/hatch/env/collectors/custom.py
.py
from __future__ import annotations import os from typing import Any from hatch.env.collectors.plugin.interface import EnvironmentCollectorInterface from hatch.plugin.constants import DEFAULT_CUSTOM_SCRIPT from hatch.plugin.utils import load_plugin_from_script class CustomEnvironmentCollector: PLUGIN_NAME = "cus...
44
1,475
hatch
src/hatch/env/collectors/plugin/hooks.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from hatch.env.collectors.custom import CustomEnvironmentCollector from hatch.env.collectors.default import DefaultEnvironmentCollector from hatchling.plugin import hookimpl if TYPE_CHECKING: from hatch.env.collectors.plugin.interface import Env...
17
633
hatch
src/hatch/env/collectors/plugin/interface.py
.py
from __future__ import annotations class EnvironmentCollectorInterface: """ Example usage: ```python tab="plugin.py" from hatch.env.collectors.plugin.interface import EnvironmentCollectorInterface class SpecialEnvironmentCollector(EnvironmentCollectorInterface): PLUGIN_NAME ...
73
2,013
hatch
src/hatch/env/plugin/hooks.py
.py
from hatch.env.system import SystemEnvironment from hatch.env.virtual import VirtualEnvironment from hatchling.plugin import hookimpl @hookimpl def hatch_register_environment(): return [SystemEnvironment, VirtualEnvironment]
9
231
hatch
src/hatch/env/plugin/interface.py
.py
from __future__ import annotations import os import sys from abc import ABC, abstractmethod from contextlib import contextmanager from functools import cached_property from os.path import isabs from typing import TYPE_CHECKING, Any from hatch.config.constants import AppEnvVars from hatch.env.utils import add_verbosit...
1,497
57,651
hatch
src/hatch/template/default.py
.py
from hatch.template import File, files_default, find_template_files from hatch.template.plugin.interface import TemplateInterface from hatch.utils.fs import Path from hatch.utils.network import download_file class DefaultTemplate(TemplateInterface): PLUGIN_NAME = "default" def __init__(self, *args, **kwargs)...
130
5,226
hatch
src/hatch/template/files_feature_cli.py
.py
from hatch.template import File from hatch.utils.fs import Path class PackageEntryPoint(File): TEMPLATE = """\ import sys if __name__ == "__main__": from {package_name}.cli import {package_name} sys.exit({package_name}()) """ def __init__( self, template_config: dict, plugin...
44
1,092
hatch
src/hatch/template/__init__.py
.py
from __future__ import annotations from contextlib import suppress from typing import TYPE_CHECKING if TYPE_CHECKING: from hatch.utils.fs import Path class File: def __init__(self, path: Path | None, contents: str = ""): self.path = path self.contents = contents self.feature = None ...
34
780
hatch
src/hatch/template/files_feature_ci.py
.py
from hatch.template import File from hatch.utils.fs import Path class CommandLinePackage(File): TEMPLATE = """\ name: test on: push: branches: [main, master] pull_request: branches: [main, master] concurrency: group: test-${{ github.head_ref }} cancel-in-progress: true env: PYTHONUNBUFFERED: ...
57
1,416
hatch
src/hatch/template/files_default.py
.py
from hatch.template import File from hatch.utils.fs import Path class PackageRoot(File): def __init__( self, template_config: dict, plugin_config: dict, # noqa: ARG002 ): super().__init__(Path(template_config["package_name"], "__init__.py"), "") class MetadataFile(File): ...
185
5,947
hatch
src/hatch/template/files_feature_tests.py
.py
from hatch.template import File from hatch.utils.fs import Path class TestsPackageRoot(File): def __init__( self, template_config: dict, # noqa: ARG002 plugin_config: dict, # noqa: ARG002 ): super().__init__(Path("tests", "__init__.py"))
12
282
hatch
src/hatch/template/plugin/hooks.py
.py
from hatch.template.default import DefaultTemplate from hatchling.plugin import hookimpl @hookimpl def hatch_register_template(): return DefaultTemplate
8
159
hatch
src/hatch/template/plugin/interface.py
.py
class TemplateInterface: PLUGIN_NAME = "" PRIORITY = 100 def __init__(self, plugin_config: dict, cache_dir, creation_time): self.plugin_config = plugin_config self.cache_dir = cache_dir self.creation_time = creation_time def initialize_config(self, config): """ ...
22
778
hatch
release/unix/make_scripts_portable.py
.py
from __future__ import annotations import sys import sysconfig from io import BytesIO from pathlib import Path def main(): interpreter = Path(sys.executable).resolve() # https://github.com/indygreg/python-build-standalone/blob/20240415/cpython-unix/build-cpython.sh#L812-L813 portable_shebang = b'#!/bin/...
50
1,393
hatch
release/macos/build_pkg.py
.py
""" This script must be run from the root of the repository. At a high level, the goal is to have a directory that emulates the full path structure of the target machine which then gets packaged by tools that are only available on macOS. """ from __future__ import annotations import argparse import shutil import sub...
120
3,959
hatch
release/windows/make_scripts_portable.py
.py
from __future__ import annotations import sys import sysconfig from contextlib import closing from importlib.metadata import entry_points from io import BytesIO from os.path import relpath from pathlib import Path from tempfile import TemporaryDirectory from urllib.request import urlopen from zipfile import ZIP_DEFLAT...
92
3,242
flit
bootstrap_dev.py
.py
#!/usr/bin/env python3 # Symlink install flit & flit_core for development. # Most projects can do the same with 'flit install --symlink'. # But that doesn't work until Flit is installed, so we need some bootstrapping. import argparse import logging import os from pathlib import Path import sys my_dir = Path(__file__...
41
1,044
flit
prepare_license_list.py
.py
# Call with path to SPDX license-list-data repo, cloned from: # https://github.com/spdx/license-list-data import json import pprint import sys from pathlib import Path list_data_repo = Path(sys.argv[1]) with (list_data_repo / 'json' / 'licenses.json').open('rb') as f: licenses_json = json.load(f) condensed = {...
24
677
flit
flit_core/bootstrap_install.py
.py
"""Install flit_core without using any other tools. Normally, you would install flit_core with pip like any other Python package. This script is meant to help with 'bootstrapping' other packaging systems, where you may need flit_core to build other packaging tools. Use 'python -m flit_core.wheel' to make a wheel, the...
58
1,741
flit
flit_core/build_dists.py
.py
"""Build flit_core to upload to PyPI. Normally, this should only be used by me when making a release. """ import os from flit_core import buildapi os.chdir(os.path.dirname(os.path.abspath(__file__))) print("Building sdist") sdist_fname = buildapi.build_sdist('dist/') print(os.path.join('dist', sdist_fname)) print(...
18
421
flit
flit_core/tests_core/test_buildapi.py
.py
from contextlib import contextmanager import os import os.path as osp import tarfile from testpath import assert_isfile, assert_isdir from testpath.tempdir import TemporaryDirectory import zipfile from flit_core import buildapi samples_dir = osp.join(osp.dirname(__file__), 'samples') @contextmanager def cwd(director...
94
3,934
flit
flit_core/tests_core/test_config.py
.py
import logging import re import sys from pathlib import Path import pytest from flit_core import config samples_dir = Path(__file__).parent / 'samples' def test_load_toml(): inf = config.read_flit_config(samples_dir / 'module1-pkg.toml') assert inf.module == 'module1' def test_load_toml_ns(): inf = con...
411
15,983
flit
flit_core/tests_core/test_wheel.py
.py
from pathlib import Path from zipfile import ZipFile from testpath import assert_isfile from flit_core.wheel import make_wheel_in, main samples_dir = Path(__file__).parent / 'samples' def test_licenses_dir(tmp_path): # Smoketest for https://github.com/pypa/flit/issues/399 info = make_wheel_in(samples_dir / ...
56
2,072
flit
flit_core/tests_core/test_build_thyself.py
.py
"""Tests of flit_core building itself""" import email.parser import os import os.path as osp import pytest import tarfile from testpath import assert_isdir, assert_isfile import zipfile from flit_core import buildapi @pytest.fixture() def cwd_project(): proj_dir = osp.dirname(osp.dirname(osp.abspath(buildapi.__fi...
65
1,818