Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Latest commit

 

History

History
1866 lines (1375 loc) · 67.8 KB

20802.md

File metadata and controls

1866 lines (1375 loc) · 67.8 KB

Issue 20802: Restore Python 2.6+ compatibility

archive/issues_020565.json:

{
    "assignees": [],
    "body": "<div id=\"comment:0\"></div>\n\nAs of Sage 7.3.beta6, building Sage requires a system Python >= 2.7 because `sage-uncompress-spkg` uses `argparse`.\n\nWhile we already ship a copy of `argparse.py`, `sage-uncompress-spkg` currently doesn't try to import it from where it's located in the Sage tree.\n\n\nDepends on #19984\nDepends on #20871\n\nCC:  @dimpase @embray @jdemeyer\n\nComponent: **build**\n\nKeywords: **argparse sage-uncompress-spkg**\n\nAuthor: **Volker Braun**\n\nBranch/Commit: **[`775a3d3`](https://github.com/sagemath/sagetrac-mirror/commit/775a3d3e160388b6d5b21b0a38e0ec2b3d247ef0)**\n\nReviewer: **Erik Bray, Leif Leonhardy, Dima Pasechnik**\n\n_Issue created by migration from https://trac.sagemath.org/ticket/20802_\n\n",
    "closed_at": "2016-07-27T20:24:40Z",
    "created_at": "2016-06-10T18:18:39Z",
    "labels": [
        "https://github.com/sagemath/sage/labels/c%3A%20build",
        "https://github.com/sagemath/sage/labels/p%3A%20blocker%20/%201",
        "https://github.com/sagemath/sage/labels/bug"
    ],
    "milestone": "https://github.com/sagemath/sage/milestones/sage-7.3",
    "reactions": [],
    "repository": "https://github.com/sagemath/sage",
    "title": "Restore Python 2.6+ compatibility",
    "type": "issue",
    "updated_at": "2016-07-27T20:24:40Z",
    "url": "https://github.com/sagemath/sage/issues/20802",
    "user": "https://github.com/vbraun"
}

As of Sage 7.3.beta6, building Sage requires a system Python >= 2.7 because sage-uncompress-spkg uses argparse.

While we already ship a copy of argparse.py, sage-uncompress-spkg currently doesn't try to import it from where it's located in the Sage tree.

Depends on #19984 Depends on #20871

CC: @dimpase @embray @jdemeyer

Component: build

Keywords: argparse sage-uncompress-spkg

Author: Volker Braun

Branch/Commit: 775a3d3

Reviewer: Erik Bray, Leif Leonhardy, Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/20802


archive/issue_events_290246.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-10T18:18:39Z",
    "event": "milestoned",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "milestone_number": null,
    "milestone_title": "sage-7.3",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290246"
}

archive/issue_events_290247.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-10T18:18:39Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/p%3A%20major%20/%203",
    "label_color": "ffbb00",
    "label_name": "p: major / 3",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290247"
}

archive/issue_comments_301681.json:

{
    "body": "Branch: **[u/vbraun/sage_requires_python_2_7_](https://github.com/sagemath/sagetrac-mirror/tree/u/vbraun/sage_requires_python_2_7_)**",
    "created_at": "2016-06-10T18:24:27Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301681",
    "user": "https://github.com/vbraun"
}

Branch: u/vbraun/sage_requires_python_2_7_


archive/issue_comments_301682.json:

{
    "body": "<div id=\"comment:2\"></div>\n\nNew commits:\n<table><tr><td><a href=\"https://github.com/sagemath/sagetrac-mirror/commit/c323a93bd31fa80fba6f7c9c9aa9626499840731\"><code>c323a93</code></a></td><td><code>Sage requires Python 2.7+</code></td></tr></table>\n",
    "created_at": "2016-06-10T18:25:33Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301682",
    "user": "https://github.com/vbraun"
}

New commits:

c323a93Sage requires Python 2.7+

archive/issue_events_290248.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-10T18:25:33Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/bug",
    "label_color": "d73a4a",
    "label_name": "bug",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290248"
}

archive/issue_comments_301683.json:

{
    "body": "Commit: **[`c323a93`](https://github.com/sagemath/sagetrac-mirror/commit/c323a93bd31fa80fba6f7c9c9aa9626499840731)**",
    "created_at": "2016-06-10T18:25:33Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301683",
    "user": "https://github.com/vbraun"
}

Commit: c323a93


archive/issue_comments_301684.json:

{
    "body": "Author: **Volker Braun**",
    "created_at": "2016-06-10T18:25:33Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301684",
    "user": "https://github.com/vbraun"
}

Author: Volker Braun


archive/issue_events_290249.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-10T18:25:33Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/c%3A%20documentation",
    "label_color": "0075ca",
    "label_name": "c: documentation",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290249"
}

archive/issue_events_290250.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-10T18:25:33Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290250"
}

archive/issue_comments_301685.json:

{
    "body": "<div id=\"comment:3\" align=\"right\">comment:3</div>\n\nJust a few months ago, people were complaining about a change (fixed in #20252) which prevented Sage from building with Python 2.6. So I think this is a dangerous change to implement: we will lose some of our user base. See [discussion in sage-devel](https://groups.google.com/d/msg/sage-devel/1hbXSJFWDZw/NNP9L2V9DQAJ). What is the motivation?",
    "created_at": "2016-06-10T18:44:55Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301685",
    "user": "https://github.com/jhpalmieri"
}
comment:3

