From a4bd40e8c652290b351988ae3151b1260b6aa028 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Tue, 22 Dec 2020 21:55:01 +0530 Subject: [PATCH] Initial commit for test cases python3 porting --- fabfile/tasks.py | 28 ++++++++++++++-------------- setup.py | 28 +++++++++++++++++++--------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/fabfile/tasks.py b/fabfile/tasks.py index fb05937d..749f4e4a 100644 --- a/fabfile/tasks.py +++ b/fabfile/tasks.py @@ -46,13 +46,13 @@ def print_results(results, top, verbose, details): """Print an item with the appropriate verbosity / detail""" if verbose and results: - print ''.join( + print(''.join( [ os.linesep, 'total pycodestyle flake8 pylint path_to_file', os.linesep, ] - ) + )) for item in sort_and_slice(results, top): @@ -66,23 +66,23 @@ def print_results(results, top, verbose, details): ) else: line = item['path_to_file'] - print line + print(line) if details: - print "pycodestyle:" + print("pycodestyle:") for detail in flatten(item['pycodestyle_violations']): - print detail - print + print(detail) + print() - print "flake8:" + print("flake8:") for detail in flatten(item['flake8_violations']): - print detail - print + print(detail) + print() - print "pylint:" + print("pylint:") for detail in flatten(item['pylint_violations']): - print detail - print + print(detail) + print() def sort_and_slice(results, top): @@ -107,7 +107,7 @@ def generate_file_list(filename): if filename: filename = os.path.abspath(filename) if not os.path.exists(filename): - print "Bad filename, specify a Python file" + print("Bad filename, specify a Python file") sys.exit(1) else: file_list = [filename] @@ -303,7 +303,7 @@ def push_docs(path=None): ) result = run('ln -sf {0} {1}'.format(WEB_ROOT, VERSION_ROOT)) if result.return_code: - print 'Linking the new release failed' + print('Linking the new release failed') # More assumptions sudo('systemctl restart apache2') diff --git a/setup.py b/setup.py index efb5abfc..d27cab15 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,17 @@ EXTRAS_REQUIRE = { 'docs': ['sphinx', 'sphinxcontrib-apidoc', 'm2r'] } +if sys.version_info[0] == 2: + version_dependencies = { + 'requirements_file': 'requirements.txt', + 'pybitmessage_file': 'src/pybitmessage' + } +else: + version_dependencies = { + 'requirements_file': 'py3_requirements.txt', + 'pybitmessage_file': 'src/py3_pybitmessage' + } + class InstallCmd(install): def run(self): @@ -49,7 +60,7 @@ if __name__ == "__main__": with open(os.path.join(here, 'README.md')) as f: README = f.read() - with open(os.path.join(here, 'requirements.txt'), 'r') as f: + with open(os.path.join(here, version_dependencies['requirements_file']), 'r') as f: requirements = list(f.readlines()) bitmsghash = Extension( @@ -61,8 +72,8 @@ if __name__ == "__main__": installRequires = [] packages = [ 'pybitmessage', - 'pybitmessage.bitmessageqt', - 'pybitmessage.bitmessagecurses', + # 'pybitmessage.bitmessageqt', + # 'pybitmessage.bitmessagecurses', 'pybitmessage.fallback', 'pybitmessage.messagetypes', 'pybitmessage.network', @@ -80,7 +91,6 @@ if __name__ == "__main__": "msgpack-python" if msgpack.version[:2] == (0, 4) else "msgpack") except ImportError: try: - import umsgpack installRequires.append("umsgpack") except ImportError: packages += ['pybitmessage.fallback.umsgpack'] @@ -108,11 +118,11 @@ if __name__ == "__main__": long_description=README, license='MIT', # TODO: add author info - #author='', - #author_email='', + # author='', + # author_email='', url='https://bitmessage.org', # TODO: add keywords - #keywords='', + # keywords='', install_requires=installRequires, tests_require=requirements, extras_require=EXTRAS_REQUIRE, @@ -127,7 +137,7 @@ if __name__ == "__main__": package_dir={'pybitmessage': 'src'}, packages=packages, package_data={'': [ - 'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem', + 'sslkeys/*.pem', 'translations/*.ts', 'translations/*.qm', 'images/*.png', 'images/*.ico', 'images/*.icns' ]}, @@ -160,7 +170,7 @@ if __name__ == "__main__": 'pybitmessage = pybitmessage.bitmessagemain:main' ] if sys.platform[:3] == 'win' else [] }, - scripts=['src/pybitmessage'], + scripts=[version_dependencies['pybitmessage_file']], cmdclass={'install': InstallCmd}, command_options={ 'build_sphinx': {