Skip to content

Commit cf220ba

Browse files
authored
Manually get XDG_CONFIG_HOME and drop pyxdg (#102)
Drop `pyxdg` as dependency and instead get `XDG_CONFIG_HOME` manually. The same way is being used as `pyxdg` does: https://gitlab.freedesktop.org/xdg/pyxdg/-/blob/bd999c1c/xdg/BaseDirectory.py#L37-L38 There is a name clash between the two packages `xdg` and `pyxdg`. See: https://gitlab.freedesktop.org/xdg/pyxdg/-/issues/24 As only that one environment variable is being used from the library it can just as good be expanded manually. This solves the confusion and problems for users who have both installed and it also reduces the dependency footprint. Also use `os.path.join` for `config_file`.
1 parent bd9ba36 commit cf220ba

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apt update && apt install -y \
88
apt install -y xvfb && \
99
rm -rf /var/lib/apt/lists/* && apt clean
1010

11-
RUN pip3 install gatt pyxdg requests black
11+
RUN pip3 install gatt requests black
1212

1313
COPY . /siglo
1414

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pip3 install gatt pyxdg
2222

2323
```sh
2424
sudo pacman -S --needed meson python-pip base-devel bluez bluez-utils dbus-python python-gobject
25-
pip3 install gatt pyxdg
25+
pip3 install gatt
2626
```
2727

2828
### Fedora
@@ -36,7 +36,7 @@ pip3 install gatt
3636

3737
```sh
3838
sudo apt install libgtk-3-dev python3-pip meson python3-dbus gtk-update-icon-cache desktop-file-utils gettext appstream-util libglib2.0-dev
39-
pip3 install gatt pyxdg requests black
39+
pip3 install gatt requests black
4040
```
4141

4242
## Build/Install

python3-modules.json

-14
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,6 @@
6464
"sha256": "b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"
6565
}
6666
]
67-
},
68-
{
69-
"name": "python3-pyxdg",
70-
"buildsystem": "simple",
71-
"build-commands": [
72-
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"pyxdg\" --no-build-isolation"
73-
],
74-
"sources": [
75-
{
76-
"type": "file",
77-
"url": "https://files.pythonhosted.org/packages/6f/2e/2251b5ae2f003d865beef79c8fcd517e907ed6a69f58c32403cec3eba9b2/pyxdg-0.27.tar.gz",
78-
"sha256": "80bd93aae5ed82435f20462ea0208fb198d8eec262e831ee06ce9ddb6b91c5a5"
79-
}
80-
]
8167
}
8268
]
8369
}

src/config.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import configparser
2-
import xdg.BaseDirectory
32
import distutils
43
import distutils.util
4+
import os
55
from pathlib import Path
66

77

@@ -13,8 +13,10 @@ class config:
1313
"paired": "False",
1414
"adapter": "None",
1515
}
16-
config_dir = xdg.BaseDirectory.xdg_config_home
17-
config_file = config_dir + "/siglo.ini"
16+
config_dir = os.environ.get("XDG_CONFIG_HOME") or os.path.join(
17+
os.path.expanduser("~"), ".config"
18+
)
19+
config_file = os.path.join(config_dir, "siglo.ini")
1820

1921
def load_defaults(self):
2022
if not Path(self.config_dir).is_dir():

0 commit comments

Comments
 (0)