Just a few months ago, people were complaining about a change (fixed in #20252) which prevented Sage from building with Python 2.6. So I think this is a dangerous change to implement: we will lose some of our user base. See discussion in sage-devel. What is the motivation?


archive/issue_comments_301686.json:

{
    "body": "<div id=\"comment:4\" align=\"right\">comment:4</div>\n\nThe fix has been broken in #20721\n\nI've advocated bundling argparse (which is imho a no-brainer) but the 0.1% size increase was deemed unacceptable in #19984.",
    "created_at": "2016-06-10T18:49:44Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301686",
    "user": "https://github.com/vbraun"
}
comment:4

The fix has been broken in #20721

I've advocated bundling argparse (which is imho a no-brainer) but the 0.1% size increase was deemed unacceptable in #19984.


archive/issue_comments_301687.json:

{
    "body": "<div id=\"comment:5\" align=\"right\">comment:5</div>\n\nIs use of argparse the only thing that currently breaks compatibility for Python 2.6?  If so I think bundling it is a no-brainer--I've done it in a dozen other projects (though most projects are finally droppping support for Python 2.6).\n\nThat said we either support Python 2.6 or we don't.  If Sage isn't tested against Python 2.6 it doesn't support it as far as anyone should be concerned.  Same goes for any other Python version.  If it's not tested it's not supported.",
    "created_at": "2016-06-13T08:11:16Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301687",
    "user": "https://github.com/embray"
}
comment:5

Is use of argparse the only thing that currently breaks compatibility for Python 2.6? If so I think bundling it is a no-brainer--I've done it in a dozen other projects (though most projects are finally droppping support for Python 2.6).

That said we either support Python 2.6 or we don't. If Sage isn't tested against Python 2.6 it doesn't support it as far as anyone should be concerned. Same goes for any other Python version. If it's not tested it's not supported.


archive/issue_comments_301688.json:

{
    "body": "<div id=\"comment:6\" align=\"right\">comment:6</div>\n\nReplying to [@embray](#comment%3A5):\n> Is use of argparse the only thing that currently breaks compatibility for Python 2.6?  If so I think bundling it is a no-brainer--I've done it in a dozen other projects (though most projects are finally droppping support for Python 2.6).\n> \n> That said we either support Python 2.6 or we don't.  If Sage isn't tested against Python 2.6 it doesn't support it as far as anyone should be concerned.  Same goes for any other Python version.  If it's not tested it's not supported.\n\nthere is demand for Python 2.6 support. It should be easy to set up a VM with one of these LTS Linux systems which are using 2.6 as the default. The question is who will do this, and on what system. There is spare capacity on the UW cluster, I think, to do this.",
    "created_at": "2016-06-13T08:20:54Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301688",
    "user": "https://github.com/dimpase"
}
comment:6

Replying to @embray:

Is use of argparse the only thing that currently breaks compatibility for Python 2.6? If so I think bundling it is a no-brainer--I've done it in a dozen other projects (though most projects are finally droppping support for Python 2.6).

That said we either support Python 2.6 or we don't. If Sage isn't tested against Python 2.6 it doesn't support it as far as anyone should be concerned. Same goes for any other Python version. If it's not tested it's not supported.

there is demand for Python 2.6 support. It should be easy to set up a VM with one of these LTS Linux systems which are using 2.6 as the default. The question is who will do this, and on what system. There is spare capacity on the UW cluster, I think, to do this.


archive/issue_comments_301689.json:

{
    "body": "<div id=\"comment:7\" align=\"right\">comment:7</div>\n\nSo, what should be done to reenable 2.6?",
    "created_at": "2016-06-13T08:22:17Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301689",
    "user": "https://github.com/dimpase"
}
comment:7

So, what should be done to reenable 2.6?


archive/issue_comments_301690.json:

{
    "body": "<div id=\"comment:8\" align=\"right\">comment:8</div>\n\nI guess also I was confused about using Python as a build dependency versus as a runtime dependency.  As a runtime dependency only Python 2.7 is supported I guess.  But for the build tools 2.6+ makes sense (but should be tested if we're to claim to support it).",
    "created_at": "2016-06-13T08:23:27Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301690",
    "user": "https://github.com/embray"
}
comment:8

I guess also I was confused about using Python as a build dependency versus as a runtime dependency. As a runtime dependency only Python 2.7 is supported I guess. But for the build tools 2.6+ makes sense (but should be tested if we're to claim to support it).


archive/issue_comments_301691.json:

{
    "body": "Changed commit from **[`c323a93`](https://github.com/sagemath/sagetrac-mirror/commit/c323a93bd31fa80fba6f7c9c9aa9626499840731)** to none",
    "created_at": "2016-06-13T16:14:36Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301691",
    "user": "https://github.com/vbraun"
}

Changed commit from c323a93 to none


archive/issue_comments_301692.json:

{
    "body": "Dependencies: **#19984**",
    "created_at": "2016-06-13T16:14:36Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301692",
    "user": "https://github.com/vbraun"
}

Dependencies: #19984


archive/issue_comments_301693.json:

{
    "body": "Changed branch from **[u/vbraun/sage_requires_python_2_7_](https://github.com/sagemath/sagetrac-mirror/tree/u/vbraun/sage_requires_python_2_7_)** to none",
    "created_at": "2016-06-13T16:14:36Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301693",
    "user": "https://github.com/vbraun"
}

Changed branch from u/vbraun/sage_requires_python_2_7_ to none


archive/issue_events_290251.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-13T16:14:36Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290251"
}

archive/issue_events_290252.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-13T16:14:36Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20work",
    "label_color": "ffff00",
    "label_name": "needs work",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290252"
}

archive/issue_events_290253.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-13T16:14:36Z",
    "event": "renamed",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "title_is": "Restore Python 2.6+ compatibility",
    "title_was": "Sage requires Python 2.7+",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290253"
}

archive/issue_events_290254.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-13T16:14:36Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/p%3A%20major%20/%203",
    "label_color": "ffbb00",
    "label_name": "p: major / 3",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290254"
}

archive/issue_events_290255.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-06-13T16:14:36Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/p%3A%20blocker%20/%201",
    "label_color": "ff0000",
    "label_name": "p: blocker / 1",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290255"
}

archive/issue_comments_301694.json:

{
    "body": "<div id=\"comment:10\" align=\"right\">comment:10</div>\n\nThere is testing via tox for multiple Python versions. Though you need to write tests, obviously. Its not currently tested on the buildbot, thats a todo for the buildbot configuration.",
    "created_at": "2016-06-13T16:16:07Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301694",
    "user": "https://github.com/vbraun"
}
comment:10

