From 1c788a73c61c8074f4ab0b42f9ec6eb0487fe450 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 5 Jul 2016 21:43:51 +0300 Subject: [PATCH] setup.py and fixes --- .gitignore | 6 +++++ MANIFEST.in | 17 +++++++++++++ docs/install.md | 16 ++++++++++++ setup.py | 43 +++++++++++++++++++++++++++++++++ src/avwidgets.py | 4 +-- src/callbacks.py | 2 +- src/list_items.py | 12 ++++----- src/main.py | 38 +++++++++++++++++++---------- src/mainscreen.py | 2 +- src/mainscreen_widgets.py | 2 +- src/menu.py | 2 +- src/plugin_support.py | 4 +-- src/{profile.py => profile_.py} | 0 tests/tests.py | 2 +- 14 files changed, 122 insertions(+), 28 deletions(-) create mode 100644 MANIFEST.in create mode 100644 setup.py rename src/{profile.py => profile_.py} (100%) diff --git a/.gitignore b/.gitignore index c35c50a..0f73c60 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,9 @@ src/libs src/build src/dist *.spec +dist/ +/src/avatars +src/__pycache__ +/*.egg-info +/*.egg + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a3fe708 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,17 @@ +include src/images/*.png +include src/images/*.ico +include src/images/*.gif +include src/sounds/*.wav +include src/stickers/tox/*.png +include src/smileys/default/*.png +include src/smileys/default/config.json +include src/smileys/animated/*.gif +include src/smileys/animated/config.json +include src/smileys/starwars/*.gif +include src/smileys/starwars/*.png +include src/smileys/starwars/config.json +include src/styles/style.qss +include src/translations/*.qm +include src/libs/libtox.dll +include src/libs/libsodium.a + diff --git a/docs/install.md b/docs/install.md index 5c1c31d..0a8aa2a 100644 --- a/docs/install.md +++ b/docs/install.md @@ -3,6 +3,22 @@ ## Use precompiled binary: [Check our releases page](https://github.com/xveduk/toxygen/releases) +##Using pip3 + +### Windows (32-bit interpreter) + +``pip3.4 install toxygen`` +Run app using ``toxygen`` command. + +##Linux + +1. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system (install in /usr/lib/) +2. Install PortAudio: +``sudo apt-get install portaudio19-dev`` +3. Install toxygen: +``sudo pip3.4 install toxygen`` +4 Run toxygen using ``toxygen`` command. + ## From source code (recommended for developers) ### Windows diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4215a98 --- /dev/null +++ b/setup.py @@ -0,0 +1,43 @@ +from setuptools import setup +from setuptools.command.install import install +from platform import system +from ctypes import CDLL + + +class DownloadScript(install): + """Install all required libs""" + def run(self): + OS = system() + if OS == 'Linux': # install libtoxcore + try: + libtoxcore = CDLL('libtoxcore.so') + libtoxencryptsave = CDLL('libtoxencryptsave.so') + libtoxav = CDLL('libtoxav.so') + except: # toxcore is not installed + pass + install.run(self) + +setup(name='Toxygen', + version='0.2.1.50', + description='Toxygen - Tox client', + long_description='Toxygen is powerful Tox client written in Python3', + url='https://github.com/xveduk/toxygen/', + keywords='toxygen tox', + author='Ingvar', + license='GPL3', + package_dir={'': 'src'}, + packages=['', 'plugins', 'styles'], + install_requires=['PyAudio', 'PySide', 'PySocks'], + include_package_data=True, + classifiers=[ + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + ], + entry_points={ + 'console_scripts': ['toxygen=main:main'], + }, + cmdclass={ + 'install': DownloadScript, + }, + ) diff --git a/src/avwidgets.py b/src/avwidgets.py index 511fd8c..2b1e696 100644 --- a/src/avwidgets.py +++ b/src/avwidgets.py @@ -3,7 +3,7 @@ try: except ImportError: from PyQt4 import QtCore, QtGui import widgets -import profile +import profile_ import util import pyaudio import wave @@ -54,7 +54,7 @@ class IncomingCallWidget(widgets.CenteredWidget): self.setWindowTitle(text) self.name.setText(name) self.call_type.setText(text) - pr = profile.Profile.get_instance() + pr = profile_.Profile.get_instance() self.accept_audio.clicked.connect(lambda: pr.accept_call(friend_number, True, False) or self.stop()) # self.accept_video.clicked.connect(lambda: pr.start_call(friend_number, True, True)) self.decline.clicked.connect(lambda: pr.stop_call(friend_number, False) or self.stop()) diff --git a/src/callbacks.py b/src/callbacks.py index fc13b99..e1fcb88 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -4,7 +4,7 @@ except ImportError: from PyQt4 import QtCore from notifications import * from settings import Settings -from profile import Profile +from profile_ import Profile from toxcore_enums_and_consts import * from toxav_enums import * from tox import bin_to_string diff --git a/src/list_items.py b/src/list_items.py index 78e12c3..3cf761c 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -3,7 +3,7 @@ try: from PySide import QtCore, QtGui except ImportError: from PyQt4 import QtCore, QtGui -import profile +import profile_ from file_transfers import TOX_FILE_TRANSFER_STATE, PAUSED_FILE_TRANSFERS, DO_NOT_SHOW_ACCEPT_BUTTON, ACTIVE_FILE_TRANSFERS, SHOW_PROGRESS_BAR from util import curr_directory, convert_time, curr_time from widgets import DataLabel, create_menu @@ -339,7 +339,7 @@ class FileTransferItem(QtGui.QListWidget): self.paused = False def cancel_transfer(self, friend_number, file_number): - pr = profile.Profile.get_instance() + pr = profile_.Profile.get_instance() pr.cancel_transfer(friend_number, file_number) self.setStyleSheet('QListWidget { border: 1px solid #B40404; }') self.cancel.setVisible(False) @@ -354,18 +354,18 @@ class FileTransferItem(QtGui.QListWidget): QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog) self.pb.setVisible(True) if directory: - pr = profile.Profile.get_instance() + pr = profile_.Profile.get_instance() pr.accept_transfer(self, directory + '/' + self.saved_name, friend_number, file_number, size) self.button_update('pause') elif self.state == TOX_FILE_TRANSFER_STATE['PAUSED_BY_USER']: # resume self.paused = False - profile.Profile.get_instance().resume_transfer(friend_number, file_number) + profile_.Profile.get_instance().resume_transfer(friend_number, file_number) self.button_update('pause') self.state = TOX_FILE_TRANSFER_STATE['RUNNING'] else: # pause self.paused = True self.state = TOX_FILE_TRANSFER_STATE['PAUSED_BY_USER'] - profile.Profile.get_instance().pause_transfer(friend_number, file_number) + profile_.Profile.get_instance().pause_transfer(friend_number, file_number) self.button_update('resume') self.accept_or_pause.clearFocus() @@ -435,7 +435,7 @@ class UnsentFileItem(FileTransferItem): movie.start() def cancel_transfer(self, *args): - pr = profile.Profile.get_instance() + pr = profile_.Profile.get_instance() pr.cancel_not_started_transfer(self._time) diff --git a/src/main.py b/src/main.py index 59fd38d..c069436 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,6 @@ import sys from loginscreen import LoginScreen +import profile_ from settings import * try: from PySide import QtCore, QtGui @@ -7,13 +8,11 @@ except ImportError: from PyQt4 import QtCore, QtGui from bootstrap import node_generator from mainscreen import MainWindow -from profile import tox_factory from callbacks import init_callbacks -from util import curr_directory +from util import curr_directory, program_version import styles.style import toxencryptsave from passwordscreen import PasswordScreen, UnlockAppScreen -import profile from plugin_support import PluginLoader @@ -67,7 +66,7 @@ class Toxygen: if encrypt_save.is_data_encrypted(data): data = self.enter_pass(data) settings = Settings(name) - self.tox = tox_factory(data, settings) + self.tox = profile_.tox_factory(data, settings) else: auto_profile = Settings.get_auto_profile() if not auto_profile[0]: @@ -95,7 +94,7 @@ class Toxygen: elif _login.t == 1: # create new profile _login.name = _login.name.strip() name = _login.name if _login.name else 'toxygen_user' - self.tox = tox_factory() + self.tox = profile_.tox_factory() self.tox.self_set_name(bytes(_login.name, 'utf-8') if _login.name else b'Toxygen User') self.tox.self_set_status_message(b'Toxing on Toxygen') ProfileHelper(Settings.get_default_path(), name).save_profile(self.tox.get_savedata()) @@ -112,14 +111,14 @@ class Toxygen: if encrypt_save.is_data_encrypted(data): data = self.enter_pass(data) settings = Settings(name) - self.tox = tox_factory(data, settings) + self.tox = profile_.tox_factory(data, settings) else: path, name = auto_profile data = ProfileHelper(path, name).open_profile() if encrypt_save.is_data_encrypted(data): data = self.enter_pass(data) settings = Settings(name) - self.tox = tox_factory(data, settings) + self.tox = profile_.tox_factory(data, settings) if Settings.is_active_profile(path, name): # profile is in use reply = QtGui.QMessageBox.question(None, @@ -147,12 +146,12 @@ class Toxygen: class Menu(QtGui.QMenu): def newStatus(self, status): - profile.Profile.get_instance().set_status(status) + profile_.Profile.get_instance().set_status(status) self.aboutToShow() self.hide() def aboutToShow(self): - status = profile.Profile.get_instance().status + status = profile_.Profile.get_instance().status act = self.act if status is None or Settings.get_instance().locked: self.actions()[1].setVisible(False) @@ -256,7 +255,7 @@ class Toxygen: ProfileHelper.get_instance().save_profile(data) del self.tox # create new tox instance - self.tox = tox_factory(data, Settings.get_instance()) + self.tox = profile_.tox_factory(data, Settings.get_instance()) # init thread self.init = self.InitThread(self.tox, self.ms, self.tray) self.init.start() @@ -355,9 +354,22 @@ class Toxygen: return self.arr[self.num] -if __name__ == '__main__': +def main(): if len(sys.argv) == 1: toxygen = Toxygen() - else: # path to profile or tox: uri - toxygen = Toxygen(sys.argv[1]) + else: # path to profile or tox: uri or --version or --help + arg = sys.argv[1] + if arg == '--version': + print('Toxygen ' + program_version) + return + elif arg == '--help': + print('Usage:\ntoxygen path_to_profile\ntoxygen tox_id\ntoxygen --version') + return + else: + toxygen = Toxygen(arg) toxygen.main() + + +if __name__ == '__main__': + main() + diff --git a/src/mainscreen.py b/src/mainscreen.py index a4acd31..e7d8246 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from menu import * -from profile import * +from profile_ import * from list_items import * from widgets import MultilineEdit, LineEdit import plugin_support diff --git a/src/mainscreen_widgets.py b/src/mainscreen_widgets.py index f12f521..9229bb5 100644 --- a/src/mainscreen_widgets.py +++ b/src/mainscreen_widgets.py @@ -3,7 +3,7 @@ try: except ImportError: from PyQt4 import QtCore, QtGui from widgets import RubberBand, create_menu, QRightClickButton, CenteredWidget -from profile import Profile +from profile_ import Profile import smileys import util diff --git a/src/menu.py b/src/menu.py index efc11c5..8ffac66 100644 --- a/src/menu.py +++ b/src/menu.py @@ -3,7 +3,7 @@ try: except ImportError: from PyQt4 import QtCore, QtGui from settings import * -from profile import Profile +from profile_ import Profile from util import curr_directory from widgets import CenteredWidget, DataLabel, LineEdit import pyaudio diff --git a/src/plugin_support.py b/src/plugin_support.py index a865038..f3602c4 100644 --- a/src/plugin_support.py +++ b/src/plugin_support.py @@ -1,5 +1,5 @@ import util -import profile +import profile_ import os import importlib import inspect @@ -12,7 +12,7 @@ class PluginLoader(util.Singleton): def __init__(self, tox, settings): super().__init__() - self._profile = profile.Profile.get_instance() + self._profile = profile_.Profile.get_instance() self._settings = settings self._plugins = {} # dict. key - plugin unique short name, value - tuple (plugin instance, is active) self._tox = tox diff --git a/src/profile.py b/src/profile_.py similarity index 100% rename from src/profile.py rename to src/profile_.py diff --git a/tests/tests.py b/tests/tests.py index 46be179..3daa89b 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,5 +1,5 @@ from src.bootstrap import node_generator -from src.profile import * +from src.profile_ import * from src.settings import ProfileHelper from src.tox_dns import tox_dns import src.toxencryptsave as encr