From e5a8a5625a5139319f1d1da1d99e105aabe45b10 Mon Sep 17 00:00:00 2001 From: EnumDev Date: Thu, 9 Jul 2026 14:17:07 +0300 Subject: [PATCH] Initial commit --- .gitignore | 3 +++ check-version.sh | 9 +++++++ info.yml | 23 ++++++++++++++++ recipe.sh | 26 +++++++++++++++++++ .../handle-missing-pkg_resources-import.patch | 19 ++++++++++++++ source-files/mock.patch | 23 ++++++++++++++++ 6 files changed, 103 insertions(+) create mode 100644 .gitignore create mode 100644 check-version.sh create mode 100644 info.yml create mode 100644 recipe.sh create mode 100644 source-files/handle-missing-pkg_resources-import.patch create mode 100644 source-files/mock.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d96df7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Ignore BPM archives and signatures +*.bpm +*.bpm.sig diff --git a/check-version.sh b/check-version.sh new file mode 100644 index 0000000..ad7aa1e --- /dev/null +++ b/check-version.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Github repository +REPO="python-xlib/python-xlib" + +# Get tag name using Github Rest API +TAG_NAME=$(curl -s -L -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/"$REPO"/releases/latest | jq -r '.tag_name') + +echo "$TAG_NAME" diff --git a/info.yml b/info.yml new file mode 100644 index 0000000..dd6ff6c --- /dev/null +++ b/info.yml @@ -0,0 +1,23 @@ +name: python-xlib +description: A fully functional X client library for Python programs +version: "0.33" +revision: 1 +url: https://github.com/python-xlib/python-xlib +license: LGPL-2.1-or-later +maintainers: + - enumdev@enumerated.dev +architecture: any +output_architecture: any +type: source +depends: + - python-six +make_depends: + - python-build + - python-installer + - python-setuptools-scm + - python-wheel +downloads: + - url: https://github.com/python-xlib/python-xlib/archive/refs/tags/${BPM_PKG_VERSION}.tar.gz + extract_to: ${BPM_SOURCE} + extract_strip_components: 1 + checksum: e10d1b49655800bffe0fbb5eb31eeef915a4421952ef006d468d53d34901f6f8 diff --git a/recipe.sh b/recipe.sh new file mode 100644 index 0000000..28434a3 --- /dev/null +++ b/recipe.sh @@ -0,0 +1,26 @@ +# This is the recipe.sh script. It is executed by BPM in a temporary directory when compiling a source package +# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE +# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT + +# The prepare function is executed in the root of the temp directory +# This function is used for putting downloaded files to the correct location or applying patches +prepare() { + cd "$BPM_SOURCE" + patch -Np1 -i "$BPM_WORKDIR"/mock.patch + patch -Np1 -i "$BPM_WORKDIR"/handle-missing-pkg_resources-import.patch +} + +# The build function is executed in the source directory +# This function is used to compile the source code +build() { + python3 -m build --wheel --no-isolation . +} + +# The package function is executed in the source directory +# This function is used to move the compiled files into the output directory +package() { + python3 -m installer --destdir="$BPM_OUTPUT" dist/*.whl + + # Install package license + install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/python-xlib/LICENSE +} diff --git a/source-files/handle-missing-pkg_resources-import.patch b/source-files/handle-missing-pkg_resources-import.patch new file mode 100644 index 0000000..fbc9775 --- /dev/null +++ b/source-files/handle-missing-pkg_resources-import.patch @@ -0,0 +1,19 @@ +--- a/setup.py ++++ b/setup.py +@@ -1,12 +1,13 @@ + # Distutils script for python-xlib + +-from pkg_resources import parse_requirements ++from packaging.requirements import Requirement + from setuptools import (__version__ as setuptools_version, setup) + + + # Check setuptools is recent enough to support `setup.cfg`. +-setuptools_require = next(parse_requirements('setuptools>=30.3.0')) +-assert setuptools_version in setuptools_require, '{} is required'.format(setuptools_require) ++setuptools_require = Requirement('setuptools>=30.3.0') ++assert setuptools_require.specifier.contains(setuptools_version), \ ++ '{} is required (found {})'.format(setuptools_require, setuptools_version) + + + setup( diff --git a/source-files/mock.patch b/source-files/mock.patch new file mode 100644 index 0000000..d4f6646 --- /dev/null +++ b/source-files/mock.patch @@ -0,0 +1,23 @@ +diff --git a/dev-requirements.txt b/dev-requirements.txt +index b2f5288..22fc710 100644 +--- a/dev-requirements.txt ++++ b/dev-requirements.txt +@@ -1,5 +1,4 @@ + coverage + codecov +-mock + nose + setuptools-scm +diff --git a/test/test_unix_connect.py b/test/test_unix_connect.py +index 7680ba5..82e9f01 100644 +--- a/test/test_unix_connect.py ++++ b/test/test_unix_connect.py +@@ -6,7 +6,7 @@ import socket + import sys + import unittest + +-from mock import patch ++from unittest.mock import patch + + from Xlib.support import unix_connect + from Xlib.error import DisplayConnectionError, DisplayNameError