There is testing via tox for multiple Python versions. Though you need to write tests, obviously. Its not currently tested on the buildbot, thats a todo for the buildbot configuration.


archive/issue_comments_301695.json:

{
    "body": "<div id=\"comment:11\" align=\"right\">comment:11</div>\n\nI'm still a little confused here.  What specifically is being tested via tox is there are no tests (and what are we talking about tests *for*)?  \n\nFor example, what command(s) are being run by tox?  Who's running tox, if not the build bot?",
    "created_at": "2016-06-14T08:32:19Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301695",
    "user": "https://github.com/embray"
}
comment:11

I'm still a little confused here. What specifically is being tested via tox is there are no tests (and what are we talking about tests for)?

For example, what command(s) are being run by tox? Who's running tox, if not the build bot?


archive/issue_comments_301696.json:

{
    "body": "<div id=\"comment:12\" align=\"right\">comment:12</div>\n\nI don't understand what you mean; Tests are in `build/tests` and you can run them right now via `cd build && tox`. Developers are supposed to run the tests before making commits, not just the buildbot ;-)",
    "created_at": "2016-06-14T16:12:01Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301696",
    "user": "https://github.com/vbraun"
}
comment:12

I don't understand what you mean; Tests are in build/tests and you can run them right now via cd build && tox. Developers are supposed to run the tests before making commits, not just the buildbot ;-)


archive/issue_comments_301697.json:

{
    "body": "<div id=\"comment:13\" align=\"right\">comment:13</div>\n\nAh, I think that's relatively new.  Wasn't there a few days ago.",
    "created_at": "2016-06-15T08:25:41Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301697",
    "user": "https://github.com/embray"
}
comment:13

Ah, I think that's relatively new. Wasn't there a few days ago.


archive/issue_comments_301698.json:

{
    "body": "<div id=\"comment:14\" align=\"right\">comment:14</div>\n\nPing.\n\nDo we need more than, say\n\n```diff\ndiff --git a/build/bin/sage-uncompress-spkg b/build/bin/sage-uncompress-spkg\nindex 9b72878..e7339ad 100755\n--- a/build/bin/sage-uncompress-spkg\n+++ b/build/bin/sage-uncompress-spkg\n@@ -28,10 +28,22 @@ printing the SPKG.txt file from an old-style spkg.)\n \n from __future__ import print_function\n \n-import argparse\n-import copy\n import os\n import sys\n+try:\n+    import argparse\n+except ImportError:\n+    # Python 2.6 doesn't have it\n+    SAGE_ROOT = os.environ.get(\"SAGE_ROOT\")\n+    if not SAGE_ROOT:\n+        sys.stderr.write(\n+            \"Error: SAGE_ROOT not set, needed to import Sage's argparse module.\\n\")\n+        sys.exit(1)\n+    sys.path.append(os.path.join(SAGE_ROOT, \"build\", \"sage_bootstrap\", \"compat\"))\n+    # we could also first check the presence of Sage's argparse.py here\n+    import argparse\n+    # bail out if that also fails (or suggest something else?)\n+import copy\n import tarfile\n import zipfile\n \n```\n?",
    "created_at": "2016-07-01T16:14:03Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301698",
    "user": "https://github.com/nexttime"
}
comment:14

Ping.

Do we need more than, say

diff --git a/build/bin/sage-uncompress-spkg b/build/bin/sage-uncompress-spkg
index 9b72878..e7339ad 100755
--- a/build/bin/sage-uncompress-spkg
+++ b/build/bin/sage-uncompress-spkg
@@ -28,10 +28,22 @@ printing the SPKG.txt file from an old-style spkg.)
 
 from __future__ import print_function
 
-import argparse
-import copy
 import os
 import sys
+try:
+    import argparse
+except ImportError:
+    # Python 2.6 doesn't have it
+    SAGE_ROOT = os.environ.get("SAGE_ROOT")
+    if not SAGE_ROOT:
+        sys.stderr.write(
+            "Error: SAGE_ROOT not set, needed to import Sage's argparse module.\n")
+        sys.exit(1)
+    sys.path.append(os.path.join(SAGE_ROOT, "build", "sage_bootstrap", "compat"))
+    # we could also first check the presence of Sage's argparse.py here
+    import argparse
+    # bail out if that also fails (or suggest something else?)
+import copy
 import tarfile
 import zipfile
 

?


archive/issue_events_290256.json:

{
    "actor": "https://github.com/nexttime",
    "created_at": "2016-07-01T16:16:48Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/c%3A%20documentation",
    "label_color": "0075ca",
    "label_name": "c: documentation",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290256"
}

archive/issue_events_290257.json:

{
    "actor": "https://github.com/nexttime",
    "created_at": "2016-07-01T16:16:48Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/c%3A%20build",
    "label_color": "0000b0",
    "label_name": "c: build",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290257"
}

archive/issue_comments_301699.json:

{
    "body": "<div id=\"comment:16\" align=\"right\">comment:16</div>\n\nIf it's too much trouble, I can also just change this script to use `optparse` instead of `argparse`.  I don't think there's really any `argparse`-specific features that it's strongly relying on.",
    "created_at": "2016-07-04T10:11:59Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301699",
    "user": "https://github.com/embray"
}
comment:16

If it's too much trouble, I can also just change this script to use optparse instead of argparse. I don't think there's really any argparse-specific features that it's strongly relying on.


archive/issue_comments_301700.json:

{
    "body": "<div id=\"comment:17\" align=\"right\">comment:17</div>\n\nReplying to [@embray](#comment%3A16):\n> If it's too much trouble, I can also just change this script to use `optparse` instead of `argparse`.  I don't think there's really any `argparse`-specific features that it's strongly relying on.\n\nI rather meant to ask whether it's only the above little change we need, but I've meanwhile built Sage 7.3.beta6 from scratch with that on a system with just Python 2.6, which worked without any issues.  (`argparse.py` already gets shipped in `build/sage_bootstrap/compat/` anyway.)\n\nSo now the question is whether I should put a branch *here* or open a separate ticket specifically for `sage-uncompress-spkg` as the ticket's title sounds pretty generic (as if it was meant to be a meta-ticket).",
    "created_at": "2016-07-04T12:06:48Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301700",
    "user": "https://github.com/nexttime"
}
comment:17

