Move some data from setupcommon to setup.py
We can't get rid of setupcommon entirely (it's needed by PyInstaller), but at least we can get the data back to setup.py. Fixes #2996
This commit is contained in:
parent
599a5b9648
commit
c74236dd96
@ -18,11 +18,9 @@
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
"""Data used by setup.py and scripts/freeze.py."""
|
||||
"""Data used by setup.py and the PyInstaller qutebrowser.spec."""
|
||||
|
||||
import sys
|
||||
import re
|
||||
import ast
|
||||
import os
|
||||
import os.path
|
||||
import subprocess
|
||||
@ -30,42 +28,16 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
||||
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
_open = open
|
||||
open_file = open
|
||||
else:
|
||||
import codecs
|
||||
_open = codecs.open
|
||||
open_file = codecs.open
|
||||
|
||||
|
||||
BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
os.path.pardir)
|
||||
|
||||
|
||||
def read_file(name):
|
||||
"""Get the string contained in the file named name."""
|
||||
with _open(name, 'r', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def _get_constant(name):
|
||||
"""Read a __magic__ constant from qutebrowser/__init__.py.
|
||||
|
||||
We don't import qutebrowser here because it can go wrong for multiple
|
||||
reasons. Instead we use re/ast to get the value directly from the source
|
||||
file.
|
||||
|
||||
Args:
|
||||
name: The name of the argument to get.
|
||||
|
||||
Return:
|
||||
The value of the argument.
|
||||
"""
|
||||
field_re = re.compile(r'__{}__\s+=\s+(.*)'.format(re.escape(name)))
|
||||
path = os.path.join(BASEDIR, 'qutebrowser', '__init__.py')
|
||||
line = field_re.search(read_file(path)).group(1)
|
||||
value = ast.literal_eval(line)
|
||||
return value
|
||||
|
||||
|
||||
def _git_str():
|
||||
"""Try to find out git version.
|
||||
|
||||
@ -95,37 +67,5 @@ def write_git_file():
|
||||
if gitstr is None:
|
||||
gitstr = ''
|
||||
path = os.path.join(BASEDIR, 'qutebrowser', 'git-commit-id')
|
||||
with _open(path, 'w', encoding='ascii') as f:
|
||||
with open_file(path, 'w', encoding='ascii') as f:
|
||||
f.write(gitstr)
|
||||
|
||||
|
||||
setupdata = {
|
||||
'name': 'qutebrowser',
|
||||
'version': '.'.join(str(e) for e in _get_constant('version_info')),
|
||||
'description': _get_constant('description'),
|
||||
'long_description': read_file('README.asciidoc'),
|
||||
'url': 'https://www.qutebrowser.org/',
|
||||
'requires': ['pypeg2', 'jinja2', 'pygments', 'PyYAML', 'attrs'],
|
||||
'author': _get_constant('author'),
|
||||
'author_email': _get_constant('email'),
|
||||
'license': _get_constant('license'),
|
||||
'classifiers': [
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: X11 Applications :: Qt',
|
||||
'Intended Audience :: End Users/Desktop',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later '
|
||||
'(GPLv3+)',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: Microsoft :: Windows :: Windows XP',
|
||||
'Operating System :: Microsoft :: Windows :: Windows 7',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Topic :: Internet',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Internet :: WWW/HTTP :: Browsers',
|
||||
],
|
||||
'keywords': 'pyqt browser web qt webkit',
|
||||
}
|
||||
|
57
setup.py
57
setup.py
@ -21,6 +21,8 @@
|
||||
|
||||
"""setuptools installer script for qutebrowser."""
|
||||
|
||||
import re
|
||||
import ast
|
||||
import os
|
||||
import os.path
|
||||
|
||||
@ -35,6 +37,32 @@ except NameError:
|
||||
BASEDIR = None
|
||||
|
||||
|
||||
def read_file(name):
|
||||
"""Get the string contained in the file named name."""
|
||||
with common.open_file(name, 'r', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def _get_constant(name):
|
||||
"""Read a __magic__ constant from qutebrowser/__init__.py.
|
||||
|
||||
We don't import qutebrowser here because it can go wrong for multiple
|
||||
reasons. Instead we use re/ast to get the value directly from the source
|
||||
file.
|
||||
|
||||
Args:
|
||||
name: The name of the argument to get.
|
||||
|
||||
Return:
|
||||
The value of the argument.
|
||||
"""
|
||||
field_re = re.compile(r'__{}__\s+=\s+(.*)'.format(re.escape(name)))
|
||||
path = os.path.join(BASEDIR, 'qutebrowser', '__init__.py')
|
||||
line = field_re.search(read_file(path)).group(1)
|
||||
value = ast.literal_eval(line)
|
||||
return value
|
||||
|
||||
|
||||
try:
|
||||
common.write_git_file()
|
||||
setuptools.setup(
|
||||
@ -45,7 +73,34 @@ try:
|
||||
test_suite='qutebrowser.test',
|
||||
zip_safe=True,
|
||||
install_requires=['pypeg2', 'jinja2', 'pygments', 'PyYAML', 'attrs'],
|
||||
**common.setupdata
|
||||
name='qutebrowser',
|
||||
version='.'.join(str(e) for e in _get_constant('version_info')),
|
||||
description=_get_constant('description'),
|
||||
long_description=read_file('README.asciidoc'),
|
||||
url='https://www.qutebrowser.org/',
|
||||
requires=['pypeg2', 'jinja2', 'pygments', 'PyYAML', 'attrs'],
|
||||
author=_get_constant('author'),
|
||||
author_email=_get_constant('email'),
|
||||
license=_get_constant('license'),
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: X11 Applications :: Qt',
|
||||
'Intended Audience :: End Users/Desktop',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later '
|
||||
'(GPLv3+)',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: Microsoft :: Windows :: Windows XP',
|
||||
'Operating System :: Microsoft :: Windows :: Windows 7',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Topic :: Internet',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Internet :: WWW/HTTP :: Browsers',
|
||||
],
|
||||
keywords='pyqt browser web qt webkit',
|
||||
)
|
||||
finally:
|
||||
if BASEDIR is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user