Skip to content

Commit

Permalink
Update setup.py (pymedusa#6722)
Browse files Browse the repository at this point in the history
* Update `setup.py`

* Improved setup.py

* Update `check_version.py`
  • Loading branch information
sharkykh authored and medariox committed Jun 6, 2019
1 parent 30236cd commit 385c6b7
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 22 deletions.
14 changes: 8 additions & 6 deletions .github/check_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Check Medusa app version before release"""
from __future__ import print_function, unicode_literals

import io
import os
import re
import subprocess
Expand Down Expand Up @@ -58,15 +59,16 @@ def __repr__(self):


def search_file_for_version():
"""Get the app version from the code."""
version_file = VERSION_FILE.split('/')
filename = os.path.abspath(os.path.join(TRAVIS_BUILD_DIR, *version_file))
with open(filename, 'r') as fh:
data = fh.readlines()
with io.open(filename, 'r', encoding='utf-8') as fh:
for line in fh:
match = VERSION_LINE_REGEXP.match(line)
if match:
return Version(match.group(1))

for line in data:
match = VERSION_LINE_REGEXP.findall(line)
if match:
return Version(match[0])
raise ValueError('Failed to get the app version!')


# Are we merging either develop or a release branch into master in a pull request?
Expand Down
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ failed.db*
autoProcessTV.cfg
server.crt
server.key
medusa.egg-info
.eggs

# Medusa Test Related #
######################
Expand Down Expand Up @@ -66,6 +64,13 @@ Thumbs.db
*~
*.torrent

# Python build related #
######################
build/
dist/
pymedusa.egg-info
.eggs

# Grunt/Gulp/Node build related #
######################
**/bower_components
Expand Down
21 changes: 21 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
recursive-include medusa *.py
graft themes

graft ext
graft ext2
graft ext3
graft lib
graft lib2
graft lib3

graft runscripts

include CHANGELOG.md
include COPYING.txt
include readme.md
include requirements.txt
include SickBeard.py
include start.py

global-exclude __pycache__
global-exclude *.py[cod]
Empty file added ext/__init__.py
Empty file.
Empty file added ext3/__init__.py
Empty file.
1 change: 0 additions & 1 deletion lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

96 changes: 83 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# coding=utf-8
"""Use setup tools to install Medusa."""
import io
import os
import re
import sys

from setuptools import find_packages, setup
from setuptools import setup
from setuptools.command.test import test as TestCommand

here = os.path.abspath(os.path.dirname(__file__))


class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]
user_options = [('pytest-args=', 'a', 'Arguments to pass into py.test')]

def initialize_options(self):
TestCommand.initialize_options(self)
Expand All @@ -27,17 +30,78 @@ def run_tests(self):
sys.exit(errno)


def get_app_version():
"""Get the app version from the code."""
pattern = re.compile(r"VERSION = '([0-9.]+)'")
filename = os.path.join(here, 'medusa', 'common.py')
with io.open(filename, 'r', encoding='utf-8') as fh:
for line in fh:
match = pattern.match(line)
if match:
return match.group(1)

raise ValueError('Failed to get the app version!')


with open(os.path.join(here, 'readme.md'), 'r') as r:
long_description = r.read()


def install_requires():
pkg_name_pattern = re.compile(r'#egg=(.+)(?:&|$)')

with open(os.path.join(here, 'requirements.txt'), 'r') as r:
requirements = r.read().splitlines(keepends=False)

def make_item(req):
if not req.startswith('https://'):
return req
return pkg_name_pattern.search(req).group(1) + ' @ ' + req

return [make_item(req) for req in requirements if req]


def packages():
result = []

for folder in ('medusa', 'ext', 'lib', 'themes'):
if os.path.isdir(os.path.join(here, folder)):
result.append(folder)

for folder in ('ext2', 'ext3', 'lib2', 'lib3'):
if os.path.isdir(os.path.join(here, folder)) and sys.version_info.major == int(folder[-1]):
result.append(folder)

return result


# These requirements probably won't be needed
# when `install_requires` is populated with `requirements.txt`
tests_runtime_require = ['tornado==5.1.1', 'six', 'profilehooks', 'contextlib2', ]

setup(
name="medusa",
description="Automatic Video Library Manager for TV Shows",
name='pymedusa',
description='Automatic Video Library Manager for TV Shows',
version=get_app_version(),
author='pymedusa team',
author_email='',
long_description=long_description,
packages=find_packages(),
install_requires=['tornado==5.1.1', 'six', 'profilehooks', 'contextlib2', ],
long_description_content_type='text/markdown',
url='https://github.com/pymedusa/Medusa',
license='GPLv3',
packages=packages(),
include_package_data=True,
# install_requires=install_requires(),
extras_require={
'system-stats': ['psutil'],
},
entry_points={
'console_scripts': [
'medusa = medusa.__main__:main'
]
},
cmdclass={'test': PyTest},
tests_require=[
tests_require=tests_runtime_require + [
'flake8>=3.5.0',
'flake8-docstrings>=1.3.0',
'flake8-import-order>=0.18',
Expand All @@ -52,13 +116,19 @@ def run_tests(self):
'vcrpy>=2.0.1',
'mock>=2.0.0',
],
extras_require={
'system-stats': ['psutil'],
},
classifiers=[
'Development Status :: ???',
'Development Status :: 4 - Beta',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Operating System :: POSIC :: LINUX',
'Topic :: ???',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: Unix',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Internet',
'Topic :: Multimedia :: Video',
],
)

0 comments on commit 385c6b7

Please sign in to comment.