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 | tests/helpers/templates/wheel/standard_default_extra_metadata.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 52 | 1,439 |
hatch | tests/helpers/templates/wheel/standard_editable_pth_extra_dependencies.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 50 | 1,419 |
hatch | tests/helpers/templates/wheel/standard_default_license_single.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 50 | 1,290 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_artifacts.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 51 | 1,353 |
hatch | tests/helpers/templates/wheel/standard_default_namespace_package.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 52 | 1,374 |
hatch | tests/helpers/templates/wheel/standard_default_python_constraint_three_components.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 50 | 1,289 |
hatch | tests/helpers/templates/wheel/standard_editable_exact_force_include.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 59 | 1,852 |
hatch | tests/helpers/templates/wheel/standard_editable_exact_extra_dependencies.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 59 | 1,754 |
hatch | tests/helpers/templates/wheel/standard_editable_pth.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 49 | 1,397 |
hatch | tests/helpers/templates/wheel/standard_default_build_script.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 50 | 1,294 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_force_include.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 52 | 1,410 |
hatch | tests/helpers/templates/wheel/standard_default_sbom.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 55 | 1,492 |
hatch | tests/helpers/templates/wheel/standard_default_license_multiple.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.licenses_multiple import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
meta... | 53 | 1,398 |
hatch | tests/helpers/templates/wheel/standard_editable_pth_force_include.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 50 | 1,517 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_configured_build_hooks.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 51 | 1,359 |
hatch | tests/helpers/templates/wheel/standard_default_shared_scripts.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 88 | 2,280 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_artifacts_with_src_layout.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 52 | 1,398 |
hatch | tests/helpers/templates/licenses/__init__.py | .py | Apache_2_0 = """\
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION,
AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution
as defined by Sections 1 through 9 of this document.
"Lice... | 212 | 11,379 |
hatch | scripts/write_coverage_summary_report.py | .py | import json
from decimal import ROUND_DOWN, Decimal
from pathlib import Path
PRECISION = Decimal(".01")
def main():
project_root = Path(__file__).resolve().parent.parent
coverage_summary = project_root / "coverage-summary.json"
coverage_data = json.loads(coverage_summary.read_text(encoding="utf-8"))
... | 50 | 1,713 |
hatch | scripts/utils.py | .py | import re
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def get_latest_release(project):
history_file = ROOT / "docs" / "history" / f"{project}.md"
release_headers = 0
history_file_lines = []
with history_file.open(encoding="utf-8") as f:
for line in f:
h... | 29 | 825 |
hatch | scripts/update_distributions.py | .py | from __future__ import annotations
import re
from ast import literal_eval
from collections import defaultdict
import httpx2
from utils import ROOT
URL = "https://raw.githubusercontent.com/ofek/pyapp/master/build.rs"
OUTPUT_FILE = ROOT / "src" / "hatch" / "python" / "distributions.py"
ARCHES = {("linux", "x86"): "i68... | 83 | 2,746 |
hatch | scripts/update_ruff.py | .py | from __future__ import annotations
import json
import re
import subprocess
import sys
import typing
from importlib.metadata import version
from utils import ROOT
if typing.TYPE_CHECKING:
from pathlib import Path
# fmt: off
UNSELECTED_RULE_PATTERNS: list[str] = [
# Allow non-abstract empty methods in abstrac... | 173 | 5,921 |
hatch | scripts/set_release_version.py | .py | import os
from utils import get_latest_release
def main():
version, _ = get_latest_release("hatch")
parts = version.split(".")
with open(os.environ["GITHUB_ENV"], "a", encoding="utf-8") as f:
f.write(f"HATCH_DOCS_VERSION={parts[0]}.{parts[1]}\n")
if __name__ == "__main__":
main()
| 16 | 311 |
hatch | scripts/bump.py | .py | import argparse
import subprocess
from datetime import datetime, timezone
from utils import ROOT, get_latest_release
TEMPLATE = (
"## [{version}](https://github.com/pypa/hatch/releases/tag/{project}-v{version}) - "
"{year}-{month:02}-{day:02} ## {{: #{project}-v{version} }}"
)
def main():
parser = argpa... | 64 | 2,217 |
hatch | scripts/release_github.py | .py | import argparse
import subprocess
import sys
import webbrowser
from urllib.parse import urlencode
from utils import get_latest_release
def main():
parser = argparse.ArgumentParser()
parser.add_argument("project", choices=["hatch", "hatchling"])
args = parser.parse_args()
version, notes = get_latest_... | 41 | 1,076 |
hatch | scripts/validate_history.py | .py | import re
import sys
from utils import ROOT
HEADER_PATTERN = (
r"^\[([a-z0-9.]+)\]\(https://github\.com/pypa/hatch/releases/tag/({package}-v\1)\)"
r" - [0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}} ## \{{: #\2 \}}$"
)
def main():
for package in ("hatch", "hatchling"):
history_file = ROOT / "docs" / "history"... | 36 | 1,000 |
hatch | scripts/generate_coverage_summary.py | .py | import json
from collections import defaultdict
from lxml import etree # nosec B410
from utils import ROOT
PACKAGES = {
"backend/src/hatchling/": "hatchling",
"src/hatch/": "hatch",
"tests/": "tests",
}
def main():
coverage_report = ROOT / "coverage.xml"
root = etree.fromstring(coverage_report.... | 54 | 1,807 |
hatch | backend/tests/downstream/integrate.py | .py | import errno
import json
import os
import platform
import shutil
import stat
import subprocess
import sys
import tempfile
from contextlib import contextmanager
from zipfile import ZipFile
import requests
import tomli
from packaging.requirements import Requirement
from packaging.specifiers import SpecifierSet
from virt... | 263 | 9,462 |
hatch | backend/src/hatchling/__main__.py | .py | import sys
if __name__ == "__main__":
from hatchling.cli import hatchling
sys.exit(hatchling())
| 7 | 106 |
hatch | backend/src/hatchling/build.py | .py | from __future__ import annotations
import os
from typing import Any
__all__ = [
"build_editable",
"build_sdist",
"build_wheel",
"get_requires_for_build_editable",
"get_requires_for_build_sdist",
"get_requires_for_build_wheel",
]
__all__ += ["__all__"]
def get_requires_for_build_sdist(config_... | 145 | 5,577 |
hatch | backend/src/hatchling/ouroboros.py | .py | from __future__ import annotations
import os
import re
from ast import literal_eval
from typing import Any
from hatchling.build import * # noqa: F403
def read_dependencies() -> list[str]:
pattern = r"^dependencies = (\[.*?\])$"
with open(os.path.join(os.getcwd(), "pyproject.toml"), encoding="utf-8") as f:... | 53 | 1,507 |
hatch | backend/src/hatchling/builders/app.py | .py | from __future__ import annotations
from typing import Any
from hatchling.builders.binary import BinaryBuilder
class AppBuilder(BinaryBuilder):
PLUGIN_NAME = "app"
def build_bootstrap(
self,
directory: str,
**build_data: Any,
) -> str:
self.app.display_warning(
... | 21 | 530 |
hatch | backend/src/hatchling/builders/utils.py | .py | from __future__ import annotations
import os
import shutil
from base64 import urlsafe_b64encode
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Iterable
from zipfile import ZipInfo
def replace_file(src: str, dst: str) -> None:
try:
os.replace(src, dst)
# Happen... | 129 | 3,819 |
hatch | backend/src/hatchling/builders/custom.py | .py | from __future__ import annotations
import os
from typing import TYPE_CHECKING, Any, Generic
from hatchling.builders.plugin.interface import BuilderInterface
from hatchling.metadata.core import ProjectMetadata
from hatchling.plugin.manager import PluginManagerBound
from hatchling.plugin.utils import load_plugin_from_s... | 55 | 2,127 |
hatch | backend/src/hatchling/builders/binary.py | .py | from __future__ import annotations
import os
import sys
from typing import TYPE_CHECKING, Any
from hatchling.builders.config import BuilderConfig
from hatchling.builders.plugin.interface import BuilderInterface
if TYPE_CHECKING:
from collections.abc import Callable
class BinaryBuilderConfig(BuilderConfig):
... | 203 | 7,639 |
hatch | backend/src/hatchling/builders/macos.py | .py | from __future__ import annotations
import os
import platform
import re
__all__ = ["process_macos_plat_tag"]
def process_macos_plat_tag(plat: str, /, *, compat: bool) -> str:
"""
Process the macOS platform tag. This will normalize the macOS version to
10.16 if compat=True. If the MACOSX_DEPLOYMENT_TARGET... | 59 | 2,085 |
hatch | backend/src/hatchling/builders/constants.py | .py | DEFAULT_BUILD_DIRECTORY = "dist"
EXCLUDED_DIRECTORIES = frozenset((
# Python bytecode
"__pycache__",
# Single virtual environment
".venv",
# Git
".git",
# Mercurial
".hg",
# Hatch
".hatch",
# tox
".tox",
# nox
".nox",
# Ruff
".ruff_cache",
# pytest
... | 46 | 905 |
hatch | backend/src/hatchling/builders/sdist.py | .py | from __future__ import annotations
import gzip
import os
import tarfile
import tempfile
from contextlib import closing
from copy import copy
from io import BytesIO
from time import time as get_current_timestamp
from typing import TYPE_CHECKING, Any
from hatchling.builders.config import BuilderConfig
from hatchling.bu... | 358 | 13,558 |
hatch | backend/src/hatchling/builders/wheel.py | .py | from __future__ import annotations
import csv
import hashlib
import os
import stat
import sys
import tempfile
import zipfile
from functools import cached_property
from io import StringIO
from typing import TYPE_CHECKING, Any, NamedTuple, cast
from hatchling.__about__ import __version__
from hatchling.builders.config ... | 902 | 38,187 |
hatch | backend/src/hatchling/builders/config.py | .py | from __future__ import annotations
import os
from contextlib import contextmanager
from functools import cached_property
from typing import TYPE_CHECKING, Any, TypeVar
import pathspec
from hatchling.builders.constants import DEFAULT_BUILD_DIRECTORY, EXCLUDED_DIRECTORIES, BuildEnvVars
from hatchling.builders.utils im... | 865 | 35,662 |
hatch | backend/src/hatchling/builders/hooks/custom.py | .py | from __future__ import annotations
import os
from typing import Any
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.plugin.utils import load_plugin_from_script
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
class CustomBuildHook:
PLUGIN_NAME = "custom"
de... | 42 | 1,378 |
hatch | backend/src/hatchling/builders/hooks/version.py | .py | from __future__ import annotations
from typing import Any
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.version.core import VersionFile
class VersionBuildHook(BuildHookInterface):
PLUGIN_NAME = "version"
def __init__(self, *args: Any, **kwargs: Any) -> None:
... | 72 | 2,416 |
hatch | backend/src/hatchling/builders/hooks/plugin/hooks.py | .py | from __future__ import annotations
import typing
from hatchling.builders.hooks.custom import CustomBuildHook
from hatchling.builders.hooks.version import VersionBuildHook
from hatchling.plugin import hookimpl
if typing.TYPE_CHECKING:
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
@hoo... | 17 | 545 |
hatch | backend/src/hatchling/builders/hooks/plugin/interface.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Generic, cast
from hatchling.builders.config import BuilderConfigBound
if TYPE_CHECKING:
from hatchling.bridge.app import Application
from hatchling.metadata.core import ProjectMetadata
class BuildHookInterface(Generic[BuilderConfigB... | 149 | 4,250 |
hatch | backend/src/hatchling/builders/plugin/hooks.py | .py | from __future__ import annotations
import typing
from hatchling.builders.app import AppBuilder
from hatchling.builders.binary import BinaryBuilder
from hatchling.builders.custom import CustomBuilder
from hatchling.builders.sdist import SdistBuilder
from hatchling.builders.wheel import WheelBuilder
from hatchling.plug... | 19 | 617 |
hatch | backend/src/hatchling/builders/plugin/interface.py | .py | from __future__ import annotations
import os
import re
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Generic, cast
from hatchling.builders.config import BuilderConfig, BuilderConfigBound, env_var_enabled
from hatchling.builders.constants import EXCLUDED_DIRECTORIES, EXCLUDED_FILES, BuildE... | 444 | 16,217 |
hatch | backend/src/hatchling/metadata/utils.py | .py | from __future__ import annotations
import re
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from packaging.requirements import Requirement
from hatchling.metadata.core import ProjectMetadata
# NOTE: this module should rarely be changed because it is likely to be used by other packages like Hatch
... | 88 | 3,440 |
hatch | backend/src/hatchling/metadata/custom.py | .py | from __future__ import annotations
import os
from typing import Any
from hatchling.metadata.plugin.interface import MetadataHookInterface
from hatchling.plugin.utils import load_plugin_from_script
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
class CustomMetadataHook:
PLUGIN_NAME = "custom"
de... | 42 | 1,424 |
hatch | backend/src/hatchling/metadata/spec.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from hatchling.metadata.utils import split_import_name_annotation
if TYPE_CHECKING:
from collections.abc import Callable
from hatchling.metadata.core import ProjectMetadata
DEFAULT_METADATA_VERSION = "2.5"
LATEST_METADATA_VERSION = "2... | 729 | 28,970 |
hatch | backend/src/hatchling/metadata/core.py | .py | from __future__ import annotations
import os
import sys
from contextlib import suppress
from copy import deepcopy
from typing import TYPE_CHECKING, Any, Generic, cast
from hatchling.metadata.utils import (
format_dependency,
is_valid_import_name,
is_valid_project_name,
normalize_project_name,
norm... | 1,700 | 65,849 |
hatch | backend/src/hatchling/metadata/plugin/hooks.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from hatchling.metadata.custom import CustomMetadataHook
from hatchling.plugin import hookimpl
if TYPE_CHECKING:
from hatchling.metadata.plugin.interface import MetadataHookInterface
@hookimpl
def hatch_register_metadata_hook() -> type[Metadat... | 15 | 397 |
hatch | backend/src/hatchling/metadata/plugin/interface.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
class MetadataHookInterface(ABC): # no cov
"""
Example usage:
```python tab="plugin.py"
from hatchling.metadata.plugin.interface import MetadataHookInterface
class SpecialMetadataHook(MetadataHookInterface):
PLUGIN... | 67 | 1,500 |
hatch | backend/src/hatchling/version/scheme/standard.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, cast
from hatchling.version.scheme.plugin.interface import VersionSchemeInterface
if TYPE_CHECKING:
from packaging.version import Version
class StandardScheme(VersionSchemeInterface):
"""
See https://peps.python.org/pep-... | 112 | 4,420 |
hatch | backend/src/hatchling/version/scheme/plugin/hooks.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from hatchling.plugin import hookimpl
from hatchling.version.scheme.standard import StandardScheme
if TYPE_CHECKING:
from hatchling.version.scheme.plugin.interface import VersionSchemeInterface
@hookimpl
def hatch_register_version_scheme() -> ... | 15 | 376 |
hatch | backend/src/hatchling/version/scheme/plugin/interface.py | .py | from __future__ import annotations
import os
from abc import ABC, abstractmethod
from functools import cached_property
class VersionSchemeInterface(ABC): # no cov
"""
Example usage:
```python tab="plugin.py"
from hatchling.version.scheme.plugin.interface import VersionSchemeInterface
class Sp... | 86 | 2,384 |
hatch | backend/src/hatchling/version/source/regex.py | .py | from hatchling.version.core import VersionFile
from hatchling.version.source.plugin.interface import VersionSourceInterface
class RegexSource(VersionSourceInterface):
PLUGIN_NAME = "regex"
def get_version_data(self) -> dict:
relative_path = self.config.get("path", "")
if not relative_path:
... | 30 | 1,065 |
hatch | backend/src/hatchling/version/source/code.py | .py | from __future__ import annotations
import os
from hatchling.version.source.plugin.interface import VersionSourceInterface
class CodeSource(VersionSourceInterface):
PLUGIN_NAME = "code"
def get_version_data(self) -> dict:
import sys
from importlib.util import module_from_spec, spec_from_file... | 65 | 2,348 |
hatch | backend/src/hatchling/version/source/env.py | .py | from __future__ import annotations
import os
from hatchling.version.source.plugin.interface import VersionSourceInterface
class EnvSource(VersionSourceInterface):
PLUGIN_NAME = "env"
def get_version_data(self) -> dict:
variable = self.config.get("variable", "")
if not variable:
... | 30 | 911 |
hatch | backend/src/hatchling/version/source/plugin/hooks.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from hatchling.plugin import hookimpl
from hatchling.version.source.code import CodeSource
from hatchling.version.source.env import EnvSource
from hatchling.version.source.regex import RegexSource
if TYPE_CHECKING:
from hatchling.version.source.... | 17 | 502 |
hatch | backend/src/hatchling/version/source/plugin/interface.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
class VersionSourceInterface(ABC): # no cov
"""
Example usage:
```python tab="plugin.py"
from hatchling.version.source.plugin.interface import VersionSourceInterface
class SpecialVersionSource(VersionSourceInterface):
... | 70 | 1,852 |
hatch | backend/src/hatchling/utils/constants.py | .py | DEFAULT_BUILD_SCRIPT = "hatch_build.py"
DEFAULT_CONFIG_FILE = "hatch.toml"
class VersionEnvVars:
VALIDATE_BUMP = "HATCH_VERSION_VALIDATE_BUMP"
| 7 | 149 |
hatch | backend/src/hatchling/utils/context.py | .py | from __future__ import annotations
import os
import string
from abc import ABC, abstractmethod
from collections import ChainMap
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any
from hatchling.utils.fs import path_to_uri
if TYPE_CHECKING:
from collections.abc import Iterable, Iterator, ... | 176 | 6,109 |
hatch | backend/src/hatchling/utils/fs.py | .py | from __future__ import annotations
import os
def locate_file(root: str, file_name: str, *, boundary: str | None = None) -> str | None:
while True:
file_path = os.path.join(root, file_name)
if os.path.isfile(file_path):
return file_path
if boundary is not None and os.path.exis... | 27 | 714 |
hatch | backend/src/hatchling/cli/__init__.py | .py | import argparse
from hatchling.cli.build import build_command
from hatchling.cli.dep import dep_command
from hatchling.cli.metadata import metadata_command
from hatchling.cli.version import version_command
def hatchling() -> int:
parser = argparse.ArgumentParser(prog="hatchling", allow_abbrev=False)
subparse... | 29 | 730 |
hatch | backend/src/hatchling/cli/dep/__init__.py | .py | from __future__ import annotations
import sys
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
import argparse
def synced_impl(*, dependencies: list[str], python: str) -> None:
import subprocess
from ast import literal_eval
from packaging.requirements import Requirement
from hatchling.c... | 38 | 1,169 |
hatch | backend/src/hatchling/cli/dep/core.py | .py | from __future__ import annotations
import re
import sys
from importlib.metadata import Distribution, DistributionFinder
from packaging.markers import default_environment
from packaging.requirements import Requirement
class DistributionCache:
def __init__(self, sys_path: list[str]) -> None:
self._resolve... | 133 | 5,316 |
hatch | backend/src/hatchling/cli/metadata/__init__.py | .py | from __future__ import annotations
import argparse
from typing import Any
def metadata_impl(
*,
called_by_app: bool, # noqa: ARG001
field: str,
compact: bool,
) -> None:
import json
import os
from hatchling.bridge.app import Application
from hatchling.metadata.core import ProjectMet... | 59 | 1,695 |
hatch | backend/src/hatchling/cli/version/__init__.py | .py | from __future__ import annotations
import argparse
from typing import Any
def version_impl(
*,
called_by_app: bool, # noqa: ARG001
force: bool,
desired_version: str,
) -> None:
import os
from hatchling.bridge.app import Application
from hatchling.metadata.core import ProjectMetadata
... | 73 | 2,426 |
hatch | backend/src/hatchling/plugin/utils.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar
if TYPE_CHECKING:
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.builders.plugin.interface import BuilderInterface
from hatchling.metadata.plugin.interface import MetadataHookInterface
... | 49 | 1,638 |
hatch | backend/src/hatchling/plugin/exceptions.py | .py | class UnknownPluginError(ValueError):
pass
| 3 | 47 |
hatch | backend/src/hatchling/plugin/manager.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar
import pluggy
if TYPE_CHECKING:
from collections.abc import Callable
class PluginManager:
def __init__(self) -> None:
self.manager = pluggy.PluginManager("hatch")
self.third_party_plugins = ThirdPartyPlugins(self.m... | 115 | 3,731 |
hatch | backend/src/hatchling/plugin/__init__.py | .py | import pluggy
hookimpl = pluggy.HookimplMarker("hatch")
| 4 | 57 |
hatch | backend/src/hatchling/plugin/specs.py | .py | import pluggy
hookspec = pluggy.HookspecMarker("hatch")
@hookspec
def hatch_register_version_source() -> None:
"""Register new classes that adhere to the version source interface."""
@hookspec
def hatch_register_builder() -> None:
"""Register new classes that adhere to the builder interface."""
@hookspec... | 24 | 565 |
hatch | backend/src/hatchling/bridge/app.py | .py | from __future__ import annotations
import os
import sys
from typing import Any
class Application:
"""
The way output is displayed can be [configured](../config/hatch.md#terminal) by users.
!!! important
Never import this directly; Hatch judiciously decides if a type of plugin requires
th... | 112 | 3,890 |
hatch | src/hatch/__main__.py | .py | if __name__ == "__main__":
from hatch.cli import main
main()
| 5 | 70 |
hatch | src/hatch/publish/index.py | .py | from __future__ import annotations
import re
from typing import TYPE_CHECKING
from hatch.publish.plugin.interface import PublisherInterface
from hatch.utils.fs import Path
from hatchling.metadata.utils import normalize_project_name
if TYPE_CHECKING:
from collections.abc import Iterable
class IndexPublisher(Pub... | 165 | 6,018 |
hatch | src/hatch/publish/auth.py | .py | from __future__ import annotations
from hatch.utils.fs import Path
class AuthenticationCredentials:
def __init__(
self,
app,
cache_dir: Path,
options: dict,
repo: str,
repo_config: dict[str, str],
):
self._app = app
self._pwu_path = cache_dir / ... | 117 | 3,864 |
hatch | src/hatch/publish/plugin/hooks.py | .py | from hatch.publish.index import IndexPublisher
from hatchling.plugin import hookimpl
@hookimpl
def hatch_register_publisher():
return IndexPublisher
| 8 | 155 |
hatch | src/hatch/publish/plugin/interface.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
class PublisherInterface(ABC):
"""
Example usage:
```python tab="plugin.py"
from hatch.publish.plugin.interface import PublisherInterface
class SpecialPublisher(PublisherInterface):
PLUGIN_NAME = 'specia... | 116 | 3,353 |
hatch | src/hatch/project/utils.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Iterable
def parse_script_command(command: str) -> tuple[str, str, bool]:
possible_script, _, args = command.partition(" ")
if possible_script == "-":
ignore_exit_code = True
... | 53 | 1,632 |
hatch | src/hatch/project/sources.py | .py | from __future__ import annotations
from functools import cached_property
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Iterable, Mapping
from hatch.dep.core import Dependency
_TYPE_KEYS: tuple[str, ...] = ("path", "git", "url", "index", "workspace")
class Source:
... | 492 | 16,945 |
hatch | src/hatch/project/constants.py | .py | BUILD_BACKEND = "hatchling.build"
DEFAULT_BUILD_DIRECTORY = "dist"
DEFAULT_BUILD_SCRIPT = "hatch_build.py"
DEFAULT_CONFIG_FILE = "hatch.toml"
class BuildEnvVars:
REQUESTED_TARGETS = "HATCH_BUILD_REQUESTED_TARGETS"
LOCATION = "HATCH_BUILD_LOCATION"
HOOKS_ONLY = "HATCH_BUILD_HOOKS_ONLY"
NO_HOOKS = "HATC... | 16 | 524 |
hatch | src/hatch/project/config.py | .py | from __future__ import annotations
import re
from copy import deepcopy
from functools import cached_property
from itertools import product
from os import environ
from typing import TYPE_CHECKING, Any, cast
from hatch.env.utils import ensure_valid_environment
from hatch.project.constants import DEFAULT_BUILD_DIRECTORY... | 802 | 32,263 |
hatch | src/hatch/project/env.py | .py | from __future__ import annotations
from functools import cached_property
from os import environ
from typing import TYPE_CHECKING, Any
from hatch.utils.platform import get_platform_name
if TYPE_CHECKING:
from hatch.env.plugin.interface import EnvironmentInterface
from hatch.utils.fs import Path
RESERVED_OPTI... | 456 | 17,876 |
hatch | src/hatch/project/core.py | .py | from __future__ import annotations
import re
from collections import defaultdict
from contextlib import contextmanager
from functools import cached_property
from typing import TYPE_CHECKING, Any, cast
from hatch.project.env import EnvironmentMetadata
from hatch.utils.fs import Path
from hatch.utils.runner import Exec... | 501 | 19,126 |
hatch | src/hatch/project/frontend/core.py | .py | from __future__ import annotations
import json
from functools import cache
from typing import TYPE_CHECKING, Any, Literal
from hatch.utils.fs import Path
from hatch.utils.runner import ExecutionContext
if TYPE_CHECKING:
from hatch.env.plugin.interface import EnvironmentInterface
from hatch.project.core impor... | 327 | 12,582 |
hatch | src/hatch/project/frontend/scripts/core_metadata.py | .py | from __future__ import annotations
import json
import os
from hatchling.metadata.core import ProjectMetadata
from hatchling.metadata.utils import resolve_metadata_fields
from hatchling.plugin.manager import PluginManager
RUNNER: dict = {}
def main() -> None:
project_root: str = RUNNER["project_root"]
outpu... | 30 | 783 |
hatch | src/hatch/project/frontend/scripts/build_deps.py | .py | from __future__ import annotations
import json
import os
from hatchling.bridge.app import Application
from hatchling.metadata.core import ProjectMetadata
from hatchling.plugin.manager import PluginManager
RUNNER: dict = {}
def main() -> None:
project_root: str = RUNNER["project_root"]
output_dir: str = RUN... | 41 | 1,138 |
hatch | src/hatch/project/frontend/scripts/standard.py | .py | from __future__ import annotations
import json
import os
import shutil
import subprocess
import sys
from tempfile import TemporaryDirectory
RUNNER: dict = {}
def main() -> int:
project_root: str = RUNNER["project_root"]
output_dir: str = RUNNER["output_dir"]
hook: str = RUNNER["hook"]
kwargs: dict[s... | 83 | 2,476 |
hatch | src/hatch/index/publish.py | .py | from hatch.index.errors import ArtifactMetadataError
MULTIPLE_USE_METADATA_FIELDS = {
"classifier",
"dynamic",
"license_file",
"obsoletes_dist",
"platform",
"project_url",
"provides_dist",
"provides_extra",
"requires_dist",
"requires_external",
"supported_platform",
}
RENAME... | 104 | 3,378 |
hatch | src/hatch/index/errors.py | .py | class ArtifactMetadataError(Exception):
pass
| 3 | 49 |
hatch | src/hatch/index/core.py | .py | from __future__ import annotations
from functools import cached_property
from typing import TYPE_CHECKING
import hyperlink
from hatch._version import __version__
if TYPE_CHECKING:
import httpx2
from hatch.utils.fs import Path
class IndexURLs:
def __init__(self, repo: str):
self.repo = hyperli... | 106 | 3,326 |
hatch | src/hatch/dep/sync.py | .py | from __future__ import annotations
import re
import sys
from importlib.metadata import Distribution, DistributionFinder
from typing import TYPE_CHECKING
from packaging.markers import default_environment
from hatch.dep.core import Dependency
from hatch.utils.fs import Path
if TYPE_CHECKING:
from collections.abc ... | 157 | 6,479 |
hatch | src/hatch/dep/core.py | .py | from __future__ import annotations
from functools import cached_property
from packaging.requirements import InvalidRequirement, Requirement
from hatch.utils.fs import Path
InvalidDependencyError = InvalidRequirement
class Dependency(Requirement):
def __init__(self, s: str, *, editable: bool = False) -> None:
... | 58 | 1,575 |
hatch | src/hatch/python/resolve.py | .py | from __future__ import annotations
import os
import platform
import sys
from abc import ABC, abstractmethod
from functools import cached_property
from typing import TYPE_CHECKING, Literal
from hatch.config.constants import PythonEnvVars
from hatch.errors import PythonDistributionResolutionError, PythonDistributionUnk... | 311 | 9,991 |
hatch | src/hatch/python/distributions.py | .py | from __future__ import annotations
# fmt: off
ORDERED_DISTRIBUTIONS: tuple[str, ...] = (
'3.7',
'3.8',
'3.9',
'3.10',
'3.11',
'3.12',
'3.13',
'3.14',
'3.15',
'pypy2.7',
'pypy3.9',
'pypy3.10',
'pypy3.11',
)
DISTRIBUTIONS: dict[str, dict[tuple[str, ...], str]] = {
... | 515 | 52,057 |
hatch | src/hatch/python/core.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from hatch.python.resolve import ORDERED_DISTRIBUTION_NAMES, get_distribution, is_valid_distribution_name
from hatch.utils.fs import temp_directory
if TYPE_CHECKING:
from hatch.python.resolve import Distribution
from hatch.utils.fs impo... | 126 | 4,016 |
hatch | src/hatch/errors/__init__.py | .py | class HatchError(Exception):
pass
class PythonDistributionUnknownError(HatchError):
pass
class PythonDistributionResolutionError(HatchError):
pass
| 11 | 163 |
hatch | src/hatch/config/user.py | .py | from __future__ import annotations
from typing import cast
from hatch.config.model import RootConfig
from hatch.utils.fs import Path
from hatch.utils.toml import load_toml_data
class ConfigFile:
def __init__(self, path: Path | None = None):
self._path: Path | None = path
self.model = cast(RootCo... | 68 | 1,655 |
hatch | src/hatch/config/utils.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import tomlkit
if TYPE_CHECKING:
from tomlkit.items import InlineTable
from tomlkit.toml_document import TOMLDocument
from hatch.utils.fs import Path
def save_toml_document(document: TOMLDocument, path: Path):
path.ensure_parent_d... | 21 | 491 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.