Skip to content

Commit

Permalink
fix readthedocs build
Browse files Browse the repository at this point in the history
  • Loading branch information
bakatrouble committed Feb 19, 2019
1 parent 4cefda2 commit d4cef5d
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 74 deletions.
8 changes: 5 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))
sys.path.insert(0, os.path.abspath('..'))

# Import after sys.path.insert() to avoid issues
from tgvoip import __version__
from setup import get_version

# -- Project information -----------------------------------------------------

Expand All @@ -26,9 +27,9 @@
author = 'bakatrouble'

# The short X.Y version
version = 'version' + __version__
version = 'version' + get_version()
# The full version, including alpha/beta/rc tags
release = __version__
release = get_version()


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -77,6 +78,7 @@
pygments_style = 'tango'

autodoc_member_order = 'bysource'
autodoc_mock_imports = ['_tgvoip']


# -- Options for HTML output -------------------------------------------------
Expand Down
43 changes: 39 additions & 4 deletions docs/module/tgvoip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,43 @@ Enums
Data structures
---------------

.. autoclass:: tgvoip.Stats
:members:

.. autoclass:: tgvoip.Endpoint
:members:
.. py:class:: tgvoip.Stats
Object storing call stats

.. attribute:: bytes_sent_wifi

Amount of data sent over WiFi
:type: ``int``

.. attribute:: bytes_sent_mobile

Amount of data sent over mobile network
:type: ``int``

.. attribute:: bytes_recvd_wifi

Amount of data received over WiFi
:type: ``int``

.. attribute:: bytes_recvd_mobile

Amount of data received over mobile network
:type: ``int``


.. py:class:: tgvoip.Endpoint
Object storing endpoint info

:param _id: Endpoint ID
:type _id: ``int``
:param ip: Endpoint IPv4 address
:type ip: ``str``
:param ipv6: Endpoint IPv6 address
:type ipv6: ``str``
:param port: Endpoint port
:type port: ``int``
:param peer_tag: Endpoint peer tag
:type peer_tag: ``bytes``
97 changes: 49 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def build_extension(self, ext):
subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)


def get_version():
def get_version(force_release=False):
with open('src/tgvoip/__init__.py', encoding='utf-8') as f:
version = re.findall(r"__version__ = '(.+)'", f.read())[0]
if os.environ.get('BUILD') is None:
if os.environ.get('BUILD') is None and not force_release:
version += '.develop'
return version

Expand All @@ -113,49 +113,50 @@ def get_data_files():
return data_files


setup(
name='pytgvoip',
version=get_version(),
license='LGPLv3+',
author='bakatrouble',
author_email='bakatrouble@gmail.com',
description='Telegram VoIP Library for Python',
long_description=get_long_description(),
long_description_content_type='text/markdown',
url='https://github.com/bakatrouble/pytgvoip',
keywords='telegram messenger voip library python',
project_urls={
'Tracker': 'https://github.com/bakatrouble/pytgvoip/issues',
'Community': 'https:/t.me/pytgvoip',
'Source': 'https://github.com/bakatrouble/pytgvoip',
},
python_required='~=3.4',
ext_modules=[CMakeExtension('_tgvoip')],
packages=['tgvoip'],
package_dir={'tgvoip': os.path.join('src', 'tgvoip')},
package_data={'': [os.path.join('src', '_tgvoip.pyi')]},
data_files=get_data_files(),
cmdclass={'build_ext': CMakeBuild},
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: C++',
'Topic :: Internet',
'Topic :: Communications',
'Topic :: Communications :: Internet Phone',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)
if __name__ == '__main__':
setup(
name='pytgvoip',
version=get_version(),
license='LGPLv3+',
author='bakatrouble',
author_email='bakatrouble@gmail.com',
description='Telegram VoIP Library for Python',
long_description=get_long_description(),
long_description_content_type='text/markdown',
url='https://github.com/bakatrouble/pytgvoip',
keywords='telegram messenger voip library python',
project_urls={
'Tracker': 'https://github.com/bakatrouble/pytgvoip/issues',
'Community': 'https:/t.me/pytgvoip',
'Source': 'https://github.com/bakatrouble/pytgvoip',
},
python_required='~=3.4',
ext_modules=[CMakeExtension('_tgvoip')],
packages=['tgvoip'],
package_dir={'tgvoip': os.path.join('src', 'tgvoip')},
package_data={'': [os.path.join('src', '_tgvoip.pyi')]},
data_files=get_data_files(),
cmdclass={'build_ext': CMakeBuild},
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: C++',
'Topic :: Internet',
'Topic :: Communications',
'Topic :: Communications :: Internet Phone',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)
21 changes: 2 additions & 19 deletions src/_tgvoip_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ PYBIND11_MODULE(_tgvoip, m) {
.value("PROXY", CallError::ERROR_PROXY)
.export_values();

py::class_<Stats>(m, "Stats", R"doc(
An object storing call stats
Attributes:
bytes_sent_wifi (``int``): Amount of data sent over WiFi
bytes_sent_mobile (``int``): Amount of data sent over mobile network
bytes_recvd_wifi (``int``): Amount of data received over WiFi
bytes_recvd_mobile (``int``): Amount of data received over mobile network
)doc")
py::class_<Stats>(m, "Stats")
.def_readonly("bytes_sent_wifi", &Stats::bytes_sent_wifi)
.def_readonly("bytes_sent_mobile", &Stats::bytes_sent_mobile)
.def_readonly("bytes_recvd_wifi", &Stats::bytes_recvd_wifi)
Expand All @@ -95,16 +87,7 @@ PYBIND11_MODULE(_tgvoip, m) {
return repr.str();
});

py::class_<Endpoint>(m, "Endpoint", R"doc(
An object storing endpoint info
Args:
_id (``int``): Endpoint ID
ip (``str``): Endpoint IPv4 address
ipv6 (``str``): Endpoint IPv6 address
port (``int``): Endpoint port
peer_tag (``bytes``): Endpoint peer tag
)doc")
py::class_<Endpoint>(m, "Endpoint")
.def(py::init<long, const std::string &, const std::string &, int, const std::string &>())
.def_readwrite("_id", &Endpoint::id)
.def_readwrite("ip", &Endpoint::ip)
Expand Down

0 comments on commit d4cef5d

Please sign in to comment.