Skip to content

Commit caa9e1e

Browse files
Remove deprecated distutils (#20481)
* 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>
1 parent 38971a0 commit caa9e1e

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

dockers/base-cuda/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ RUN \
5959
add-apt-repository ppa:deadsnakes/ppa && \
6060
apt-get install -y \
6161
python${PYTHON_VERSION} \
62-
python${PYTHON_VERSION}-distutils \
62+
python3-setuptools \
6363
python${PYTHON_VERSION}-dev \
6464
&& \
6565
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \

dockers/docs/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ RUN \
4444
dvipng \
4545
texlive-pictures \
4646
python3 \
47-
python3-distutils \
47+
python3-setuptools \
4848
python3-dev \
4949
&& \
5050
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \

examples/fabric/reinforcement_learning/rl/utils.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
import math
33
import os
4-
from distutils.util import strtobool
54
from typing import TYPE_CHECKING, Optional, Union
65

76
import gymnasium as gym
@@ -12,6 +11,23 @@
1211
from rl.agent import PPOAgent, PPOLightningAgent
1312

1413

14+
def strtobool(val):
15+
"""Convert a string representation of truth to true (1) or false (0).
16+
17+
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'.
18+
Raises ValueError if 'val' is anything else.
19+
20+
Note: taken from distutils after its deprecation.
21+
22+
"""
23+
val = val.lower()
24+
if val in ("y", "yes", "t", "true", "on", "1"):
25+
return 1
26+
if val in ("n", "no", "f", "false", "off", "0"):
27+
return 0
28+
raise ValueError(f"invalid truth value {val!r}")
29+
30+
1531
def parse_args():
1632
parser = argparse.ArgumentParser()
1733
parser.add_argument("--exp-name", type=str, default="default", help="the name of this experiment")

0 commit comments

Comments
 (0)