Replying to @embray:

If it's too much trouble, I can also just change this script to use optparse instead of argparse. I don't think there's really any argparse-specific features that it's strongly relying on.

I rather meant to ask whether it's only the above little change we need, but I've meanwhile built Sage 7.3.beta6 from scratch with that on a system with just Python 2.6, which worked without any issues. (argparse.py already gets shipped in build/sage_bootstrap/compat/ anyway.)

So now the question is whether I should put a branch here or open a separate ticket specifically for sage-uncompress-spkg as the ticket's title sounds pretty generic (as if it was meant to be a meta-ticket).


archive/issue_events_290258.json:

{
    "actor": "https://github.com/nexttime",
    "created_at": "2016-07-04T12:06:48Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20work",
    "label_color": "ffff00",
    "label_name": "needs work",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290258"
}

archive/issue_events_290259.json:

{
    "actor": "https://github.com/nexttime",
    "created_at": "2016-07-04T12:06:48Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20info",
    "label_color": "ffff00",
    "label_name": "needs info",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290259"
}

archive/issue_comments_301701.json:

{
    "body": "Description changed:\n``````diff\n--- \n+++ \n@@ -1 +1,4 @@\n+As of Sage 7.3.beta6, building Sage requires a system Python >= 2.7 because `sage-uncompress-spkg` uses `argparse`.\n \n+While we already ship a copy of `argparse.py`, `sage-uncompress-spkg` currently doesn't try to import it from where it's located in the Sage tree.\n+\n``````\n",
    "created_at": "2016-07-04T12:06:48Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301701",
    "user": "https://github.com/nexttime"
}

Description changed:

--- 
+++ 
@@ -1 +1,4 @@
+As of Sage 7.3.beta6, building Sage requires a system Python >= 2.7 because `sage-uncompress-spkg` uses `argparse`.
 
+While we already ship a copy of `argparse.py`, `sage-uncompress-spkg` currently doesn't try to import it from where it's located in the Sage tree.
+

archive/issue_comments_301702.json:

{
    "body": "Changed author from **Volker Braun** to none",
    "created_at": "2016-07-04T12:06:48Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301702",
    "user": "https://github.com/nexttime"
}

Changed author from Volker Braun to none


archive/issue_comments_301703.json:

{
    "body": "Changed keywords from none to **argparse sage-uncompress-spkg**",
    "created_at": "2016-07-04T12:06:48Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301703",
    "user": "https://github.com/nexttime"
}

Changed keywords from none to argparse sage-uncompress-spkg


archive/issue_comments_301704.json:

{
    "body": "<div id=\"comment:18\" align=\"right\">comment:18</div>\n\nAs long as `sage-uncompress-spkg` is not **needed** to install things into `build/sage_bootstrap/compat/`, this looks good.",
    "created_at": "2016-07-04T12:11:14Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301704",
    "user": "https://github.com/dimpase"
}
comment:18

As long as sage-uncompress-spkg is not needed to install things into build/sage_bootstrap/compat/, this looks good.


archive/issue_comments_301705.json:

{
    "body": "<div id=\"comment:19\" align=\"right\">comment:19</div>\n\nJust import from `sage_bootstrap.compat.argparse`",
    "created_at": "2016-07-04T12:42:06Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301705",
    "user": "https://github.com/vbraun"
}
comment:19

Just import from sage_bootstrap.compat.argparse


archive/issue_comments_301706.json:

{
    "body": "<div id=\"comment:20\" align=\"right\">comment:20</div>\n\nReplying to [@vbraun](#comment%3A19):\n> Just import from `sage_bootstrap.compat.argparse`\n\nYou mean unconditionally?",
    "created_at": "2016-07-04T13:01:01Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301706",
    "user": "https://github.com/nexttime"
}
comment:20

Replying to @vbraun:

Just import from sage_bootstrap.compat.argparse

You mean unconditionally?


archive/issue_comments_301707.json:

{
    "body": "<div id=\"comment:21\" align=\"right\">comment:21</div>\n\nReplying to [@nexttime](#comment%3A20):\n> Replying to [@vbraun](#comment%3A19):\n> > Just import from `sage_bootstrap.compat.argparse`\n> \n> \n> You mean unconditionally?\n> \n\nWell, why? The difference is that, AFAII, `bootstrap.compat.argparse` exists, while `build/sage_bootstrap/compat/` might not (yet).",
    "created_at": "2016-07-04T13:07:33Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301707",
    "user": "https://github.com/dimpase"
}
comment:21

Replying to @nexttime:

Replying to @vbraun:

Just import from sage_bootstrap.compat.argparse

You mean unconditionally?

Well, why? The difference is that, AFAII, bootstrap.compat.argparse exists, while build/sage_bootstrap/compat/ might not (yet).


archive/issue_comments_301708.json:

{
    "body": "<div id=\"comment:22\" align=\"right\">comment:22</div>\n\n`build/sage_bootstrap/compat` is checked into the Sage repo so it will exist as long as you have the source code.",
    "created_at": "2016-07-04T13:13:43Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301708",
    "user": "https://github.com/vbraun"
}
comment:22

build/sage_bootstrap/compat is checked into the Sage repo so it will exist as long as you have the source code.


archive/issue_comments_301709.json:

{
    "body": "<div id=\"comment:23\" align=\"right\">comment:23</div>\n\nI think it would still be better to try to import the existing package first, and fall back on the compat version shipped with sage otherwise.",
    "created_at": "2016-07-04T14:01:28Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301709",
    "user": "https://github.com/embray"
}
comment:23

I think it would still be better to try to import the existing package first, and fall back on the compat version shipped with sage otherwise.


archive/issue_comments_301710.json:

