Set minimum python version required to 3.2

This commit is contained in:
Nick Hall 2015-02-28 17:57:00 +00:00
parent 4f72a8bc6a
commit 1a661bcc3d
3 changed files with 21 additions and 46 deletions

View File

@ -12,7 +12,7 @@ version by deleting the installed directories. For example, if your installation
If you installed with a package manager you might instead need to remove If you installed with a package manager you might instead need to remove
/usr/local/lib/pythonx.x/dist-packages/gramps /usr/local/lib/pythonx.x/dist-packages/gramps
replacing pythonx.x with the python version you used, e.g. python2.7. replacing pythonx.x with the python version you used, e.g. python3.4.
Also remove any gramps .egg files that are installed along with the gramps Also remove any gramps .egg files that are installed along with the gramps
directory and the file /usr/local/bin/gramps. directory and the file /usr/local/bin/gramps.
@ -49,7 +49,7 @@ things like MIME type and desktop entries.
See below for ways to invoke Gramps. See below for ways to invoke Gramps.
Typical install directories in linux (ubuntu) are: Typical install directories in linux (ubuntu) are:
* /usr/local/lib/python2.7/dist-packages/gramps/ : the gramps python module * /usr/local/lib/python3.4/dist-packages/gramps/ : the gramps python module
* /usr/local/share/mime-info : mime info so gramps opens files automatically * /usr/local/share/mime-info : mime info so gramps opens files automatically
* /usr/local/share/icons/gnome : our icons * /usr/local/share/icons/gnome : our icons
* /usr/local/share/doc/gramps : documentation, also example .gramps and .gedcom * /usr/local/share/doc/gramps : documentation, also example .gramps and .gedcom

4
README
View File

@ -5,13 +5,13 @@ Please read the INSTALL file if you intend to build from source.
Requirements Requirements
-------------------------------- --------------------------------
The following packages *MUST* be installed in order for Gramps to work: The following packages *MUST* be installed in order for Gramps to work:
Python 2.7 or greater, Python 3.2 or greater (or both python versions) Python 3.2 or greater
GTK 3.0 or greater GTK 3.0 or greater
pygobject 3.3.2 or greater pygobject 3.3.2 or greater
cairo, pango, pangocairo with introspection bindings (the gi packages) cairo, pango, pangocairo with introspection bindings (the gi packages)
librsvg2 (svg icon view) librsvg2 (svg icon view)
xdg-utils xdg-utils
bsddb3 is required for Python 3.2 (not python 2.7) bsddb3
The following package is needed for full translation of the interface The following package is needed for full translation of the interface
to your language: to your language:

View File

@ -27,14 +27,7 @@
# Python modules # Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from __future__ import print_function, unicode_literals
import sys import sys
## hack to avoid mentioning 'utf8' encoding everywhere unicode or str is is used
if sys.version_info[0] < 3:
reload(sys)
sys.setdefaultencoding('utf8')
##
import os import os
import signal import signal
@ -46,7 +39,7 @@ from subprocess import Popen, PIPE
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from .gen.const import APP_GRAMPS, USER_DIRLIST, HOME_DIR from .gen.const import APP_GRAMPS, USER_DIRLIST, HOME_DIR
@ -132,7 +125,7 @@ _ = glocale.translation.gettext
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
MIN_PYTHON_VERSION = (2, 7, 0, '', 0) MIN_PYTHON_VERSION = (3, 2, 0, '', 0)
if not sys.version_info >= MIN_PYTHON_VERSION : if not sys.version_info >= MIN_PYTHON_VERSION :
logging.warning(_("Your Python version does not meet the " logging.warning(_("Your Python version does not meet the "
"requirements. At least python %(v1)d.%(v2)d.%(v3)d is needed to" "requirements. At least python %(v1)d.%(v2)d.%(v3)d is needed to"
@ -143,19 +136,17 @@ if not sys.version_info >= MIN_PYTHON_VERSION :
'v3': MIN_PYTHON_VERSION[2]}) 'v3': MIN_PYTHON_VERSION[2]})
sys.exit(1) sys.exit(1)
if sys.version_info[0] >= 3: try:
#check if bsddb3 is installed import bsddb3
try: except ImportError:
import bsddb3 logging.warning(_("\nYou don't have the python bsddb3 package installed."
except ImportError: " This package is needed to start Gramps.\n\n"
logging.warning(_("\nYou don't have the python bsddb3 package installed." "Gramps will terminate now."))
" This package is needed to start Gramps.\n\n" sys.exit(1)
"Gramps will terminate now."))
sys.exit(1)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# gramps libraries # Gramps libraries
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
try: try:
@ -268,13 +259,8 @@ def show_settings():
pyicu_str = 'not found' pyicu_str = 'not found'
icu_str = 'not found' icu_str = 'not found'
from .gen.config import config
usebsddb3 = config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3
try: try:
if usebsddb3: import bsddb3 as bsddb
import bsddb3 as bsddb
else:
import bsddb
bsddb_str = bsddb.__version__ bsddb_str = bsddb.__version__
bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\ bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\
.replace('(', '').replace(')', '') .replace('(', '').replace(')', '')
@ -330,10 +316,6 @@ def show_settings():
print (' gtk++ : %s' % gtkver_str) print (' gtk++ : %s' % gtkver_str)
print (' pygobject : %s' % pygobjectver_str) print (' pygobject : %s' % pygobjectver_str)
print (' pango : %s' % pangover_str) print (' pango : %s' % pangover_str)
if usebsddb3:
print (' Using bsddb3')
else:
print (' Not using bsddb3')
print (' bsddb : %s' % bsddb_str) print (' bsddb : %s' % bsddb_str)
print (' bsddb.db : %s' % bsddb_db_str) print (' bsddb.db : %s' % bsddb_db_str)
print (' cairo : %s' % cairover_str) print (' cairo : %s' % cairover_str)
@ -433,26 +415,19 @@ def run():
return error return error
startgtkloop(error, argpars) startgtkloop(error, argpars)
else: else:
#CLI use of GRAMPS #CLI use of Gramps
#Ensure that output is encoded correctly to stdout and #Ensure that output is encoded correctly to stdout and
#stderr. This is much less cumbersome and error-prone than #stderr. This is much less cumbersome and error-prone than
#encoding individual outputs and better handles the #encoding individual outputs:
#differences between Python 2 and Python 3:
try: try:
_encoding = sys.stdout.encoding or sys.getdefaultencoding() _encoding = sys.stdout.encoding or sys.getdefaultencoding()
except: except:
_encoding = "UTF-8" _encoding = "UTF-8"
if sys.version_info[0] < 3: sys.stdout = codecs.getwriter(_encoding)(sys.stdout.detach(),
sys.stdout = codecs.getwriter(_encoding)(sys.stdout, 'backslashreplace')
'backslashreplace') sys.stderr = codecs.getwriter(_encoding)(sys.stderr.detach(),
sys.stderr = codecs.getwriter(_encoding)(sys.stderr, 'backslashreplace')
'backslashreplace')
else:
sys.stdout = codecs.getwriter(_encoding)(sys.stdout.detach(),
'backslashreplace')
sys.stderr = codecs.getwriter(_encoding)(sys.stderr.detach(),
'backslashreplace')
argpars.print_help() argpars.print_help()
argpars.print_usage() argpars.print_usage()
from .cli.grampscli import startcli from .cli.grampscli import startcli