pytrainer: 1.12.1 → 2.0.0

This commit is contained in:
Jan Tojnar 2018-12-31 15:28:20 +01:00 committed by Robert Helgesson
parent 3b1b51520d
commit 99e72dc413
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 69 additions and 88 deletions

View file

@ -1,38 +1,45 @@
{ stdenv, fetchFromGitHub, perl, python, sqlite, gpsbabel
, withWebKit ? false }:
{ stdenv
, fetchFromGitHub
, perl
, python3
, sqlite
, gpsbabel
, gnome3
, gobject-introspection
, wrapGAppsHook
, gtk3
, xvfb_run
, webkitgtk
, glib-networking
, glibcLocales
, tzdata
, substituteAll
}:
let
# Pytrainer needs a matplotlib with GTK backend. Also ensure we are
# using the pygtk with glade support as needed by pytrainer.
matplotlibGtk = python.pkgs.matplotlib.override {
enableGtk2 = true;
pygtk = python.pkgs.pyGtkGlade;
# Pytrainer needs a matplotlib with GTK backend.
matplotlibGtk = python3.pkgs.matplotlib.override {
enableGtk3 = true;
};
in
python.pkgs.buildPythonApplication rec {
name = "pytrainer-${version}";
version = "1.12.1";
python3.pkgs.buildPythonApplication rec {
pname = "pytrainer";
version = "2.0.0";
src = fetchFromGitHub {
owner = "pytrainer";
repo = "pytrainer";
rev = "v${version}";
sha256 = "0rzf8kks96qzlknh6g3b9pjq04j7qk6rmz58scp7sck8xz9rjbwx";
sha256 = "1w5z1xwb2g6j2izm89b7lv9n92r1zhsr8bglxcn7jc5gwbvwysvd";
};
namePrefix = "";
patches = [
# The test fails in the UTC timezone and C locale.
./fix-test-tz.patch
# The existing use of pywebkitgtk shows raw HTML text instead of
# map. This patch solves the problems by showing the file from a
# string, which allows setting an explicit MIME type.
./pytrainer-webkit.patch
(substituteAll {
src = ./fix-paths.patch;
perl = "${perl}/bin/perl";
})
];
postPatch = ''
@ -40,18 +47,40 @@ python.pkgs.buildPythonApplication rec {
--replace "'mysqlclient'," ""
'';
propagatedBuildInputs = with python.pkgs; [
dateutil lxml matplotlibGtk pyGtkGlade sqlalchemy sqlalchemy_migrate psycopg2
] ++ stdenv.lib.optional withWebKit [ pywebkitgtk ];
propagatedBuildInputs = with python3.pkgs; [
dateutil
lxml
matplotlibGtk
pygobject3
sqlalchemy
sqlalchemy_migrate
psycopg2
requests
certifi
];
buildInputs = [ perl gpsbabel sqlite ];
nativeBuildInputs = [
gobject-introspection
wrapGAppsHook
xvfb_run
];
# This package contains no binaries to patch or strip.
dontPatchELF = true;
dontStrip = true;
buildInputs = [
gpsbabel
sqlite
gtk3
webkitgtk
glib-networking
glibcLocales
gnome3.adwaita-icon-theme
];
checkPhase = ''
${python.interpreter} -m unittest discover
env HOME=$TEMPDIR TZDIR=${tzdata}/share/zoneinfo \
TZ=Europe/Kaliningrad \
LC_ALL=en_US.UTF-8 \
xvfb-run -s '-screen 0 800x600x24' \
${python3.interpreter} setup.py test
'';
meta = with stdenv.lib; {

View file

@ -0,0 +1,11 @@
--- a/imports/file_garminfit.py
+++ b/imports/file_garminfit.py
@@ -81,7 +81,7 @@
logging.debug(">>")
result = False
try:
- result = subprocess.check_output(["perl",
+ result = subprocess.check_output(["@perl@",
self.main_data_path+"plugins/garmin-fit/bin/fit2tcx",
filename])
except subprocess.CalledProcessError:

View file

@ -1,45 +0,0 @@
diff -Nurp source.orig/pytrainer/test/core/test_activity.py source/pytrainer/test/core/test_activity.py
--- source.orig/pytrainer/test/core/test_activity.py 2018-02-27 22:15:32.078243354 +0100
+++ source/pytrainer/test/core/test_activity.py 2018-02-27 22:16:33.936867052 +0100
@@ -92,7 +92,7 @@ class ActivityTest(unittest.TestCase):
self.assertEquals(self.activity.time, self.activity.duration)
def test_activity_starttime(self):
- self.assertEquals(self.activity.starttime, '12:58:23 PM')
+ self.assertEquals(self.activity.starttime, '12:58:23')
def test_activity_time_tuple(self):
self.assertEquals(self.activity.time_tuple, (2, 3, 46))
diff -Nurp source.orig/pytrainer/test/imports/test_garmintcxv2.py source/pytrainer/test/imports/test_garmintcxv2.py
--- source.orig/pytrainer/test/imports/test_garmintcxv2.py 2018-02-27 22:15:32.079243364 +0100
+++ source/pytrainer/test/imports/test_garmintcxv2.py 2018-02-27 22:17:10.778333751 +0100
@@ -39,7 +39,7 @@ class GarminTCXv2Test(unittest.TestCase)
self.fail()
def test_workout_summary(self):
- summary = [(0, False, '2012-10-14T12:02:42', '10.12', '00:39:51', 'Running')]
+ summary = [(0, False, '2012-10-14T10:02:42', '10.12', '00:39:51', 'Running')]
try:
current_path = os.path.dirname(os.path.abspath(__file__))
data_path = os.path.dirname(os.path.dirname(os.path.dirname(current_path))) + "/"
@@ -52,7 +52,7 @@ class GarminTCXv2Test(unittest.TestCase)
self.fail()
def test_summary_in_database(self):
- summary = [(0, True, '2012-10-14T12:02:42', '10.12', '00:39:51', 'Running')]
+ summary = [(0, True, '2012-10-14T10:02:42', '10.12', '00:39:51', 'Running')]
activity = Activity(date_time_utc='2012-10-14T10:02:42Z', sport_id='1')
self.ddbb.session.add(activity)
self.ddbb.session.commit(
diff -Nurp source.orig/pytrainer/test/lib/test_date.py source/pytrainer/test/lib/test_date.py
--- source.orig/pytrainer/test/lib/test_date.py 2018-05-10 21:15:22.196275555 +0200
+++ source/pytrainer/test/lib/test_date.py 2018-05-10 21:22:43.647870401 +0200
@@ -47,7 +47,7 @@ class DateFunctionTest(unittest.TestCase
def test_getDateTime(self):
utctime, localtime = getDateTime('Tue Nov 24 17:29:05 UTC 2015')
self.assertEqual(datetime.datetime(2015, 11, 24, 17, 29, 5, tzinfo=tzutc()), utctime)
- self.assertEqual(datetime.datetime(2015, 11, 24, 19, 29, 5, tzinfo=tzlocal()), localtime)
+ self.assertEqual(datetime.datetime(2015, 11, 24, 17, 29, 5, tzinfo=tzlocal()), localtime)
class DateRangeTest(unittest.TestCase):

View file

@ -1,14 +0,0 @@
diff -Nurp pytrainer-1.10.0-orig/pytrainer/extensions/mapviewer.py pytrainer-1.10.0/pytrainer/extensions/mapviewer.py
--- pytrainer-1.10.0-orig/pytrainer/extensions/mapviewer.py 2013-03-31 12:28:29.000000000 +0200
+++ pytrainer-1.10.0/pytrainer/extensions/mapviewer.py 2014-12-22 11:44:44.367032126 +0100
@@ -46,7 +46,9 @@ class MapViewer:
logging.debug(">>")
if htmlfile is None:
htmlfile = self.createErrorHtml()
- self.wkview.load_uri("file://%s" % (htmlfile))
+ content = open(htmlfile, 'r').read()
+ self.wkview.load_string(content, 'text/html', 'UTF-8', 'file:///')
+ #self.wkview.load_uri("file://%s" % (htmlfile))
#self.box.show_all()
logging.debug("<<")