Skip to content

Commit

Permalink
Merge pull request #161 from hugovk/update-ci
Browse files Browse the repository at this point in the history
Add support for Python 3.10-3.12 and drop EOL 3.5-3.7
  • Loading branch information
lostanlen authored Jan 23, 2024
2 parents 0a428b8 + e66831d commit 5e93526
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 179 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@

name: Run Tests on PR

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install dependencies
run: |
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# pysox documentation build configuration file, created by
# sphinx-quickstart on Tue May 17 14:11:03 2016.
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[metadata]
description-file = README.md
[bdist_wheel]
universal = 1
python_requires = >=3.8
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version = imp.load_source('sox.version', 'sox/version.py')

with open("README.md", "r") as fh:
with open("README.md") as fh:
long_description = fh.read()

if __name__ == "__main__":
Expand Down
24 changes: 11 additions & 13 deletions sox/combine.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Python wrapper around the SoX library.
This module requires that SoX is installed.
'''

from __future__ import print_function

from pathlib import Path
from typing import Union, Optional, List
Expand Down Expand Up @@ -41,7 +39,7 @@ class Combiner(Transformer):
'''

def __init__(self):
super(Combiner, self).__init__()
super().__init__()

def build(self,
input_filepath_list: Union[str, Path],
Expand Down Expand Up @@ -111,7 +109,7 @@ def build(self,

if status != 0:
raise SoxError(
"Stdout: {}\nStderr: {}".format(out, err)
f"Stdout: {out}\nStderr: {err}"
)
else:
logger.info(
Expand All @@ -121,7 +119,7 @@ def build(self,
" ".join(self.effects_log)
)
if out is not None:
logger.info("[SoX] {}".format(out))
logger.info(f"[SoX] {out}")
return True

def preview(self,
Expand Down Expand Up @@ -306,19 +304,19 @@ def set_input_format(self,
input_format.append([])

for i, f in enumerate(file_type):
input_format[i].extend(['-t', '{}'.format(f)])
input_format[i].extend(['-t', f'{f}'])

for i, r in enumerate(rate):
input_format[i].extend(['-r', '{}'.format(r)])
input_format[i].extend(['-r', f'{r}'])

for i, b in enumerate(bits):
input_format[i].extend(['-b', '{}'.format(b)])
input_format[i].extend(['-b', f'{b}'])

for i, c in enumerate(channels):
input_format[i].extend(['-c', '{}'.format(c)])
input_format[i].extend(['-c', f'{c}'])

for i, e in enumerate(encoding):
input_format[i].extend(['-e', '{}'.format(e)])
input_format[i].extend(['-e', f'{e}'])

for i, l in enumerate(ignore_length):
if l is True:
Expand Down Expand Up @@ -347,7 +345,7 @@ def _validate_sample_rates(input_filepath_list: List[Path],
file_info.sample_rate(f) for f in input_filepath_list
]
if not core.all_equal(sample_rates):
raise IOError(
raise OSError(
"Input files do not have the same sample rate. The {} combine "
"type requires that all files have the same sample rate"
.format(combine_type)
Expand All @@ -362,7 +360,7 @@ def _validate_num_channels(input_filepath_list: List[Path],
file_info.channels(f) for f in input_filepath_list
]
if not core.all_equal(channels):
raise IOError(
raise OSError(
"Input files do not have the same number of channels. The "
"{} combine type requires that all files have the same "
"number of channels"
Expand Down Expand Up @@ -441,7 +439,7 @@ def _build_input_format_list(input_filepath_list: List[Path],
fmts = [f for f in input_format]

for i, (vol, fmt) in enumerate(zip(vols, fmts)):
input_format_list[i].extend(['-v', '{}'.format(vol)])
input_format_list[i].extend(['-v', f'{vol}'])
input_format_list[i].extend(fmt)

return input_format_list
Expand Down
8 changes: 4 additions & 4 deletions sox/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ def soxi(filepath: Union[str, Path], argument: str) -> str:
filepath = str(filepath)

if argument not in SOXI_ARGS:
raise ValueError("Invalid argument '{}' to SoXI".format(argument))
raise ValueError(f"Invalid argument '{argument}' to SoXI")

args = ['sox', '--i']
args.append("-{}".format(argument))
args.append(f"-{argument}")
args.append(filepath)

try:
Expand All @@ -165,8 +165,8 @@ def soxi(filepath: Union[str, Path], argument: str) -> str:
stderr=subprocess.PIPE
)
except CalledProcessError as cpe:
logger.info("SoXI error message: {}".format(cpe.output))
raise SoxiError("SoXI failed with exit code {}".format(cpe.returncode))
logger.info(f"SoXI error message: {cpe.output}")
raise SoxiError(f"SoXI failed with exit code {cpe.returncode}")

shell_output = shell_output.decode("utf-8")

Expand Down
12 changes: 6 additions & 6 deletions sox/file_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ def validate_input_file(input_filepath: Union[str, Path]) -> None:
'''
input_filepath = Path(input_filepath)
if not input_filepath.exists():
raise IOError(
"input_filepath {} does not exist.".format(input_filepath)
raise OSError(
f"input_filepath {input_filepath} does not exist."
)
ext = file_extension(input_filepath)
if ext not in VALID_FORMATS:
logger.info("Valid formats: %s", " ".join(VALID_FORMATS))
logger.warning(
"This install of SoX cannot process .{} files.".format(ext)
f"This install of SoX cannot process .{ext} files."
)


Expand Down Expand Up @@ -304,15 +304,15 @@ def validate_output_file(output_filepath: Union[str, Path]) -> None:
not os.access(os.path.dirname(output_filepath), os.W_OK)]

if all(nowrite_conditions):
raise IOError(
"SoX cannot write to output_filepath {}".format(output_filepath)
raise OSError(
f"SoX cannot write to output_filepath {output_filepath}"
)

ext = file_extension(output_filepath)
if ext not in VALID_FORMATS:
logger.info("Valid formats: %s", " ".join(VALID_FORMATS))
logger.warning(
"This install of SoX cannot process .{} files.".format(ext)
f"This install of SoX cannot process .{ext} files."
)

if os.path.exists(output_filepath):
Expand Down
Loading

0 comments on commit 5e93526

Please sign in to comment.