Merge pull request #141 from MightyCreak/docs-add-dependencies

Add project dependencies and fix Python 3.8 compatibility
This commit is contained in:
Creak 2022-01-09 11:04:18 -05:00 committed by GitHub
commit c224d17e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 13 deletions

View File

@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Linters can be run sooner (before installation) - Linters can be run sooner (before installation)
- Better messages when an error occurs while parsing the config file - Better messages when an error occurs while parsing the config file
- Start converting the code to static types - Start converting the code to static types
- Add more information about the dependencies in the documentation
### Fixed ### Fixed
- Removed the lasting lint errors (i.e. in main.py) - Removed the lasting lint errors (i.e. in main.py)

View File

@ -2,6 +2,40 @@
## Requirements ## Requirements
Diffuse depends on these projects:
* Python 3.8+
* PyPi
* Cairo and GObject Introspection development headers
* Meson
* Flatpak and Flatpak builder
### Install the distribution dependencies
It's a bit difficult to get the command lines for all the distributions and
their releases, but it should be enough to find the packages on other
distributions.
<details>
<summary>Debian/Ubuntu</summary>
```sh
sudo apt install python3-pip libcairo2-dev libgirepository1.0-dev meson flatpak flatpak-builder
```
_Note: Tested on Debian 11 (Buster) and Ubuntu 20.04 (Focal)_
</details>
<details>
<summary>Fedora</summary>
```sh
sudo dnf install python-pip python3-cairo-devel python3-gobject-devel meson flatpak flatpak-builder
```
_Note: Tested on Fedora 34_
</details>
### Install the project dependencies
To install the requirements just to execute the binary, run: To install the requirements just to execute the binary, run:
```sh ```sh

View File

@ -24,6 +24,7 @@ import shlex
import sys import sys
from gettext import gettext as _ from gettext import gettext as _
from typing import List
from diffuse import constants from diffuse import constants
from diffuse import utils from diffuse import utils
@ -386,7 +387,7 @@ class Preferences:
def getEncodings(self): def getEncodings(self):
return self.encodings return self.encodings
def _getDefaultEncodings(self) -> list[str]: def _getDefaultEncodings(self) -> List[str]:
return self.string_prefs['encoding_auto_detect_codecs'].split() return self.string_prefs['encoding_auto_detect_codecs'].split()
def getDefaultEncoding(self) -> str: def getDefaultEncoding(self) -> str:

View File

@ -25,7 +25,7 @@ import traceback
from enum import IntFlag from enum import IntFlag
from gettext import gettext as _ from gettext import gettext as _
from typing import Final, Optional, TextIO from typing import Final, List, Optional, TextIO
from diffuse import constants from diffuse import constants
from diffuse.resources import theResources from diffuse.resources import theResources
@ -106,7 +106,7 @@ def logErrorAndDialog(msg: str, parent: Gtk.Widget = None) -> None:
dialog.destroy() dialog.destroy()
def make_subdirs(p: str, ss: list[str]) -> str: def make_subdirs(p: str, ss: List[str]) -> str:
'''Create nested subdirectories and return the complete path.''' '''Create nested subdirectories and return the complete path.'''
for s in ss: for s in ss:
p = os.path.join(p, s) p = os.path.join(p, s)
@ -221,7 +221,7 @@ def strip_eol(s: str) -> str:
return s return s
def _strip_eols(ss: list[str]) -> list[str]: def _strip_eols(ss: List[str]) -> List[str]:
'''Returns the list of strings without line ending characters.''' '''Returns the list of strings without line ending characters.'''
return [strip_eol(s) for s in ss] return [strip_eol(s) for s in ss]
@ -232,7 +232,7 @@ def popenReadLines(dn, cmd, prefs, bash_pref, success_results=None):
dn, cmd, prefs, bash_pref, success_results).decode('utf-8', errors='ignore'))) dn, cmd, prefs, bash_pref, success_results).decode('utf-8', errors='ignore')))
def readconfiglines(fd: TextIO) -> list[str]: def readconfiglines(fd: TextIO) -> List[str]:
return fd.read().replace('\r', '').split('\n') return fd.read().replace('\r', '').split('\n')
@ -243,7 +243,7 @@ def globEscape(s: str) -> str:
# split string into lines based upon DOS, Mac, and Unix line endings # split string into lines based upon DOS, Mac, and Unix line endings
def splitlines(text: str) -> list[str]: def splitlines(text: str) -> List[str]:
# split on new line characters # split on new line characters
temp, i, n = [], 0, len(text) temp, i, n = [], 0, len(text)
while i < n: while i < n:
@ -272,7 +272,7 @@ def splitlines(text: str) -> list[str]:
# also recognize old Mac OS line endings # also recognize old Mac OS line endings
def readlines(fd: TextIO) -> list[str]: def readlines(fd: TextIO) -> List[str]:
return _strip_eols(splitlines(fd.read())) return _strip_eols(splitlines(fd.read()))

View File

@ -19,6 +19,8 @@
import os import os
from typing import Tuple
from diffuse import utils from diffuse import utils
from diffuse.vcs.svn import Svn from diffuse.vcs.svn import Svn
@ -33,7 +35,7 @@ class Svk(Svn):
return 'Depot Path: ' return 'Depot Path: '
@staticmethod @staticmethod
def _parseStatusLine(s: str) -> tuple[str, str]: def _parseStatusLine(s: str) -> Tuple[str, str]:
if len(s) < 4 or s[0] not in 'ACDMR': if len(s) < 4 or s[0] not in 'ACDMR':
return '', '' return '', ''
return s[0], s[4:] return s[0], s[4:]

View File

@ -21,7 +21,7 @@ import os
import glob import glob
from gettext import gettext as _ from gettext import gettext as _
from typing import Optional from typing import Optional, Tuple
from diffuse import utils from diffuse import utils
from diffuse.vcs.folder_set import FolderSet from diffuse.vcs.folder_set import FolderSet
@ -44,7 +44,7 @@ class Svn(VcsInterface):
return 'URL: ' return 'URL: '
@staticmethod @staticmethod
def _parseStatusLine(s: str) -> tuple[str, str]: def _parseStatusLine(s: str) -> Tuple[str, str]:
if len(s) < 8 or s[0] not in 'ACDMR': if len(s) < 8 or s[0] not in 'ACDMR':
return '', '' return '', ''
# subversion 1.6 adds a new column # subversion 1.6 adds a new column

View File

@ -20,7 +20,7 @@
import os import os
from gettext import gettext as _ from gettext import gettext as _
from typing import Optional from typing import List, Optional
from diffuse import utils from diffuse import utils
from diffuse.preferences import Preferences from diffuse.preferences import Preferences
@ -99,7 +99,7 @@ def _get_darcs_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
def _get_git_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]: def _get_git_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
if 'GIT_DIR' in os.environ: if 'GIT_DIR' in os.environ:
try: try:
ss: list[str] = utils.popenReadLines( ss: List[str] = utils.popenReadLines(
path, path,
[ [
prefs.getString('git_bin'), prefs.getString('git_bin'),
@ -185,7 +185,7 @@ def _get_svk_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
try: try:
# find working copies by parsing the config file # find working copies by parsing the config file
with open(svkconfig, 'r', encoding='utf-8') as f: with open(svkconfig, 'r', encoding='utf-8') as f:
ss: list[str] = utils.readlines(f) ss: List[str] = utils.readlines(f)
projs, sep = [], os.sep projs, sep = [], os.sep
# find the separator character # find the separator character
for s in ss: for s in ss: