Skip to content

Commit

Permalink
Create setup.py file. Prepare for release of Debian package.
Browse files Browse the repository at this point in the history
  • Loading branch information
quasoft committed Feb 5, 2017
1 parent ee11f10 commit a1fa8a6
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 44 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@ ENV/

# Folder with experimental tests
exp/*

deb_dist/

adblockradio*.tar.gz
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Unreleased]
## [Release 0.3.0] - 2017-02-05
### Added

- Released package for Ubuntu 16.04 64-bit
- Introduced Makefile for developers

### Changed
- Changed project structure to make release of OS packages easier
- Fix: Do not add an empty item in blacklist and favourites files, if last line already ends with a newline


## [Release 0.2] - 2017-01-24
### Added
- Allow user to record currently playing song
Expand All @@ -25,4 +26,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
- Fix: Do not terminate application when a dialog window is closed
- Fix: Mark as advertisement (Blacklist) menu was not actually saving the pattern anywhere

[Release 0.1]: https://github.com/quasoft/adblockradio/tree/0.1
[Release 0.1]: https://github.com/quasoft/adblockradio/tree/0.1
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include CHANGELOG.md
include LICENSE
include Makefile
include README.txt
include requirements.txt
recursive-include adblockradio/ui/svg *.svg
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
PYTHON = /usr/bin/python3
NAME = `/usr/bin/python3 setup.py --name`
USERNAME := $(shell whoami)

init:
$(PYTHON) -m pip install -r requirements.txt
sudo apt-get install pyqt4-dev-tools qt4-designer
sudo apt-get install python3-stdeb fakeroot python3-all

dist: source deb

source:
$(PYTHON) setup.py sdist

deb:
$(PYTHON) setup.py --command-packages=stdeb.command bdist_deb

debsrc:
$(PYTHON) setup.py --command-packages=stdeb.command sdist_dsc

rpm:
$(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall

check:
# pyflakes adblockradio/*.py
# find adblockradio/ -name \*.py | grep -v "^test_" | xargs pylint --errors-only --reports=n | grep -v "PyQt4"
# pep8
# pyntch
# pychecker
# pymetrics

clean:
$(PYTHON) setup.py clean
rm -rf build/ MANIFEST dist build adblockradio.egg-info deb_dist
find . -name '*.pyc' -delete

develop : adblockradio.py
sudo apt-get install python3-pip python3-pyqt4 gstreamer1.0-plugins-base gstreamer1.0-plugins-good python3-gst-1.0
$(PYTHON) -m pip install appdirs plac requests
sed -i -e "s|/home/user/|/home/$(USERNAME)/|g" share/adblockradio.desktop
sudo cp share/adblockradio.desktop /usr/share/applications

# Compile Qt designs to python classes
ui/ui_text_item_editor.py : ui/ui_text_item_editor.ui
pyuic4 ui/ui_text_item_editor.ui -o ui/ui_text_item_editor.py

.PHONY: init dist source deb rpm check clean develop
75 changes: 42 additions & 33 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Requirements:
- PyQt4
- Python packages: appdirs, plac, requests

How it works
------------

Coming soon...

Download:
---------

Expand All @@ -31,70 +36,66 @@ Binary packages for the following OSes are provided:
If you want to run the player on another OS, you might need to install
it manually - see below.

How to install manually:
------------------------
How to customize:
-----------------

Ubuntu 16.04:
~~~~~~~~~~~~~
#. Edit list of radio stations in ``config.py``

Tested to work under Ubuntu 16.04. Might work on other debian based
distros too:
#. Add blacklist patterns for advertisements in
``~/.local/share/adblockradio/blacklist.txt``

#. Download project:
#. Start player with GUI in system tray:

::

cd ~/
git clone https://github.com/quasoft/adblockradio.git
cd adblockradio
python3 adblockradio/adblockradio.py

#. Install dependencies and desktop file
or, to start with a specific radio station:

::

make manual_install
python3 adblockradio/adblockradio.py --station URL_TO_RADIO_STREAM

#. Edit list of radio stations in config.py

#. Add blacklist patterns for advertisements in
``~/.local/share/adblockradio/blacklist.txt``
How to contribute:
------------------

#. Start player with GUI in system tray:

::
Ubuntu 16.04:
~~~~~~~~~~~~~

/usr/bin/python3 adblockradio/adblockradio.py
Development has been done under Ubuntu 16.04 64 bit:

or, to start with a specific radio station:
#. Download project:

::

/usr/bin/python3 adblockradio/adblockradio.py --station URL_TO_RADIO_STREAM

*You can add more radio stations to config.py file*
cd ~/
git clone https://github.com/quasoft/adblockradio.git
cd adblockradio

#. Start player as console application:
#. Install dependencies and desktop file

::

bin/adblockradio.sh start
make develop

#. Start player as daemon:
#. Start player with GUI in system tray:

::

bin/adblockradio.sh start &
python3 adblockradio/adblockradio.py


To stop daemon:
or in console mode (eg. for debugging purposes):

::

bin/adblockradio.sh stop
python3 adblockradio/adblockradio.py --console

Windows 10 64 bit:
~~~~~~~~~~~~~~~~~~
If you have Anaconda Python installed, use full path to Python binary (replace ``python3`` with ``/usr/bin/python3``)

*You can add more radio stations to config.py file*

- Coming soon....

How to build installer/OS package:
----------------------------------
Expand All @@ -104,8 +105,16 @@ For Ubuntu/Debian:

::

apt-get install python3-stdeb fakeroot python3-all
make init
make deb
sudo gdebi deb_dist/python3-adblockradio_0.3-1_all.deb

For Windows 10 64 bit:
~~~~~~~~~~~~~~~~~~~~~~

::

Coming soon...

Credits
-------
Expand Down
7 changes: 7 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
AdBlockRadio - Internet radio player that blocks advertisements.

Detects advertisements by inspecting song titles inside stream metadata
and switches automatically to another radio station, when an ad is
detected.

Requirements: Python 3.4, GStreamer 1.X with python bindings, PyQt4, appdirs, plac, requests.
Empty file removed adblockradio/.keep
Empty file.
2 changes: 1 addition & 1 deletion adblockradio/player_tee.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gi.require_version('Gst', '1.0')
gi.require_version('GstBase', '1.0')
gi.require_version('Gtk', '3.0')
from gi.repository import GObject, Gst
from gi.repository import Gst

from recorder import Recorder
import config
Expand Down
4 changes: 3 additions & 1 deletion TODO.md → docs/TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## Must have
* [ ] Menu to open folder with recordings
* [ ] GUI editor for management of radio stations
* [ ] Make QT4 dependency optional, as player should run without GUI, if started with `--console` option
* [ ] Create tests
* [ ] Create Ubuntu install package (`.deb`)
* [X] Create Ubuntu install package (`.deb`)

## Nice to have
* [ ] Add `--record-training-data` option for automatic recording of both songs and advertisements. This would allow machine learning to be used for automatic detection of ads at a later stage
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
appdirs==1.4.0
plac==0.9.6
requests==2.9.1
stdeb==0.8.5
58 changes: 58 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
import os
from setuptools import setup, find_packages


def read_long_description():
with open('README.txt') as f:
return f.read()


osname = os.uname()[0]
if any([name for name in ['Darwin', 'Linux'] if osname in name]):
data_files = [
('/usr/share/applications', ['share/adblockradio.desktop']),
('/usr/share/adblockradio', ['share/icon.svg'])
]
else:
data_files = []


setup(
name='adblockradio',
version='0.3',
author='QuaSoft',
author_email='[email protected]',
description='Internet radio player for Ubuntu that blocks advertisements',
long_description=read_long_description(),
license='GPLv3',
keywords='music internet radio player block advertisements',
url='https://github.com/quasoft/adblockradio',
packages=find_packages(),
package_data={
'adblockradio': [
'adblockradio/ui/svg/*.svg'
]
},
include_package_data=True,
data_files=data_files,
entry_points={
'console_scripts': [
'adblockradio=adblockradio.adblockradio:main'
]
},
download_url='https://github.com/quasoft/adblockradio/archive/0.3.tar.gz',
install_requires=['appdirs', 'requests'],
extras_require={
'console': ['plac']
},
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Intended Audience :: End Users/Desktop',
'Topic :: Multimedia :: Audio',
'Topic :: Utilities'
]
)
9 changes: 4 additions & 5 deletions share/adblockradio.desktop
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[Desktop Entry]
Version=1.0
Version=0.3
Name=Ad Block Radio
Comment=Internet radio player that blocks advertisements.
Exec=/usr/bin/python3 adblockradio.py
Path=/home/user/adblockradio/
Icon=/home/user/adblockradio/ui/svg/icon.svg
Exec=adblockradio
Icon=/usr/share/adblockradio/icon.svg
Terminal=false
Type=Application
Categories=Application;
Categories=Application;AudioVideo;Audio;Music;
5 changes: 5 additions & 0 deletions stdeb.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[DEFAULT]
Depends3: python3-pyqt4, gstreamer1.0-plugins-base, gstreamer1.0-plugins-good, gstreamer1.0-plugins-bad, gstreamer1.0-plugins-ugly, python3-gst-1.0
XS-Python-Version: >= 3.4
Suite: xenial
Section: sound

0 comments on commit a1fa8a6

Please sign in to comment.