Skip to content

Commit

Permalink
Add project infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jun 20, 2021
1 parent e398aca commit 9b18391
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 42 deletions.
11 changes: 11 additions & 0 deletions .bumpversion.cfg
@@ -0,0 +1,11 @@
[bumpversion]
current_version = 0.0.0
files = setup.py saraswati/__init__.py
search = version='{current_version}'
__version__ = '{current_version}'
version = u'{current_version}'
release = u'{current_version}'
commit = True
tag = True
tag_name = {new_version}
allow_dirty = True
4 changes: 4 additions & 0 deletions .gitignore
@@ -1,2 +1,6 @@
/.idea
/.venv*
*.pyc
__pycache__
*.egg-info
/var
42 changes: 0 additions & 42 deletions LICENSE
Expand Up @@ -617,45 +617,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
90 changes: 90 additions & 0 deletions Makefile
@@ -0,0 +1,90 @@
# ============
# Main targets
# ============


# -------------
# Configuration
# -------------

$(eval venvpath := .venv)
$(eval pip := $(venvpath)/bin/pip)
$(eval python := $(venvpath)/bin/python)
$(eval pytest := $(venvpath)/bin/pytest)
$(eval bumpversion := $(venvpath)/bin/bumpversion)
$(eval twine := $(venvpath)/bin/twine)
$(eval sphinx := $(venvpath)/bin/sphinx-build)

# Setup Python virtualenv
setup-virtualenv:
@test -e $(python) || python3 -m venv --system-site-packages $(venvpath)


# -------
# Testing
# -------

# Run the main test suite
test:
@test -e $(pytest) || $(MAKE) install-tests
@$(pytest) tests -m 'not slow'

test-refresh: install-tests test

test-junit: install-tests
@$(pytest) tests --junit-xml .pytest_results/pytest.xml

test-coverage: install-tests
@$(pytest) tests \
--junit-xml .pytest_results/pytest.xml \
--cov saraswati --cov-branch \
--cov-report term-missing \
--cov-report html:.pytest_results/htmlcov \
--cov-report xml:.pytest_results/coverage.xml

# -------
# Release
# -------

# Release this piece of software
# Synopsis:
# make release bump=minor (major,minor,patch)
release: bumpversion push sdist pypi-upload


# -------------
# Documentation
# -------------

# Build the documentation
docs-html: install-doctools
touch doc/index.rst
export SPHINXBUILD="`pwd`/$(sphinx)"; cd doc; make html


# ===============
# Utility targets
# ===============
bumpversion: install-releasetools
@$(bumpversion) $(bump)

push:
git push && git push --tags

sdist:
@$(python) setup.py sdist

pypi-upload: install-releasetools
@$(twine) upload --skip-existing dist/*.tar.gz

install-doctools: setup-virtualenv
@$(pip) install --quiet --requirement requirements-docs.txt --upgrade

install-releasetools: setup-virtualenv
@$(pip) install --quiet --requirement requirements-release.txt --upgrade

install-tests: setup-virtualenv
@$(pip) install --quiet --editable .[test] --upgrade
@$(python) setup.py --quiet develop
@touch $(venvpath)/bin/activate
@mkdir -p .pytest_results
3 changes: 3 additions & 0 deletions requirements-release.txt
@@ -0,0 +1,3 @@
bump2version==1.0.0
twine==3.4.1
keyring==23.0.1
78 changes: 78 additions & 0 deletions setup.py
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
# (c) 2018-2021 The Hiveeyes Developers
import os

from setuptools import setup, find_packages

here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()

setup(name='saraswati',
version='0.0.0',
description='Saraswati - a robust, multi-channel audio recording, transmission and storage system',
long_description=README,
license="AGPL 3, EUPL 1.2",
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Environment :: Plugins",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Information Technology",
"Intended Audience :: Manufacturing",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"Intended Audience :: Telecommunications Industry",
"License :: OSI Approved :: GNU Affero General Public License v3",
"License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
"Environment :: Console",
"Environment :: Web Environment",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Communications",
"Topic :: Education",
"Topic :: Internet",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator",
"Topic :: Software Development :: Embedded Systems",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Pre-processors",
"Topic :: Software Development :: Testing",
"Topic :: System :: Archiving",
"Topic :: System :: Distributed Computing",
"Topic :: System :: Monitoring",
"Topic :: System :: Networking :: Monitoring",
"Topic :: System :: Systems Administration",
"Topic :: Text Processing",
"Topic :: Utilities",
],
author='Andreas Motl',
author_email='andreas@hiveeyes.org',
url='https://github.com/hiveeyes/saraswati',
keywords='audio multi-channel recording transmission storage robust',
packages=find_packages(),
include_package_data=True,
package_data={
},
zip_safe=False,
test_suite='tests',
install_requires=[],
extras_require={
"test": [
'pytest>=4.6.7',
'pytest-cov>=2.8.1',
]
},
tests_require=[],
entry_points={
'console_scripts': [
'saraswati = saraswati.commands:run',
],
},
)
20 changes: 20 additions & 0 deletions tests/test_recorder.py
@@ -0,0 +1,20 @@
import logging

from gi.overrides import Gst

from tests.util import load_module_from_file


def test_spike():

spike = load_module_from_file("python/examples/flac-timestamp-chunked.py")

# Setup logging
spike.setup_logging(level=logging.DEBUG)

# Setup PyGObject and GStreamer
Gst.init(None)

# Run a basic pipeline test
pipe = spike.BasicPipeline()
pipe.setup()
26 changes: 26 additions & 0 deletions tests/util.py
@@ -0,0 +1,26 @@
import imp

try:
import hashlib
md = hashlib.md5
except ImportError:
import md5
md = md5.new


def load_module_from_file(path):
"""
http://code.davidjanes.com/blog/2008/11/27/how-to-dynamically-load-python-code/
:param path:
:return:
"""
try:
fp = open(path, 'rb')
digest = md(path.encode('utf-8')).hexdigest()
return imp.load_source(digest, path, fp)
finally:
try:
fp.close()
except:
pass

0 comments on commit 9b18391

Please sign in to comment.