Skip to content

Commit 5d9b5ba

Browse files
Merge branch 'master' into security/prevent_rootfs_escape
2 parents 91de73f + 7766e98 commit 5d9b5ba

File tree

12 files changed

+58
-46
lines changed

12 files changed

+58
-46
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
- uses: actions/checkout@v3
1414

1515
- name: Set up Python
16-
uses: actions/setup-python@v3
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: 3.x
1719

1820
- name: Install tox
1921
run: python -m pip install tox
@@ -39,7 +41,7 @@ jobs:
3941
- uses: actions/checkout@v3
4042

4143
- name: Set up Python ${{ matrix.python }}
42-
uses: actions/setup-python@v3
44+
uses: actions/setup-python@v4
4345
with:
4446
python-version: ${{ matrix.python }}
4547

@@ -64,7 +66,7 @@ jobs:
6466
- uses: codecov/codecov-action@v3
6567

6668
- name: Set up Python
67-
uses: actions/setup-python@v3
69+
uses: actions/setup-python@v4
6870
with:
6971
python-version: 3.x
7072

.github/workflows/deploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "Deploy to PyPI"
22
on:
33
workflow_dispatch:
4-
inputs:
4+
inputs:
55
tag:
66
description: "Git tag to deploy to PyPI"
77
required: true
@@ -15,13 +15,13 @@ jobs:
1515
- uses: actions/checkout@v3
1616
with:
1717
ref: ${{ github.event.inputs.tag }}
18-
- uses: actions/setup-python@v3
18+
- uses: actions/setup-python@v4
1919
with:
2020
python-version: 3.x
2121
- shell: bash
2222
run: |
2323
python -m pip install --disable-pip-version-check -U pip
24-
python -m pip install -U setuptools wheel twine
25-
python setup.py sdist bdist_wheel
24+
python -m pip install -U build twine
25+
python -m build
2626
python -m twine check dist/*
2727
python -m twine upload --username=__token__ --password=${{ secrets.PYPI_TOKEN }} dist/*

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ repos:
1919
args: ["--strict"]
2020
additional_dependencies: [
2121
"pytest==6.2.5",
22-
"types-setuptools==57.4.2",
2322
]

CHANGELOG.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## 1.8.0 (2022.10.10)
2+
3+
BACKWARD COMPATIBILITY:
4+
* Replace `setup.py` with `build` [[#342](https://github.com/python-distro/distro/pull/342)]
5+
6+
ENHANCEMENTS:
7+
* Lowered `LinuxDistribution._distro_release_info` method complexity [[#327](https://github.com/python-distro/distro/pull/327)]
8+
* Added official support for Buildroot distribution [[#329](https://github.com/python-distro/distro/pull/329)]
9+
* Added official support for Guix distribution [[#330](https://github.com/python-distro/distro/pull/330)]
10+
* Added support for `/etc/debian_version` [[#333](https://github.com/python-distro/distro/pull/333)] & [[#349](https://github.com/python-distro/distro/pull/349)]
11+
* Fixed a typography in CONTRIBUTING.md [[#340](https://github.com/python-distro/distro/pull/340)]
12+
* Improved README.md "Usage" code block [[#343](https://github.com/python-distro/distro/pull/343)]
13+
14+
RELEASE:
15+
* Bumped black to v22.3.0 in pre-commit.ci configuration [[#331](https://github.com/python-distro/distro/pull/331)]
16+
* Enabled GitHub Dependabot to keep GitHub Actions up to date [[#335](https://github.com/python-distro/distro/pull/335)]
17+
118
## 1.7.0 (2022.02.15)
219

320
BACKWARD COMPATIBILITY:
@@ -130,7 +147,7 @@ RELEASE:
130147
## 1.0.4 (2017.04.01)
131148

132149
BUG FIXES:
133-
* Guess common *-release files if /etc not readable [[#175](https://github.com/python-distro/distro/issues/175)]
150+
* Guess common \*-release files if /etc not readable [[#175](https://github.com/python-distro/distro/issues/175)]
134151

135152
## 1.0.3 (2017.03.19)
136153

@@ -213,4 +230,3 @@ TESTS:
213230

214231
DOCS:
215232
* Documentation fixes
216-

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ def test_centos5_dist_release(self):
4949
self._test_outcome(desired_outcome, 'centos', '5')
5050
```
5151

52-
Where the name of the method is not indicative of the lookup folder but rather tha two last arguments in `_test_outcome`.
52+
Where the name of the method is not indicative of the lookup folder but rather the two last arguments in `_test_outcome`.
5353

54-
A test case is mandatory under `TestOverall` for a PR to be complete.
54+
A test case is mandatory under `TestOverall` for a PR to be complete.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ clean:
5454

5555
.PHONY: build
5656
build:
57-
python setup.py sdist bdist_wheel
57+
python -m build
5858

5959
.PHONY: publish
6060
publish:
@@ -72,12 +72,12 @@ dev: instdev test
7272
.PHONY: instdev
7373
instdev:
7474
pip install -r dev-requirements.txt
75-
python setup.py develop
75+
pip install -e .
7676
@echo "$@ done."
7777

7878
.PHONY: install
7979
install:
80-
python setup.py install
80+
pip install .
8181
@echo "$@ done."
8282

8383
.PHONY: clobber

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,12 @@ $ distro -j
7575

7676
$ python
7777
>>> import distro
78-
>>> distro.linux_distribution(full_distribution_name=False)
79-
('centos', '7.1.1503', 'Core')
78+
>>> distro.name(pretty=True)
79+
'CentOS Linux 8'
80+
>>> distro.id()
81+
'centos'
82+
>>> distro.version(best=True)
83+
'8.4.2105'
8084
```
8185

8286

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/distro/distro.py

100755100644
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
# Python 3.7
5757
TypedDict = dict
5858

59-
__version__ = "1.7.0"
59+
__version__ = "1.8.0"
6060

6161

6262
class VersionDict(TypedDict):
@@ -903,16 +903,7 @@ def version(self, pretty: bool = False, best: bool = False) -> str:
903903
versions.insert(0, self.oslevel_info())
904904
elif self.id() == "debian" or "debian" in self.like().split():
905905
# On Debian-like, add debian_version file content to candidates list.
906-
try:
907-
with open(
908-
self.__resolve_chroot_symlink_as_needed(
909-
os.path.join(self.etc_dir, "debian_version")
910-
),
911-
encoding="ascii",
912-
) as fp:
913-
versions.append(fp.readline().rstrip())
914-
except FileNotFoundError:
915-
pass
906+
versions.append(self._debian_version)
916907
version = ""
917908
if best:
918909
# This algorithm uses the last version in priority order that has
@@ -1280,6 +1271,19 @@ def _oslevel_info(self) -> str:
12801271
return ""
12811272
return self._to_str(stdout).strip()
12821273

1274+
@cached_property
1275+
def _debian_version(self) -> str:
1276+
try:
1277+
with open(
1278+
self.__resolve_chroot_symlink_as_needed(
1279+
os.path.join(self.etc_dir, "debian_version")
1280+
),
1281+
encoding="ascii",
1282+
) as fp:
1283+
versions.append(fp.readline().rstrip())
1284+
except FileNotFoundError:
1285+
pass
1286+
12831287
@staticmethod
12841288
def _parse_uname_content(lines: Sequence[str]) -> Dict[str, str]:
12851289
if not lines:

0 commit comments

Comments
 (0)