Skip to content

Commit

Permalink
enable py312 client (#985)
Browse files Browse the repository at this point in the history
* initial commit

* hooks

* dont be lazy with imports

* poetry

* trailing whitespace?

* poetry lock update

* imports

* config parser
  • Loading branch information
rcano-baseten authored Jun 26, 2024
1 parent 8d15053 commit 500cf02
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 262 deletions.
1 change: 0 additions & 1 deletion docker/base_images/base_image.Dockerfile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ RUN apt update && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt update -y && \
apt install -y python{{python_version}} && \
apt install -y python{{python_version}}-distutils && \
apt install -y python{{python_version}}-venv && \
apt install -y python{{python_version}}-dev && \
rm -rf /var/lib/apt/lists
Expand Down
497 changes: 249 additions & 248 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ psutil = ">=5.9.4"
pydantic = ">=1.10.0"
pytest-asyncio = "^0.23.6"
# Note: when using chains, 3.9 will be required at runtime, but other truss functionality works with 3.8.
python = ">=3.8,<3.12"
python = ">=3.8,<3.13"
python-json-logger = ">=2.0.2"
python-on-whales = "^0.68.0"
PyYAML = ">=6.0"
Expand Down
15 changes: 11 additions & 4 deletions truss/remote/remote_factory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import inspect
from configparser import DEFAULTSECT, SafeConfigParser

try:
from configparser import DEFAULTSECT
from configparser import SafeConfigParser as ConfigParser
except ImportError:
# We need to do this for py312 and onwards.
from configparser import DEFAULTSECT, ConfigParser # type: ignore

from functools import partial
from operator import is_not
from pathlib import Path
Expand All @@ -11,13 +18,13 @@
USER_TRUSSRC_PATH = Path("~/.trussrc").expanduser()


def load_config() -> SafeConfigParser:
config = SafeConfigParser()
def load_config() -> ConfigParser:
config = ConfigParser()
config.read(USER_TRUSSRC_PATH)
return config


def update_config(config: SafeConfigParser):
def update_config(config: ConfigParser):
with open(USER_TRUSSRC_PATH, "w") as configfile:
config.write(configfile)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Dict, List

import pkg_resources
from pkg_resources.extern.packaging import requirements # type: ignore
from packaging import requirements # type: ignore


def identify_requirement_name(req: str) -> str:
try:
parsed_req = pkg_resources.Requirement.parse(req)

parsed_req = requirements.Requirement(req)
return parsed_req.name # type: ignore
except (requirements.InvalidRequirement, ValueError):
# default to the whole line if we can't parse it.
Expand Down
9 changes: 4 additions & 5 deletions truss/util/path.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import os
import random
import shutil
import string
import tempfile
from contextlib import contextmanager
from distutils.dir_util import remove_tree
from distutils.file_util import copy_file
from pathlib import Path
from typing import Iterable, Iterator, List, Optional, Set, Tuple, Union

Expand Down Expand Up @@ -33,11 +32,11 @@ def copy_tree_path(src: Path, dest: Path, ignore_patterns: List[str] = []) -> No
dest_fp.mkdir(exist_ok=True)
else:
dest_fp.parent.mkdir(exist_ok=True, parents=True)
copy_file(str(sub_path), str(dest_fp), verbose=False)
shutil.copy2(str(sub_path), str(dest_fp))


def copy_file_path(src: Path, dest: Path) -> Tuple[str, str]:
return copy_file(str(src), str(dest), verbose=False)
return shutil.copy2(str(src), str(dest))


def copy_tree_or_file(src: Path, dest: Path) -> Union[List[str], Tuple[str, str]]:
Expand All @@ -48,7 +47,7 @@ def copy_tree_or_file(src: Path, dest: Path) -> Union[List[str], Tuple[str, str]


def remove_tree_path(target: Path) -> None:
return remove_tree(str(target), verbose=0)
return shutil.rmtree(str(target))


def get_max_modified_time_of_dir(path: Path) -> float:
Expand Down

0 comments on commit 500cf02

Please sign in to comment.