Skip to content

Commit

Permalink
fix: replace deprecated pkg_resources with importlib (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
timmahrt authored Nov 4, 2023
1 parent 89bb335 commit 6327bc4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ Please view [CHANGELOG.md](https://github.com/timmahrt/praatIO/blob/main/CHANGEL

Python module `https://pypi.org/project/typing-extensions/`. It should be installed automatically with praatio but you can install it manually if you have any problems.

``Python 3.7.*`` or above

[Click here to visit travis-ci and see the specific versions of python that praatIO is currently tested under](<https://travis-ci.org/timmahrt/praatIO>)
``Python 3.7.*`` or above (CI tested with python `3.7` through `3.12`).

If you are using ``Python 2.x`` or ``Python < 3.7``, you can use `PraatIO 4.x`.

Expand Down
2 changes: 1 addition & 1 deletion examples/get_pitch_and_formants.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
450,
forceRegenerate=False,
)
tg = textgrid.openTextgrid(join(tgPath, "mary.TextGrid"))
tg = textgrid.openTextgrid(join(tgPath, "mary.TextGrid"), False)
tier = tg.getTier("phone")
filteredData = tier.getValuesInIntervals(maryPitchData)

Expand Down
15 changes: 8 additions & 7 deletions praatio/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import subprocess
import itertools
import wave
from pkg_resources import resource_filename
from importlib import resources
from typing_extensions import Literal
from typing import Any, Iterator, List, Tuple, NoReturn, Type, Optional

Expand All @@ -15,11 +15,13 @@

Interval = constants.Interval

# Get the folder one level above the current folder
scriptsPath = resource_filename(
"praatio",
"praatScripts",
)
# New in python 3.9
if hasattr(resources, "files"):
scriptsPath = resources.files("praatio") / "praatScripts"
# Deprecated in python 3.11
else:
with resources.path("praatio", "praatScripts") as path:
scriptsPath = path


def find(list, value, reverse) -> Optional[int]:
Expand Down Expand Up @@ -386,7 +388,6 @@ def findAll(txt: str, subStr: str) -> List[int]:
def runPraatScript(
praatEXE: str, scriptFN: str, argList: List[Any], cwd: str = None
) -> None:

# Popen gives a not-very-transparent error
if not os.path.exists(praatEXE):
raise errors.FileNotFound(praatEXE)
Expand Down

0 comments on commit 6327bc4

Please sign in to comment.