Skip to content

Commit

Permalink
Switch project to Poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch00k committed Jul 30, 2024
1 parent 42247d7 commit 51112ae
Show file tree
Hide file tree
Showing 10 changed files with 525 additions and 80 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ jobs:
with:
python-version: "3.12"
architecture: x64
- run: pip install -U -r dev-requirements.txt
- run: flake8 .
- run: black --check --diff .
- run: isort --check --diff .
- run: |
pip install poetry
poetry install --with dev
- run: poetry run flake8 .
- run: poetry run black --check --diff .
- run: poetry run isort --check --diff .

test:
# https://github.com/actions/setup-python/issues/544
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
Expand All @@ -44,9 +43,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: pip install -U -r test-requirements.txt
- run: PATH=./tests/ffmpeg:$PATH PYTHONPATH=. py.test tests --cov=ffmpy --cov-report xml

- run: |
pip install poetry
poetry install --with dev
- run: cp ${{ env.github_workspace }}/tests/ffmpeg/ffmpeg /usr/local/bin/ffmpeg
- run: poetry run pytest --cov=ffmpy --cov-report xml
- uses: codecov/codecov-action@v4
if: matrix.python-version == 3.12
with:
Expand Down
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
*.pyc
*.egg-info
.tox
.eggs
.cache
dist
build

# Sphinx
docs/_build
3 changes: 0 additions & 3 deletions dev-requirements.txt

This file was deleted.

15 changes: 3 additions & 12 deletions ffmpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class FFmpeg(object):
ffprobe).
"""

def __init__(
self, executable="ffmpeg", global_options=None, inputs=None, outputs=None
):
def __init__(self, executable="ffmpeg", global_options=None, inputs=None, outputs=None):
"""Initialize FFmpeg command line wrapper.
Compiles FFmpeg command line from passed arguments (executable path, options, inputs and
Expand Down Expand Up @@ -93,18 +91,11 @@ def run(self, input_data=None, stdout=None, stderr=None, env=None, **kwargs):
"""
try:
self.process = subprocess.Popen(
self._cmd,
stdin=subprocess.PIPE,
stdout=stdout,
stderr=stderr,
env=env,
**kwargs
self._cmd, stdin=subprocess.PIPE, stdout=stdout, stderr=stderr, env=env, **kwargs
)
except OSError as e:
if e.errno == errno.ENOENT:
raise FFExecutableNotFoundError(
"Executable '{0}' not found".format(self.executable)
)
raise FFExecutableNotFoundError("Executable '{0}' not found".format(self.executable))
else:
raise

Expand Down
422 changes: 422 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[tool.poetry]
name = "ffmpy"
version = "0.3.3"
description = "A simple Python wrapper for FFmpeg"
authors = ["Andrii Yurchuk <ay@mntw.re>"]
license = "MIT"
readme = "README.rst"
homepage = "https://github.com/Ch00k/ffmpy"
repository = "https://github.com/Ch00k/ffmpy"
documentation = "https://ffmpy.readthedocs.io"
keywords = [
"ffmpeg",
"ffprobe",
"ffplay",
"ffserver",
"wrapper",
"media",
"audio",
"video",
"transcoding",
]
classifiers = [
"Topic :: Multimedia :: Sound/Audio",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: POSIX :: BSD",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
]
packages = [{ include = "ffmpy.py" }]

[tool.poetry.dependencies]
python = "^3.8.1" # flake8 requires Python 3.8.1 or higher

[tool.poetry.group.dev.dependencies]
black = "^24.4.2"
isort = "^5.13.2"
mypy = "^1.11.0"
flake8 = "^7.1.0"
flake8-pyproject = "^1.2.3"
pytest = "^8.3.2"
pytest-cov = "^5.0.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 101

[tool.flake8]
max-line-length = 101

[tool.isort]
profile = "black"
line_length = 101
include_trailing_comma = true

[tool.mypy]
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
warn_unreachable = true
show_column_numbers = true
3 changes: 0 additions & 3 deletions setup.cfg

This file was deleted.

38 changes: 0 additions & 38 deletions setup.py

This file was deleted.

2 changes: 0 additions & 2 deletions test-requirements.txt

This file was deleted.

14 changes: 9 additions & 5 deletions tests/test_cmd_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ def test_non_zero_exitcode_no_stdout_and_stderr():
with pytest.raises(FFRuntimeError) as exc_info:
ff.run(stdout=subprocess.PIPE, stderr=subprocess.PIPE)

assert exc_info.value.cmd == (
"ffmpeg --stdin none --stdout none --stderr none --exit-code 42"
)
assert exc_info.value.cmd == ("ffmpeg --stdin none --stdout none --stderr none --exit-code 42")
assert exc_info.value.exit_code == 42
assert exc_info.value.stdout == b""
assert exc_info.value.stderr == b""
Expand Down Expand Up @@ -167,8 +165,14 @@ def test_terminate_process():
thread_1 = threading.Thread(target=ff.run)
thread_1.start()

while not ff.process:
time.sleep(0.05)
timeout = time.time() + 3
while time.time() < timeout:
if ff.process is None:
time.sleep(0.05)
else:
break
else:
raise AssertionError("FFmpeg process was not started within 3 seconds")

print(ff.process.returncode)

Expand Down

0 comments on commit 51112ae

Please sign in to comment.