{
    "body": "<div id=\"comment:24\" align=\"right\">comment:24</div>\n\n#20871 (merged in 7.3.beta7) added a new import to `sage-uncompress-spkg`...",
    "created_at": "2016-07-09T14:53:55Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301710",
    "user": "https://github.com/nexttime"
}
comment:24

#20871 (merged in 7.3.beta7) added a new import to sage-uncompress-spkg...


archive/issue_comments_301711.json:

{
    "body": "Changed dependencies from **#19984** to **#19984, #20871**",
    "created_at": "2016-07-09T14:53:55Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301711",
    "user": "https://github.com/nexttime"
}

Changed dependencies from #19984 to #19984, #20871


archive/issue_comments_301712.json:

{
    "body": "<div id=\"comment:25\" align=\"right\">comment:25</div>\n\nReplying to [@nexttime](#comment%3A24):\n> #20871 (merged in 7.3.beta7) added a new import to `sage-uncompress-spkg`...\n\nOnly the `stat` module, for two constants, both of which are the same in Python 2.6.",
    "created_at": "2016-07-11T11:22:32Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301712",
    "user": "https://github.com/embray"
}
comment:25

Replying to @nexttime:

#20871 (merged in 7.3.beta7) added a new import to sage-uncompress-spkg...

Only the stat module, for two constants, both of which are the same in Python 2.6.


archive/issue_comments_301713.json:

{
    "body": "<div id=\"comment:26\" align=\"right\">comment:26</div>\n\nReplying to [@embray](#comment%3A25):\n> Replying to [@nexttime](#comment%3A24):\n> > #20871 (merged in 7.3.beta7) added a new import to `sage-uncompress-spkg`...\n> \n> \n> Only the `stat` module, for two constants, both of which are the same in Python 2.6.  \n\nYep, but that broke the patch because a change happened within its context.  (While there's no branch here yet anyway, it'll have to depend on #20871 now).",
    "created_at": "2016-07-11T12:04:42Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301713",
    "user": "https://github.com/nexttime"
}
comment:26

Replying to @embray:

Replying to @nexttime:

#20871 (merged in 7.3.beta7) added a new import to sage-uncompress-spkg...

Only the stat module, for two constants, both of which are the same in Python 2.6.

Yep, but that broke the patch because a change happened within its context. (While there's no branch here yet anyway, it'll have to depend on #20871 now).


archive/issue_comments_301714.json:

{
    "body": "<div id=\"comment:27\" align=\"right\">comment:27</div>\n\nReplying to [@embray](#comment%3A23):\n> I think it would still be better to try to import the existing package first, and fall back on the compat version shipped with sage otherwise.\n\nGenerally, I don't like the philosophy of \"try A and if that didn't work, use B instead\". It means two different scenarios which can break. If B is always available and it works, why bother with trying A first?",
    "created_at": "2016-07-11T23:49:40Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301714",
    "user": "https://github.com/jdemeyer"
}
comment:27

Replying to @embray:

I think it would still be better to try to import the existing package first, and fall back on the compat version shipped with sage otherwise.

Generally, I don't like the philosophy of "try A and if that didn't work, use B instead". It means two different scenarios which can break. If B is always available and it works, why bother with trying A first?


archive/issue_comments_301715.json:

{
    "body": "<div id=\"comment:28\" align=\"right\">comment:28</div>\n\nThats the standard pattern for vendoring python libraries, I don't think its particularly fruitful to discuss it here.",
    "created_at": "2016-07-12T07:29:17Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301715",
    "user": "https://github.com/vbraun"
}
comment:28

Thats the standard pattern for vendoring python libraries, I don't think its particularly fruitful to discuss it here.


archive/issue_comments_301716.json:

{
    "body": "<div id=\"comment:29\" align=\"right\">comment:29</div>\n\nReplying to [@vbraun](#comment%3A28):\n> Thats the standard pattern for vendoring python libraries, I don't think its particularly fruitful to discuss it here.\n\n+1",
    "created_at": "2016-07-12T08:01:54Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301716",
    "user": "https://github.com/embray"
}
comment:29

Replying to @vbraun:

Thats the standard pattern for vendoring python libraries, I don't think its particularly fruitful to discuss it here.

+1


archive/issue_comments_301717.json:

{
    "body": "Branch: **[u/vbraun/restore_python_2_6__compatibility](https://github.com/sagemath/sagetrac-mirror/tree/u/vbraun/restore_python_2_6__compatibility)**",
    "created_at": "2016-07-23T23:03:18Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301717",
    "user": "https://github.com/vbraun"
}

Branch: u/vbraun/restore_python_2_6__compatibility


archive/issue_comments_301718.json:

{
    "body": "Author: **Volker Braun**",
    "created_at": "2016-07-23T23:03:54Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301718",
    "user": "https://github.com/vbraun"
}

Author: Volker Braun


archive/issue_comments_301719.json:

{
    "body": "<div id=\"comment:31\"></div>\n\nNew commits:\n<table><tr><td><a href=\"https://github.com/sagemath/sagetrac-mirror/commit/775a3d3e160388b6d5b21b0a38e0ec2b3d247ef0\"><code>775a3d3</code></a></td><td><code>Refactor sage-uncompress-spkg, add tests</code></td></tr></table>\n",
    "created_at": "2016-07-23T23:03:54Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301719",
    "user": "https://github.com/vbraun"
}

New commits:

775a3d3Refactor sage-uncompress-spkg, add tests

archive/issue_comments_301720.json:

{
    "body": "Commit: **[`775a3d3`](https://github.com/sagemath/sagetrac-mirror/commit/775a3d3e160388b6d5b21b0a38e0ec2b3d247ef0)**",
    "created_at": "2016-07-23T23:03:54Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301720",
    "user": "https://github.com/vbraun"
}

Commit: 775a3d3


archive/issue_events_290260.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-07-23T23:03:54Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20info",
    "label_color": "ffff00",
    "label_name": "needs info",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290260"
}

archive/issue_events_290261.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-07-23T23:03:54Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290261"
}

archive/issue_comments_301721.json:

