Skip to content

Commit

Permalink
Remove deprecated distutils (#20481)
Browse files Browse the repository at this point in the history
* Remove deprecated distutils

* Fix format

* Fix package name

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
lantiga and pre-commit-ci[bot] authored Dec 9, 2024
1 parent 38971a0 commit caa9e1e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dockers/base-cuda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get install -y \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-distutils \
python3-setuptools \
python${PYTHON_VERSION}-dev \
&& \
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
Expand Down
2 changes: 1 addition & 1 deletion dockers/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN \
dvipng \
texlive-pictures \
python3 \
python3-distutils \
python3-setuptools \
python3-dev \
&& \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
Expand Down
18 changes: 17 additions & 1 deletion examples/fabric/reinforcement_learning/rl/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import argparse
import math
import os
from distutils.util import strtobool
from typing import TYPE_CHECKING, Optional, Union

import gymnasium as gym
Expand All @@ -12,6 +11,23 @@
from rl.agent import PPOAgent, PPOLightningAgent


def strtobool(val):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'.
Raises ValueError if 'val' is anything else.
Note: taken from distutils after its deprecation.
"""
val = val.lower()
if val in ("y", "yes", "t", "true", "on", "1"):
return 1
if val in ("n", "no", "f", "false", "off", "0"):
return 0
raise ValueError(f"invalid truth value {val!r}")


def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--exp-name", type=str, default="default", help="the name of this experiment")
Expand Down

0 comments on commit caa9e1e

Please sign in to comment.