Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
boonhapus committed Feb 28, 2025
2 parents e8ab58f + fdd9f73 commit dfb8088
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 57 deletions.
4 changes: 1 addition & 3 deletions cs_tools/cli/commands/self.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pathlib
import shutil
import sys
import sysconfig
import zipfile

from cs_tools import __version__, _types, updater, utils
Expand Down Expand Up @@ -53,10 +52,9 @@ def info(
f"\n System Info: [fg-warn]{meta.local_system.system}[/]"
f"\n Configs Directory: [fg-warn]{cs_tools_venv.base_dir}[/]"
f"\nActivate VirtualEnv: [fg-warn]{source}[/]"
f"\n Platform Tags: [fg-warn]{sysconfig.get_platform()}[/]"
f"\n Platform Tags: [fg-warn]{utils.platform_tag()}[/]"
f"\n"
)

if anonymous:
text = utils.anonymize(text, anonymizer=" [dim]{anonymous}[/] ")

Expand Down
32 changes: 30 additions & 2 deletions cs_tools/updater/_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,35 @@ class CSToolsVenv(venv.EnvBuilder):
VENV_NAME = ".cs_tools"
"""Default name of the VirtualEnvironment."""

TYPICAL_BUILD_DEPENDENCIES = ("wheel >= 0.45", "setuptools >= 75", "hatch", "maturin")
# fmt: off
#
# DEV NOTE: @boonhapus, 2024/02/27
# AS OF TODAY, THERE ARE NO TOOLS IN THE PYTHON ECOSYSTEM WHICH HELP DISCOVER A
# PACKAGE'S build-system requirements. (see: pyproject.toml#build-system.requires)
#
# UPDATED FOR v1.6.0 ON 2024/02/27 ALA pip-dep-tree STYLE.
TYPICAL_BUILD_DEPENDENCIES = (
# TOP-LEVEL FOR MOST PYTHON-based DEPENDENCIES.
"setuptools >= 75",
"wheel >= 0.45",
# BUILD-REQUIRES
"flit_core >= 3.8, <4",

# TOP-LEVEL FOR RUST-based DEPENDENCIES.
"maturin",
# BUILD-REQUIRES
# setuptools ,
# wheel >= 0.36.2 ,
"tomli >= 1.1.0; python_version < '3.11'",
"setuptools-rust >= 1.4.0",

# TOP-LEVEL FOR DEVELOPMENT-based DEPENDENCIES.
"hatch",
# BUILD-REQUIRES
"hatchling >= 1.24.2",
"hatch-vcs >= 0.3.0",
)
# fmt: on
"""uv and pip do not discover these automatically."""

def __init__(
Expand All @@ -55,7 +83,7 @@ def __init__(
self.register_venv_path = register_venv_path

# REDUNDANT, BUT NECESSARY IF WE'RE INSTANTIATING DIRECTLY.
self.ctx = super().ensure_directories(self.base_dir / CSToolsVenv.VENV_NAME)
self.ctx = self.ensure_directories(self.base_dir / CSToolsVenv.VENV_NAME)

def __str__(self) -> str:
return f"<CSToolsVenv @ {self.base_dir} has_internet_access={self.has_internet_access}>"
Expand Down
18 changes: 16 additions & 2 deletions cs_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import logging
import pathlib
import sys
import sysconfig
import zipfile
import zlib

Expand All @@ -30,7 +31,7 @@

from cs_tools import _compat

log = logging.getLogger(__name__)
_LOG = logging.getLogger(__name__)
_T = TypeVar("_T")
_EVENT_LOOP: Optional[asyncio.AbstractEventLoop] = None

Expand Down Expand Up @@ -101,6 +102,19 @@ async def with_backpressure(coro: Awaitable) -> Any:
return await asyncio.gather(*(with_backpressure(coro) for coro in aws), return_exceptions=return_exceptions)


def platform_tag() -> str:
"""Return the platform tag for use in pip download."""
try:
from pip._vendor.packaging.tags import platform_tags

platform_tag = next(iter(platform_tags()))
except Exception:
_LOG.debug("Could not fetch platform tags from vendored pip.packaging, falling back to sysconfig.")
platform_tag = sysconfig.get_platform()

return platform_tag


def batched(iterable: Iterable[_T], *, n: int) -> Generator[Iterable[_T], None, None]:
"""Yield successive n-sized chunks from list."""
# batched('ABCDEFG', 3) --> ABC DEF G
Expand Down Expand Up @@ -269,7 +283,7 @@ def create_dynamic_model(__tablename__: str, *, sample_row: dict[str, Any]) -> t
py_type = type(value)
sa_type = SQLA_DATA_TYPES[py_type]
except KeyError:
log.warning(f"{__tablename__}.{column_name} found no data type for '{py_type}', faling back to VARCHAR..")
_LOG.warning(f"{__tablename__}.{column_name} found no data type for '{py_type}', faling back to VARCHAR..")
sa_type = sa_types.Text

field_definitions[column_name] = Annotated[py_type, Field(None, sa_column=Column(type_=sa_type))]
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "cs_tools"
dynamic = ["version"]
description = "Scale your ThoughtSpot adoption with tools created by the ThoughtSpot Solutions Consulting organization."
readme = "README.md"
requires-python = ">= 3.9"
requires-python = ">= 3.9.2"
license = {file = "LICENSE"}
authors = [
{name = "boonhapus", email="[email protected]"},
Expand All @@ -29,6 +29,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

dependencies = [
Expand Down
51 changes: 2 additions & 49 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dfb8088

Please sign in to comment.