{
    "body": "<div id=\"comment:32\" align=\"right\">comment:32</div>\n\nFWIW, I intentionally did *not* import the whole `sage_bootstrap` package just because `sage-uncompress-spkg` in case of Python 2.6 needs the `argparse` module (and only that) from `.../compat/` in my patch.\n\n---\n\nCould you add a `.contains_garbage()` property in order to not pass the whole list of all files in a tarball to `.extractall()` if it returns `False` (which is the normal case -- it should IMHO error out unless given some option to override that otherwise, or *at least* give a warning).\n\nAs is, it essentially does\n\n```sh\ntar xf $TARBALL $( tar tf $TARBALL | cat )\n```\nor, worse (and more explicit),\n\n```sh\ngunzip -c $TARBALL | tar xf - $( gunzip -c $TARBALL | tar tf - | cat )\n```\nin the normal (non-error) case, where `gunzip` will be `bunzip2` if `$TARBALL` ends with `.bz2` instead of `.gz`; since you're also building a dictionary, `cat` here doesn't even properly reflect the no-op processing of all filenames in the archive (it would have to be some more complex identity function).\n\n\n\n\nYou could in addition rename `.names()` to `.valid_names()` say, and add another function `.invalid_names()` (or `.names()` returning *all* names) or whatever (such that it is possible to obtain the ones filtered out, or at least see whether any files got filtered out, but if we give an error or warning message, that should contain *which* files are considered garbage).",
    "created_at": "2016-07-24T15:02:09Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301721",
    "user": "https://github.com/nexttime"
}
comment:32

FWIW, I intentionally did not import the whole sage_bootstrap package just because sage-uncompress-spkg in case of Python 2.6 needs the argparse module (and only that) from .../compat/ in my patch.


Could you add a .contains_garbage() property in order to not pass the whole list of all files in a tarball to .extractall() if it returns False (which is the normal case -- it should IMHO error out unless given some option to override that otherwise, or at least give a warning).

As is, it essentially does

tar xf $TARBALL $( tar tf $TARBALL | cat )

or, worse (and more explicit),

gunzip -c $TARBALL | tar xf - $( gunzip -c $TARBALL | tar tf - | cat )

in the normal (non-error) case, where gunzip will be bunzip2 if $TARBALL ends with .bz2 instead of .gz; since you're also building a dictionary, cat here doesn't even properly reflect the no-op processing of all filenames in the archive (it would have to be some more complex identity function).

You could in addition rename .names() to .valid_names() say, and add another function .invalid_names() (or .names() returning all names) or whatever (such that it is possible to obtain the ones filtered out, or at least see whether any files got filtered out, but if we give an error or warning message, that should contain which files are considered garbage).


archive/issue_comments_301722.json:

{
    "body": "<div id=\"comment:33\" align=\"right\">comment:33</div>\n\nIHMO adding subdirectories of packages to sys.path is to be avoided as it can cause confusion.\n\nI don't mind beautifying the file handling logic, but that doesn't belong to this ticket.",
    "created_at": "2016-07-24T15:22:14Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301722",
    "user": "https://github.com/vbraun"
}
comment:33

IHMO adding subdirectories of packages to sys.path is to be avoided as it can cause confusion.

I don't mind beautifying the file handling logic, but that doesn't belong to this ticket.


archive/issue_comments_301723.json:

{
    "body": "<div id=\"comment:34\" align=\"right\">comment:34</div>\n\nP.S.:  To those unfamiliar with the tar (**t**ape **ar**chive) file format:\n\nIn contrast to e.g. a zip archive, the tar header does *not* contain a \"table of contents\"; to get a list of all files contained in a tarball (or to see whether it contains some file(s)), the *whole archive* has to get read.  (This originates from the sequential access of tapes, and has other advantages.)",
    "created_at": "2016-07-24T15:24:00Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301723",
    "user": "https://github.com/nexttime"
}
comment:34

P.S.: To those unfamiliar with the tar (tape archive) file format:

In contrast to e.g. a zip archive, the tar header does not contain a "table of contents"; to get a list of all files contained in a tarball (or to see whether it contains some file(s)), the whole archive has to get read. (This originates from the sequential access of tapes, and has other advantages.)


archive/issue_comments_301724.json:

{
    "body": "<div id=\"comment:35\" align=\"right\">comment:35</div>\n\nReplying to [@vbraun](#comment%3A33):\n> IHMO adding subdirectories of packages to sys.path is to be avoided as it can cause confusion.\n\nSure, but I didn't put `argparse` there, which is unrelated to and independent of all the other stuff there.\n\n\n\n\n> I don't mind beautifying the file handling logic, but that doesn't belong to this ticket.\n\nBut completely rewriting it (or changing its structure, and adding tests etc.) does?\n\nThat's really completely unrelated to Python 2.6 support; if you're referring to the title, all we need *here* is to pick up the `argparse` module.  And it's currently a blocker ticket.\n\nI'd suggest to put your restructuring etc. on a follow-up, where we can improve other things as well (to not say remove further regressions introduced previously).\n\nIf the latter still makes it into Sage 7.3, fine, otherwise it doesn't hurt because the main issue has already been fixed here -- quickly and safe.",
    "created_at": "2016-07-24T15:39:19Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301724",
    "user": "https://github.com/nexttime"
}
comment:35

Replying to @vbraun:

IHMO adding subdirectories of packages to sys.path is to be avoided as it can cause confusion.

Sure, but I didn't put argparse there, which is unrelated to and independent of all the other stuff there.

I don't mind beautifying the file handling logic, but that doesn't belong to this ticket.

But completely rewriting it (or changing its structure, and adding tests etc.) does?

That's really completely unrelated to Python 2.6 support; if you're referring to the title, all we need here is to pick up the argparse module. And it's currently a blocker ticket.

I'd suggest to put your restructuring etc. on a follow-up, where we can improve other things as well (to not say remove further regressions introduced previously).

If the latter still makes it into Sage 7.3, fine, otherwise it doesn't hurt because the main issue has already been fixed here -- quickly and safe.


