From a18417904b3c881b0b06d845f263313fb61d5284 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 12 Jun 2022 07:39:35 -0700 Subject: [PATCH 1/6] Fix typo: tha -> the --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4948ef24..262469ad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,6 +49,6 @@ def test_centos5_dist_release(self): self._test_outcome(desired_outcome, 'centos', '5') ``` -Where the name of the method is not indicative of the lookup folder but rather tha two last arguments in `_test_outcome`. +Where the name of the method is not indicative of the lookup folder but rather the two last arguments in `_test_outcome`. -A test case is mandatory under `TestOverall` for a PR to be complete. \ No newline at end of file +A test case is mandatory under `TestOverall` for a PR to be complete. From b84e1ff11d325cb38437457dc7a4aa2ef0d7be0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jun 2022 05:44:48 -0700 Subject: [PATCH 2/6] Actions(deps): Bump actions/setup-python from 3 to 4 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yaml | 8 +++++--- .github/workflows/deploy.yml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index afe339b9..7f8dd008 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,9 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 + with: + python-version: 3.x - name: Install tox run: python -m pip install tox @@ -39,7 +41,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} @@ -64,7 +66,7 @@ jobs: - uses: codecov/codecov-action@v3 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: 3.x diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 002905fc..dc1b7a78 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.tag }} - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 with: python-version: 3.x - shell: bash From fc50845c4af02fcee0c5218894b2b07a8a8940f8 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 26 Jun 2022 17:41:21 -0700 Subject: [PATCH 3/6] Replace setup.py with build Using setup.py is no longer recommended by setuptools. Instead, projects should use build: https://github.com/pypa/build. Invoking build will create a source and wheel distribution https://pypa-build.readthedocs.io/en/latest/: > By default, a source distribution (sdist) is built from {srcdir} and a > binary distribution (wheel) is built from the sdist. See the setuptools quickstart guides for more information: https://setuptools.pypa.io/en/latest/userguide/quickstart.html > Instead, when creating new Python packages, it is recommended to use a > command line tool called build. This tool will automatically download > setuptools and any other build-time dependencies that your project > might have. You just need to specify them in a pyproject.toml file at > the root of your package, as indicated in the following section. --- .github/workflows/deploy.yml | 6 +++--- .pre-commit-config.yaml | 1 - Makefile | 6 +++--- pyproject.toml | 3 +++ setup.py | 17 ----------------- tox.ini | 1 + 6 files changed, 10 insertions(+), 24 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dc1b7a78..ffbfe8dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,7 +1,7 @@ name: "Deploy to PyPI" on: workflow_dispatch: - inputs: + inputs: tag: description: "Git tag to deploy to PyPI" required: true @@ -21,7 +21,7 @@ jobs: - shell: bash run: | python -m pip install --disable-pip-version-check -U pip - python -m pip install -U setuptools wheel twine - python setup.py sdist bdist_wheel + python -m pip install -U build twine + python -m build python -m twine check dist/* python -m twine upload --username=__token__ --password=${{ secrets.PYPI_TOKEN }} dist/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a4b3294..9a2251ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,5 +19,4 @@ repos: args: ["--strict"] additional_dependencies: [ "pytest==6.2.5", - "types-setuptools==57.4.2", ] diff --git a/Makefile b/Makefile index 585ca2ef..ad3ec566 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ clean: .PHONY: build build: - python setup.py sdist bdist_wheel + python -m build .PHONY: publish publish: @@ -72,12 +72,12 @@ dev: instdev test .PHONY: instdev instdev: pip install -r dev-requirements.txt - python setup.py develop + pip install -e . @echo "$@ done." .PHONY: install install: - python setup.py install + pip install . @echo "$@ done." .PHONY: clobber diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fed528d4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py deleted file mode 100644 index 4ab6be28..00000000 --- a/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2015-2020 Nir Cohen -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from setuptools import setup - -setup() diff --git a/tox.ini b/tox.ini index efa6ae6d..cc9dfc51 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ [tox] minversion = 1.9 envlist = lint, py{36,37,38,39,310,py3} +isolated_build = true skip_missing_interpreters = true [testenv] From 095882f9b4b397085c34c9bbe20ec05263b9e008 Mon Sep 17 00:00:00 2001 From: Zac the Wise <75515581+TechWiz-3@users.noreply.github.com> Date: Wed, 20 Jul 2022 06:04:36 +1000 Subject: [PATCH 4/6] Improve readme 'usage' code block (#343) --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e22ed1ee..de6f3c79 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,12 @@ $ distro -j $ python >>> import distro ->>> distro.linux_distribution(full_distribution_name=False) -('centos', '7.1.1503', 'Core') +>>> distro.name(pretty=True) +'CentOS Linux 8' +>>> distro.id() +'centos' +>>> distro.version(best=True) +'8.4.2105' ``` From 8be3ae67e4a3bef3cc31b0f682955b0d9e85501e Mon Sep 17 00:00:00 2001 From: Samuel FORESTIER Date: Mon, 10 Oct 2022 14:42:40 +0000 Subject: [PATCH 5/6] Cache `/etc/debian_version` content (#349) This patch is a follow-up for 6d44662 (#333), introducing caching of `/etc/debian_version` file content, to prevent opening and reading operations for each `distro.version()` call. --- src/distro/distro.py | 18 +++++++++++------- tests/test_distro.py | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/distro/distro.py b/src/distro/distro.py index 8fc5a41d..489b8ec6 100755 --- a/src/distro/distro.py +++ b/src/distro/distro.py @@ -900,13 +900,7 @@ def version(self, pretty: bool = False, best: bool = False) -> str: versions.insert(0, self.oslevel_info()) elif self.id() == "debian" or "debian" in self.like().split(): # On Debian-like, add debian_version file content to candidates list. - try: - with open( - os.path.join(self.etc_dir, "debian_version"), encoding="ascii" - ) as fp: - versions.append(fp.readline().rstrip()) - except FileNotFoundError: - pass + versions.append(self._debian_version) version = "" if best: # This algorithm uses the last version in priority order that has @@ -1217,6 +1211,16 @@ def _oslevel_info(self) -> str: return "" return self._to_str(stdout).strip() + @cached_property + def _debian_version(self) -> str: + try: + with open( + os.path.join(self.etc_dir, "debian_version"), encoding="ascii" + ) as fp: + return fp.readline().rstrip() + except FileNotFoundError: + return "" + @staticmethod def _parse_uname_content(lines: Sequence[str]) -> Dict[str, str]: if not lines: diff --git a/tests/test_distro.py b/tests/test_distro.py index 36061d8f..3dda970a 100644 --- a/tests/test_distro.py +++ b/tests/test_distro.py @@ -2272,6 +2272,6 @@ def test_repr(self) -> None: repr_str = repr(distro._distro) assert "LinuxDistribution" in repr_str for attr in MODULE_DISTRO.__dict__.keys(): - if attr in ("root_dir", "etc_dir", "usr_lib_dir"): + if attr in ("root_dir", "etc_dir", "usr_lib_dir", "_debian_version"): continue assert f"{attr}=" in repr_str From 7766e989a79101c1b8ec02e5e76aad520bf0abcd Mon Sep 17 00:00:00 2001 From: Samuel FORESTIER Date: Mon, 10 Oct 2022 15:27:19 +0000 Subject: [PATCH 6/6] Release 1.8.0 --- CHANGELOG.md | 20 ++++++++++++++++++-- src/distro/distro.py | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d854ae..75588d28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +## 1.8.0 (2022.10.10) + +BACKWARD COMPATIBILITY: +* Replace `setup.py` with `build` [[#342](https://github.com/python-distro/distro/pull/342)] + +ENHANCEMENTS: +* Lowered `LinuxDistribution._distro_release_info` method complexity [[#327](https://github.com/python-distro/distro/pull/327)] +* Added official support for Buildroot distribution [[#329](https://github.com/python-distro/distro/pull/329)] +* Added official support for Guix distribution [[#330](https://github.com/python-distro/distro/pull/330)] +* Added support for `/etc/debian_version` [[#333](https://github.com/python-distro/distro/pull/333)] & [[#349](https://github.com/python-distro/distro/pull/349)] +* Fixed a typography in CONTRIBUTING.md [[#340](https://github.com/python-distro/distro/pull/340)] +* Improved README.md "Usage" code block [[#343](https://github.com/python-distro/distro/pull/343)] + +RELEASE: +* Bumped black to v22.3.0 in pre-commit.ci configuration [[#331](https://github.com/python-distro/distro/pull/331)] +* Enabled GitHub Dependabot to keep GitHub Actions up to date [[#335](https://github.com/python-distro/distro/pull/335)] + ## 1.7.0 (2022.02.15) BACKWARD COMPATIBILITY: @@ -130,7 +147,7 @@ RELEASE: ## 1.0.4 (2017.04.01) BUG FIXES: -* Guess common *-release files if /etc not readable [[#175](https://github.com/python-distro/distro/issues/175)] +* Guess common \*-release files if /etc not readable [[#175](https://github.com/python-distro/distro/issues/175)] ## 1.0.3 (2017.03.19) @@ -213,4 +230,3 @@ TESTS: DOCS: * Documentation fixes - diff --git a/src/distro/distro.py b/src/distro/distro.py index 489b8ec6..89e18680 100755 --- a/src/distro/distro.py +++ b/src/distro/distro.py @@ -55,7 +55,7 @@ # Python 3.7 TypedDict = dict -__version__ = "1.7.0" +__version__ = "1.8.0" class VersionDict(TypedDict):