-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop3.6 & move all configuration into pyproject.toml (#49)
* move all configuration into pyproject.toml * tox configuration simplified and consolidated to pyproject.toml * default configuration for common tools (black, pytype, coverage) * add entry point for sigmf_convert_wav * slightly improve sigmf_convert_wav * increment to v1.2.0 * move tools/ to apps/ * move gui.py to apps/ * drop support for python 3.6 * add support for python 3.12 * distribution previously made with setup.py can be created w/python3 -m build * upgrade logo to SVG version * pin PySimpleGUI version
- Loading branch information
Showing
14 changed files
with
214 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
[project] | ||
name = "SigMF" | ||
description = "Easily interact with Signal Metadata Format (SigMF) recordings." | ||
keywords = ["gnuradio"] | ||
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.7", | ||
"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", | ||
] | ||
dynamic = ["version", "readme"] | ||
requires-python = ">=3.7" | ||
dependencies = [ | ||
"numpy", # for vector math | ||
"jsonschema", # for spec validation | ||
] | ||
[project.urls] | ||
repository = "https://github.com/sigmf/sigmf-python" | ||
[project.scripts] | ||
sigmf_validate = "sigmf.validate:main" | ||
sigmf_gui = "sigmf.apps.gui:main [apps]" | ||
sigmf_convert_wav = "sigmf.apps.convert_wav:main [apps]" | ||
[project.optional-dependencies] | ||
test = [ | ||
"pylint", | ||
"pytest", | ||
"pytest-cov", | ||
"hypothesis", # next-gen testing framework | ||
] | ||
apps = [ | ||
"scipy", # for wav i/o | ||
# FIXME: PySimpleGUI 2024-02-12 v5.0.0 release seems to have a bug. Unpin version when possible. | ||
"PySimpleGUI < 5.0.0", # for gui interface | ||
] | ||
|
||
[tool.setuptools] | ||
packages = ["sigmf"] | ||
[tool.setuptools.dynamic] | ||
version = {attr = "sigmf.__version__"} | ||
readme = {file = ["README.md"], content-type = "text/markdown"} | ||
[tool.setuptools.package-data] | ||
sigmf = ["*.json"] | ||
|
||
[build-system] | ||
requires = ["setuptools>=65.0", "setuptools-scm"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.coverage.run] | ||
branch = true | ||
source = ["sigmf", "tests"] | ||
# -rA captures stdout from all tests and places it after the pytest summary | ||
command_line = "-m pytest -rA --doctest-modules --junitxml=pytest.xml" | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "--doctest-modules" | ||
|
||
[tool.pylint] | ||
[tool.pylint.main] | ||
load-plugins = [ | ||
"pylint.extensions.typing", | ||
"pylint.extensions.docparams", | ||
] | ||
exit-zero = true | ||
[tool.pylint.messages_control] | ||
disable = [ | ||
"logging-not-lazy", | ||
"missing-module-docstring", | ||
"import-error", | ||
"unspecified-encoding", | ||
] | ||
max-line-length = 120 | ||
[tool.pylint.REPORTS] | ||
# omit from the similarity reports | ||
ignore-comments = 'yes' | ||
ignore-docstrings = 'yes' | ||
ignore-imports = 'yes' | ||
ignore-signatures = 'yes' | ||
min-similarity-lines = 4 | ||
|
||
[tool.pytype] | ||
inputs = ['sigmf', 'tests'] | ||
|
||
[tool.black] | ||
line-length = 120 | ||
|
||
[tool.tox] | ||
legacy_tox_ini = ''' | ||
[tox] | ||
skip_missing_interpreters = True | ||
envlist = py{37,38,39,310,311,312} | ||
[testenv] | ||
usedevelop = True | ||
deps = .[test,apps] | ||
commands = coverage run | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright: Multiple Authors | ||
# | ||
# This file is part of SigMF. https://github.com/sigmf/sigmf-python | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
"""converter for wav containers""" | ||
|
||
import os | ||
import tempfile | ||
import datetime | ||
import pathlib | ||
import argparse | ||
import getpass | ||
|
||
from scipy.io import wavfile | ||
|
||
from .. import archive | ||
from ..sigmffile import SigMFFile | ||
from ..utils import get_data_type_str | ||
|
||
|
||
def convert_wav(input_wav_filename, archive_filename=None, start_datetime=None, author=None): | ||
""" | ||
read a .wav and write a .sigmf archive | ||
""" | ||
samp_rate, wav_data = wavfile.read(input_wav_filename) | ||
|
||
global_info = { | ||
SigMFFile.AUTHOR_KEY: getpass.getuser() if author is None else author, | ||
SigMFFile.DATATYPE_KEY: get_data_type_str(wav_data), | ||
SigMFFile.DESCRIPTION_KEY: f"Converted from {input_wav_filename}", | ||
SigMFFile.NUM_CHANNELS_KEY: 1 if len(wav_data.shape) < 2 else wav_data.shape[1], | ||
SigMFFile.RECORDER_KEY: os.path.basename(__file__), | ||
SigMFFile.SAMPLE_RATE_KEY: samp_rate, | ||
} | ||
|
||
if start_datetime is None: | ||
fname = pathlib.Path(input_wav_filename) | ||
mtime = datetime.datetime.fromtimestamp(fname.stat().st_mtime) | ||
start_datetime = mtime.isoformat() + "Z" | ||
|
||
capture_info = {SigMFFile.START_INDEX_KEY: 0} | ||
if start_datetime is not None: | ||
capture_info[SigMFFile.DATETIME_KEY] = start_datetime | ||
|
||
tmpdir = tempfile.mkdtemp() | ||
sigmf_data_filename = input_wav_filename + archive.SIGMF_DATASET_EXT | ||
sigmf_data_path = os.path.join(tmpdir, sigmf_data_filename) | ||
wav_data.tofile(sigmf_data_path) | ||
|
||
meta = SigMFFile(data_file=sigmf_data_path, global_info=global_info) | ||
meta.add_capture(0, metadata=capture_info) | ||
|
||
if archive_filename is None: | ||
archive_filename = os.path.basename(input_wav_filename) + archive.SIGMF_ARCHIVE_EXT | ||
meta.tofile(archive_filename, toarchive=True) | ||
return os.path.abspath(archive_filename) | ||
|
||
|
||
def main(): | ||
""" | ||
entry-point for sigmf_convert_wav | ||
""" | ||
parser = argparse.ArgumentParser(description="Convert .wav to .sigmf container.") | ||
parser.add_argument("input", type=str, help="Wavfile path") | ||
parser.add_argument("--author", type=str, default=None, help=f"set {SigMFFile.AUTHOR_KEY} metadata") | ||
args = parser.parse_args() | ||
|
||
out_fname = convert_wav( | ||
input_wav_filename=args.input, | ||
author=args.author, | ||
) | ||
print("Wrote", out_fname) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.