archive/issue_comments_301725.json:

{
    "body": "<div id=\"comment:36\" align=\"right\">comment:36</div>\n\nReplying to [@nexttime](#comment%3A35):\n> But completely rewriting it (or changing its structure, and adding tests etc.) does?\n\nYes, especially adding tests that you can run with tox on a variety of Python versions is IMHO crucially important.",
    "created_at": "2016-07-24T15:41:36Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301725",
    "user": "https://github.com/vbraun"
}
comment:36

Replying to @nexttime:

But completely rewriting it (or changing its structure, and adding tests etc.) does?

Yes, especially adding tests that you can run with tox on a variety of Python versions is IMHO crucially important.


archive/issue_comments_301726.json:

{
    "body": "<div id=\"comment:37\" align=\"right\">comment:37</div>\n\nThen also add tests with \"garbage\" in the archive.\n\nAnd a warning message is still missing, which is even more important.",
    "created_at": "2016-07-24T15:44:48Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301726",
    "user": "https://github.com/nexttime"
}
comment:37

Then also add tests with "garbage" in the archive.

And a warning message is still missing, which is even more important.


archive/issue_comments_301727.json:

{
    "body": "<div id=\"comment:38\" align=\"right\">comment:38</div>\n\nP.S.:  If we want to continue Python 2.6 support, at least one buildbot should have (and use) it anyway.",
    "created_at": "2016-07-24T15:51:16Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301727",
    "user": "https://github.com/nexttime"
}
comment:38

P.S.: If we want to continue Python 2.6 support, at least one buildbot should have (and use) it anyway.


archive/issue_comments_301728.json:

{
    "body": "<div id=\"comment:39\" align=\"right\">comment:39</div>\n\nThose are good suggestions but not really on scope for this ticket.",
    "created_at": "2016-07-24T17:57:36Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301728",
    "user": "https://github.com/vbraun"
}
comment:39

Those are good suggestions but not really on scope for this ticket.


archive/issue_comments_301729.json:

{
    "body": "<div id=\"comment:40\" align=\"right\">comment:40</div>\n\nReplying to [@vbraun](#comment%3A39):\n> Those are good suggestions but not really on scope for this ticket.\n\n[https://en.wikipedia.org/wiki/Procrastination](https://en.wikipedia.org/wiki/Procrastination)",
    "created_at": "2016-07-24T20:12:33Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301729",
    "user": "https://github.com/nexttime"
}
comment:40

Replying to @vbraun:

Those are good suggestions but not really on scope for this ticket.

https://en.wikipedia.org/wiki/Procrastination


archive/issue_comments_301730.json:

{
    "body": "<div id=\"comment:41\" align=\"right\">comment:41</div>\n\n`filter_os_files.py` seems a bit overly-specialized.  I might just call that `utils.py`.  But up to you.  LGTM otherwise.",
    "created_at": "2016-07-26T12:19:47Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301730",
    "user": "https://github.com/embray"
}
comment:41

filter_os_files.py seems a bit overly-specialized. I might just call that utils.py. But up to you. LGTM otherwise.


archive/issue_comments_301731.json:

{
    "body": "<div id=\"comment:42\" align=\"right\">comment:42</div>\n\nthere is [comment:ticket:20870:4] about getting directory permissions right in `sage-uncompress-spkg`.\n\nIs it indeed the case it is fixed here, or was always fixed anyway?\n\n---\n\nEDIT: Cross-ticket comment reference is `[comment:ticket:TTTTT:CCC]`.",
    "created_at": "2016-07-26T13:26:02Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301731",
    "user": "https://github.com/dimpase"
}
comment:42

there is [comment:ticket:20870:4] about getting directory permissions right in sage-uncompress-spkg.

Is it indeed the case it is fixed here, or was always fixed anyway?


EDIT: Cross-ticket comment reference is [comment:ticket:TTTTT:CCC].


archive/issue_comments_301732.json:

{
    "body": "<div id=\"comment:43\" align=\"right\">comment:43</div>\n\nI didn't change anything, but `SageTarFile.chmod` (which I didn't change) suggests that permissions are sanitized.",
    "created_at": "2016-07-26T14:00:19Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301732",
    "user": "https://github.com/vbraun"
}
comment:43

I didn't change anything, but SageTarFile.chmod (which I didn't change) suggests that permissions are sanitized.


archive/issue_comments_301733.json:

{
    "body": "<div id=\"comment:44\" align=\"right\">comment:44</div>\n\nwhat are these errors:\n\n```\nsage -t build/test/capture.py  # ImportError in doctesting framework\n...\n```\nAre these files meant to be tested in some other way?",
    "created_at": "2016-07-26T14:13:09Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301733",
    "user": "https://github.com/dimpase"
}
comment:44

what are these errors:

sage -t build/test/capture.py  # ImportError in doctesting framework
...

Are these files meant to be tested in some other way?


archive/issue_comments_301734.json:

{
    "body": "<div id=\"comment:45\" align=\"right\">comment:45</div>\n\nReplying to [@dimpase](#comment%3A44):\n> what are these errors:\n> \n> ```\n> sage -t build/test/capture.py  # ImportError in doctesting framework\n> ...\n> ```\n> Are these files meant to be tested in some other way?\n\nAt least they're not directly tested by `ptestlong` (which passed for me):\n\n```sh\n$ ./sage -t --long build/test/\n...\n----------------------------------------------------------------------\nsage -t --long build/test/test_package.py  # ImportError in doctesting framework\nsage -t --long build/test/test_is_url.py  # ImportError in doctesting framework\nsage -t --long build/test/test_download.py  # ValueError in doctesting framework\nsage -t --long build/test/runnable.py  # ImportError in doctesting framework\nsage -t --long build/test/test_download_cmdline.py  # ImportError in doctesting framework\nsage -t --long build/test/test_config.py  # ImportError in doctesting framework\nsage -t --long build/test/capture.py  # ImportError in doctesting framework\nsage -t --long build/test/test_mirror_list.py  # ValueError in doctesting framework\nsage -t --long build/test/test_cksum.py  # ImportError in doctesting framework\nsage -t --long build/test/test_tarball.py  # ImportError in doctesting framework\nsage -t --long build/test/test_uncompress.py  # ImportError in doctesting framework\nsage -t --long build/test/test_logger.py  # ValueError in doctesting framework\nsage -t --long build/test/test_package_cmdline.py  # ImportError in doctesting framework\n----------------------------------------------------------------------\n```",
    "created_at": "2016-07-26T15:42:34Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301734",
    "user": "https://github.com/nexttime"
}
comment:45

