Skip to content

Commit dc6dd2f

Browse files
committed
chore: add pyproject.toml for project configuration
1 parent 215b765 commit dc6dd2f

File tree

5 files changed

+1806
-73
lines changed

5 files changed

+1806
-73
lines changed

pyproject.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "static_ffmpeg"
7+
version = "2.9"
8+
description = "Cross platform ffmpeg to work on various systems."
9+
readme = "README.md"
10+
authors = [
11+
{name = "Zach Vorhies", email = "[email protected]"}
12+
]
13+
license = {text = "MIT"}
14+
requires-python = ">=3.6.0"
15+
dependencies = [
16+
"requests",
17+
"filelock",
18+
"progress",
19+
"twine>=3.8.0",
20+
]
21+
classifiers = [
22+
"License :: OSI Approved :: MIT License",
23+
"Programming Language :: Python :: 3.6",
24+
"Programming Language :: Python :: 3.9",
25+
"Operating System :: Microsoft :: Windows",
26+
"Operating System :: POSIX",
27+
"Operating System :: MacOS :: MacOS X",
28+
"Environment :: Console",
29+
]
30+
31+
[project.optional-dependencies]
32+
test = ["pytest"]
33+
34+
[project.scripts]
35+
static_ffmpeg = "static_ffmpeg.run:main_static_ffmpeg"
36+
static_ffprobe = "static_ffmpeg.run:main_static_ffprobe"
37+
static_ffmpeg_paths = "static_ffmpeg.run:main_print_paths"
38+
39+
[tool.setuptools]
40+
packages = ["static_ffmpeg"]

setup.py

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
11
import os
22
import sys
33
from shutil import rmtree
4-
5-
from setuptools import Command, find_packages, setup
6-
7-
# The directory containing this file
8-
HERE = os.path.dirname(__file__)
9-
10-
NAME = "static_ffmpeg"
11-
DESCRIPTION = "Cross platform ffmpeg to work on various systems."
12-
URL = "https://github.com/zackees/static_ffmpeg"
13-
14-
AUTHOR = "Zach Vorhies"
15-
REQUIRES_PYTHON = ">=3.6.0"
16-
VERSION = "2.8"
17-
18-
# The text of the README file
19-
with open(os.path.join(HERE, "README.md")) as fd:
20-
LONG_DESCRIPTION = fd.read()
21-
22-
with open(os.path.join(HERE, "requirements.txt")) as fd:
23-
REQUIREMENTS = [line.strip() for line in fd.readlines() if line.strip()]
24-
4+
from setuptools import setup, Command
255

266
class UploadCommand(Command):
277
"""Support setup.py upload."""
28-
298
description = "Build and publish the package."
309
user_options = []
3110

@@ -42,7 +21,7 @@ def finalize_options(self):
4221
def run(self):
4322
try:
4423
self.status("Removing previous builds…")
45-
rmtree(os.path.join(HERE, "dist"))
24+
rmtree(os.path.join(os.path.dirname(__file__), "dist"))
4625
except OSError:
4726
pass
4827

@@ -53,48 +32,14 @@ def run(self):
5332
os.system("twine upload dist/*")
5433

5534
self.status("Pushing git tags…")
56-
os.system("git tag v{0}".format(VERSION))
35+
os.system("git tag v2.8")
5736
os.system("git push --tags")
5837

5938
sys.exit()
6039

61-
62-
setup(
63-
name=NAME,
64-
python_requires=REQUIRES_PYTHON,
65-
version=VERSION,
66-
description=DESCRIPTION,
67-
long_description=LONG_DESCRIPTION,
68-
long_description_content_type="text/markdown",
69-
url=URL,
70-
author="Zach Vorhies",
71-
author_email="[email protected]",
72-
license="MIT",
73-
classifiers=[
74-
"License :: OSI Approved :: MIT License",
75-
"Programming Language :: Python :: 3.6",
76-
"Programming Language :: Python :: 3.9",
77-
"Operating System :: Microsoft :: Windows",
78-
"Operating System :: POSIX",
79-
"Operating System :: MacOS :: MacOS X",
80-
"Environment :: Console",
81-
],
82-
install_requires=REQUIREMENTS,
83-
84-
entry_points={
85-
"console_scripts": [
86-
"static_ffmpeg = static_ffmpeg.run:main_static_ffmpeg",
87-
"static_ffprobe = static_ffmpeg.run:main_static_ffprobe",
88-
"static_ffmpeg_paths = static_ffmpeg.run:main_print_paths",
89-
],
90-
},
91-
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
92-
package_data={},
93-
include_package_data=True,
94-
extras_require={
95-
"test": ["pytest"],
96-
},
97-
cmdclass={
98-
"upload": UploadCommand,
99-
},
100-
)
40+
if __name__ == '__main__':
41+
setup(
42+
cmdclass={
43+
"upload": UploadCommand,
44+
},
45+
)

static_ffmpeg/run.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Entry point for running the ffmpeg executable.
2+
Entry point for running the ffmpeg executable.
33
"""
44

55
import os
@@ -12,6 +12,7 @@
1212

1313
import requests # type: ignore
1414
from filelock import FileLock, Timeout
15+
from progress.bar import Bar # type: ignore
1516
from progress.spinner import Spinner # type: ignore
1617

1718
TIMEOUT = 10 * 60 # Wait upto 10 minutes to validate install
@@ -50,17 +51,21 @@ def download_file(url, local_path):
5051
"""Downloads a file to the give path."""
5152
# NOTE the stream=True parameter below
5253
print(f"Downloading {url} -> {local_path}")
54+
chunk_size = (1024 * 1024) // 4
5355
with requests.get(url, stream=True, timeout=TIMEOUT) as req:
5456
req.raise_for_status()
57+
spinner: Spinner | Bar = Spinner("ffmpeg: ")
58+
size = -1
59+
try:
60+
size = int(req.headers.get("content-length", 0))
61+
spinner = Bar("ffmpeg: ", max=size, suffix="%(percent).1f%% - %(eta)ds")
62+
except ValueError:
63+
pass
5564
with open(local_path, "wb") as file_d:
56-
with Spinner() as spinner:
57-
for chunk in req.iter_content(chunk_size=8192 * 16):
58-
# If you have chunk encoded response uncomment if
59-
# and set chunk_size parameter to None.
60-
# if chunk:
61-
sys.stdout.write(".")
65+
with spinner as spinner:
66+
for chunk in req.iter_content(chunk_size):
6267
file_d.write(chunk)
63-
spinner.next()
68+
spinner.next(len(chunk))
6469
sys.stdout.write(f"\nDownload of {url} -> {local_path} completed.\n")
6570
return local_path
6671

tests/test_bug9.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests that https://github.com/zackees/static_ffmpeg/issues/9 is resolved. This bug did not allow spaces in the names.
2+
Tests that https://github.com/zackees/static_ffmpeg/issues/9 is resolved. This bug did not allow spaces in the names.
33
"""
44

55
import os

0 commit comments

Comments
 (0)