Replying to @dimpase:

what are these errors:

sage -t build/test/capture.py  # ImportError in doctesting framework
...

Are these files meant to be tested in some other way?

At least they're not directly tested by ptestlong (which passed for me):

$ ./sage -t --long build/test/
...
----------------------------------------------------------------------
sage -t --long build/test/test_package.py  # ImportError in doctesting framework
sage -t --long build/test/test_is_url.py  # ImportError in doctesting framework
sage -t --long build/test/test_download.py  # ValueError in doctesting framework
sage -t --long build/test/runnable.py  # ImportError in doctesting framework
sage -t --long build/test/test_download_cmdline.py  # ImportError in doctesting framework
sage -t --long build/test/test_config.py  # ImportError in doctesting framework
sage -t --long build/test/capture.py  # ImportError in doctesting framework
sage -t --long build/test/test_mirror_list.py  # ValueError in doctesting framework
sage -t --long build/test/test_cksum.py  # ImportError in doctesting framework
sage -t --long build/test/test_tarball.py  # ImportError in doctesting framework
sage -t --long build/test/test_uncompress.py  # ImportError in doctesting framework
sage -t --long build/test/test_logger.py  # ValueError in doctesting framework
sage -t --long build/test/test_package_cmdline.py  # ImportError in doctesting framework
----------------------------------------------------------------------

archive/issue_comments_301735.json:

{
    "body": "<div id=\"comment:46\" align=\"right\">comment:46</div>\n\nNo, they aren't meant to be run with the Sage doctest runner. They are meant to execute under tox, which is also ideally suited to run against multiple python versions (see tox.ini):\n\n```\ncd build\ntox\n```",
    "created_at": "2016-07-26T16:40:51Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301735",
    "user": "https://github.com/vbraun"
}
comment:46

No, they aren't meant to be run with the Sage doctest runner. They are meant to execute under tox, which is also ideally suited to run against multiple python versions (see tox.ini):

cd build
tox

archive/issue_comments_301736.json:

{
    "body": "Reviewer: **Erik Bray, Leif Leonhardy, Dima Pasechnik**",
    "created_at": "2016-07-26T22:03:27Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301736",
    "user": "https://github.com/dimpase"
}

Reviewer: Erik Bray, Leif Leonhardy, Dima Pasechnik


archive/issue_events_290262.json:

{
    "actor": "https://github.com/dimpase",
    "created_at": "2016-07-26T22:03:27Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290262"
}

archive/issue_events_290263.json:

{
    "actor": "https://github.com/dimpase",
    "created_at": "2016-07-26T22:03:27Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/positive%20review",
    "label_color": "dfffc0",
    "label_name": "positive review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290263"
}

archive/issue_comments_301737.json:

{
    "body": "<div id=\"comment:47\" align=\"right\">comment:47</div>\n\nLGTM",
    "created_at": "2016-07-26T22:03:27Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301737",
    "user": "https://github.com/dimpase"
}
comment:47

LGTM


archive/issue_comments_301738.json:

{
    "body": "<div id=\"comment:48\" align=\"right\">comment:48</div>\n\nPS. Perhaps for another ticket:\n\n```\npy34 runtests: commands[0] | python3.4 -m unittest discover\n...../home/dima/software/sage/build/sage_bootstrap/download/transfer.py:123: DeprecationWarning: FancyURLopener style of invoking requests is deprecated. Use newer urlopen functions/methods\n  opener = urllib.FancyURLopener()\n```",
    "created_at": "2016-07-26T22:04:51Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301738",
    "user": "https://github.com/dimpase"
}
comment:48

PS. Perhaps for another ticket:

py34 runtests: commands[0] | python3.4 -m unittest discover
...../home/dima/software/sage/build/sage_bootstrap/download/transfer.py:123: DeprecationWarning: FancyURLopener style of invoking requests is deprecated. Use newer urlopen functions/methods
  opener = urllib.FancyURLopener()

archive/issue_comments_301739.json:

{
    "body": "<div id=\"comment:49\" align=\"right\">comment:49</div>\n\nOMG, fancy is deprecated?!",
    "created_at": "2016-07-26T22:21:27Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301739",
    "user": "https://github.com/nexttime"
}
comment:49

OMG, fancy is deprecated?!


archive/issue_events_290264.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2016-07-27T20:24:40Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "label": "https://github.com/sagemath/sage/labels/positive%20review",
    "label_color": "dfffc0",
    "label_name": "positive review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290264"
}

archive/issue_events_290265.json:

{
    "actor": "https://github.com/vbraun",
    "commit_id": "7d53d1f99e55720b9f33b7325b2d3b77d44891f1",
    "commit_repository": "https://github.com/sagemath/sage",
    "created_at": "2016-07-27T20:24:40Z",
    "event": "closed",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20802#event-290265"
}

archive/issue_comments_301740.json:

{
    "body": "Changed branch from **[u/vbraun/restore_python_2_6__compatibility](https://github.com/sagemath/sagetrac-mirror/tree/u/vbraun/restore_python_2_6__compatibility)** to **[`775a3d3`](https://github.com/sagemath/sagetrac-mirror/commit/775a3d3e160388b6d5b21b0a38e0ec2b3d247ef0)**",
    "created_at": "2016-07-27T20:24:40Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20802",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20802#issuecomment-301740",
    "user": "https://github.com/vbraun"
}

Changed branch from u/vbraun/restore_python_2_6__compatibility to 775a3d3