Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python library to bootstrap Sage #18748

Closed
vbraun opened this issue Jun 20, 2015 · 66 comments
Closed

Python library to bootstrap Sage #18748

vbraun opened this issue Jun 20, 2015 · 66 comments

Comments

@vbraun
Copy link
Member

vbraun commented Jun 20, 2015

Move the logic behind package handling and I/O for Python scripts into a separate Python library for code reuse and automated testing.

CC: @nathanncohen

Component: build

Author: Volker Braun

Branch/Commit: 60a581b

Reviewer: John Palmieri

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

@vbraun vbraun added this to the sage-6.8 milestone Jun 20, 2015
@vbraun

This comment has been minimized.

@vbraun
Copy link
Member Author

vbraun commented Jun 20, 2015

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 21, 2015

Commit: 0acf070

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 21, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

bd61b67add the sage-pkg entrypoint
25022c3move sage-download-file to the sage_bootstrap library
0acf070initial implementation of the sage-pkg tool

@vbraun
Copy link
Member Author

vbraun commented Jun 21, 2015

comment:5

Now with testing:

$ tox
[...]
  py26: commands succeeded
  py27: commands succeeded
  py33: commands succeeded
  py34: commands succeeded
  congratulations :)

@vbraun
Copy link
Member Author

vbraun commented Jun 21, 2015

Author: Volker Braun

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 21, 2015

comment:6

Can you explain in detail what you do in this branch? You make many changes, this ticket is now a blocker, and it takes a LONG time to figure it all out from looking at the diff.

@vbraun
Copy link
Member Author

vbraun commented Jun 21, 2015

comment:7
  • No actual functionality changed
  • sage-download-file code is refactored into a package
  • Tests added for everything
  • Output is explained in the README, no more if self.verbose: printflush hacks
  • sage-pkg command to translate between package names and tarball filenames (and maybe query for package types in the future)

@jdemeyer
Copy link

comment:8

sage-pkg was the command to create old-style packages, now it's something completely different. Since we still support old-style packages, can't you rename this script?

Also: why is this a blocker? There is nothing in the description or comments justifying that.

@jdemeyer
Copy link

comment:9

About the directory structure: wouldn't it be simpler to keep the scripts in src/bin (they can still import sage_bootstrap) and then not use the redundant sage_bootstrap/sage_bootstrap subdirectory?

@jdemeyer
Copy link

comment:10

I honestly have no idea what tox does, but I tried it anyway:

jdemeyer@tamiyo:/usr/local/src/sage-config/src/sage_bootstrap$ uname -a
Linux tamiyo 3.17.7-gentoo #1 SMP PREEMPT Wed Dec 31 20:06:39 CET 2014 x86_64 Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz GenuineIntel GNU/Linux
jdemeyer@tamiyo:/usr/local/src/sage-config/src/sage_bootstrap$ python --version
Python 3.3.2
jdemeyer@tamiyo:/usr/local/src/sage-config/src/sage_bootstrap$ tox --version
1.8.1 imported from /usr/lib64/python3.3/site-packages/tox/__init__.py
jdemeyer@tamiyo:/usr/local/src/sage-config/src/sage_bootstrap$ tox
GLOB sdist-make: /usr/local/src/sage-config/src/sage_bootstrap/setup.py
py26 create: /usr/local/src/sage-config/src/sage_bootstrap/.tox/py26
ERROR: InterpreterNotFound: python2.6
py27 inst-nodeps: /usr/local/src/sage-config/src/sage_bootstrap/.tox/dist/sage_bootstrap-1.0.zip
py27 runtests: PYTHONHASHSEED='1210919353'
py27 runtests: commands[0] | python2.7 -m unittest discover
.......E.......
======================================================================
ERROR: test_checksum (test.test_tarball.TarballTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/src/sage-config/src/sage_bootstrap/test/test_tarball.py", line 40, in test_checksum
    self.assertTrue(tarball.checksum_verifies())
  File "/usr/local/src/sage-config/src/sage_bootstrap/sage_bootstrap/tarball.py", line 83, in checksum_verifies
    sha1 = self._compute_sha1()
  File "/usr/local/src/sage-config/src/sage_bootstrap/sage_bootstrap/tarball.py", line 73, in _compute_sha1
    return self._compute_hash(hashlib.sha1())
  File "/usr/local/src/sage-config/src/sage_bootstrap/sage_bootstrap/tarball.py", line 63, in _compute_hash
    with open(self.upstream_fqn, 'rb') as f:
IOError: [Errno 2] No such file or directory: '/usr/local/src/sage-config/upstream/configure-99.tar.gz'

----------------------------------------------------------------------
Ran 15 tests in 6.914s

FAILED (errors=1)
ERROR: InvocationError: '/usr/local/src/sage-config/src/sage_bootstrap/.tox/py27/bin/python2.7 -m unittest discover'
py33 inst-nodeps: /usr/local/src/sage-config/src/sage_bootstrap/.tox/dist/sage_bootstrap-1.0.zip
py33 runtests: PYTHONHASHSEED='1210919353'
py33 runtests: commands[0] | python3.3 -m unittest discover
..../usr/local/src/sage-config/src/sage_bootstrap/sage_bootstrap/download.py:121: DeprecationWarning: FancyURLopener style of invoking requests is deprecated. Use newer urlopen functions/methods
  opener = urllib.FancyURLopener()
...........
----------------------------------------------------------------------
Ran 15 tests in 0.741s

OK
py34 create: /usr/local/src/sage-config/src/sage_bootstrap/.tox/py34
ERROR: InterpreterNotFound: python3.4
_______________________________________________________________________________ summary ________________________________________________________________________________
SKIPPED:  py26: InterpreterNotFound: python2.6
ERROR:   py27: commands failed
  py33: commands succeeded
SKIPPED:  py34: InterpreterNotFound: python3.4

Also, I'm a bit confused by

ERROR: InterpreterNotFound: python3.4

followed later by

SKIPPED:  py34: InterpreterNotFound: python3.4

@jdemeyer
Copy link

comment:11

What would it take to support Python <= 2.5 or Python <= 3.2? I don't know how common these are, but if they can be supported with minimal effort, perhaps it should be done.

@vbraun
Copy link
Member Author

vbraun commented Jun 25, 2015

comment:12

I don't think there is any currently supported OS that ships with those python versions, so its most likely a waste of time to try.

@vbraun
Copy link
Member Author

vbraun commented Jun 25, 2015

comment:13

Blocker because it fixes the firewall issue from #18723 and that ticket was a blocker.

@vbraun
Copy link
Member Author

vbraun commented Jun 25, 2015

comment:14

I don't mind renaming the script, but I don't see the point of avoiding name collisions with historical Sage versions. My plan is to export all new-style package management functions via sage-pkg so its the obvious name for that.

tox (which is pretty much the standard for cross python version testing) is configured to not fail if a python version is not found (see tox.ini)

scripts in src/bin end up being installed in SAGE_LOCAL (and globally if Sage is every packaged / packageable). Build tools shouldn't be globally installed. Really sage-bootstrap only makes sense if you have the source lying around, so why pretend otherwise.

@jdemeyer
Copy link

comment:15

Replying to @vbraun:

I don't mind renaming the script, but I don't see the point of avoiding name collisions with historical Sage versions.

It's a name collision with current Sage versions. And sage --pkg is still currently documented in http://doc.sagemath.org/html/en/developer/packaging_old_spkgs.html#the-file-spkg-txt

tox (which is pretty much the standard for cross python version testing) is configured to not fail if a python version is not found (see tox.ini)

Sure, but it is confusing to see ERROR: InterpreterNotFound: python3.4 if it's not really an error. But if that's the way how tox works, so be it.

@jdemeyer
Copy link

comment:16

Replying to @vbraun:

Blocker because it fixes the firewall issue from #18723 and that ticket was a blocker.

I just don't like if blockers are complicated tickets like this. Why not apply the simple fix of #18723 as blocker and make #18748 a normal ticket?

@vbraun
Copy link
Member Author

vbraun commented Jun 25, 2015

comment:17

THis is a rather simple ticket IMHO, it just refactors a script and adds testing.

@jdemeyer
Copy link

comment:18

Wouldn't it be a lot better to move sage_bootstrap to the $SAGE_ROOT/build directory? That's where the Sage packages reside, so it would make sense to move the package build system also to build.

@jdemeyer
Copy link

comment:19

Replying to @vbraun:

THis is a rather simple ticket

Really?

28 files changed, 1518 insertions, 460 deletions

@jdemeyer
Copy link

comment:20

You have inconsistent indentation (not multiples of 4 spaces) in src/sage_bootstrap/sage_bootstrap/stdio.py

@vbraun
Copy link
Member Author

vbraun commented Jul 5, 2015

comment:42

https://tox.readthedocs.org

The whole point of the refactoring is to make stuff testable

@jhpalmieri
Copy link
Member

comment:43

Why are some of the files not listed in MANIFEST (e.g., tox.ini, test/capture.py)?

@vbraun
Copy link
Member Author

vbraun commented Jul 6, 2015

comment:44

The manifest is auto-generated by tox/distutils to build a package for testing purposes. Its contents don't really matter apart from that. The tox config file arguably doesn't belong there, so I'd count that as a plus. If we were to use the manifest for anything then we would have to add a Manifest.in to fine-tune the inclusion rules.

@jhpalmieri
Copy link
Member

comment:45

Minor questions:

  • In package.py, are the lines
    def __eq__(self, other):
        return self.tarball == other.tarball

there just for testing via tox, or do they serve another purpose?

  • There are some blank spaces on several otherwise empty lines in tarball.py. Do we care?

Overall, the code is just a relocation of old code, so that's okay. I'm not sure about the whole idea of moving it. Seems okay to me, but it doesn't strike me as very high on the priority list.

Less minor questions and comments:

  • What does sage-package do? The file itself should contain some information; you shouldn't have to run it to get its usage message. Maybe the same could be said for sage-download-file, but at least the name is somewhat self-explanatory. I think you should add a line or two there, also. Probably in README, too, for example after the sentence
This is a utility libary for dealing with third-party tarballs and
building Sage. 

(Something like "The main entry points are sage-download-file and sage-package, which are used as follows: ...". Note also that "libary" is currently misspelled.)

  • In addition, I think that each python file in sage_bootstrap could have a bit more documentation, illustrating how to use it. I don't really want to have to read the source code to figure out this sort of thing. For download.py, for example, mention Download(...).run().
  • Add the link ​https://tox.readthedocs.org to README. Maybe we should all know about tox already, but that doesn't seem to be the case.

@vbraun
Copy link
Member Author

vbraun commented Jul 7, 2015

comment:46

Replying to @jhpalmieri:

  • In package.py, are the lines
    def __eq__(self, other):
        return self.tarball == other.tarball

there just for testing via tox, or do they serve another purpose?

They are used for testing in unittest.TestCase.assertEqual, doesn't really have anything to do with tox (which is just the test runner) besides that.

  • There are some blank spaces on several otherwise empty lines in tarball.py. Do we care?

I don't.

Overall, the code is just a relocation of old code, so that's okay. I'm not sure about the whole idea of moving it. Seems okay to me, but it doesn't strike me as very high on the priority list.

The old script was already too long to fit comfortably into one file, with added testing its can't fit into one file. So it has to grow into a package.

Less minor questions and comments:

  • What does sage-package do?

It mostly makes the release manager's job easier because you don't have to log into the server and associated tarball names to package names by hand, which wastes my preciously little available time.

I'm happy to add a line of documentation here or there but unlike the math part this is not a library for Python novices. IMHO its not too much to ask to google for "tox", thats bound to produce way more relevant and informative information than I can possibly be.

@jhpalmieri
Copy link
Member

@jhpalmieri
Copy link
Member

comment:48

Replying to @vbraun:

I'm happy to add a line of documentation here or there but unlike the math part this is not a library for Python novices. IMHO its not too much to ask to google for "tox", thats bound to produce way more relevant and informative information than I can possibly be.

Here is some documentation for the main scripts. I think that few of the Python files could use a bit more information: the current descriptions for package.py and maybe tarball.py are too terse.

@jhpalmieri
Copy link
Member

@jhpalmieri
Copy link
Member

New commits:

9e2c568Merge branch 'develop' into t/18748/python_library_to_bootstrap_sage
cc213dctrac 18748: add documentation to scripts in sage_bootstrap/bin

@jhpalmieri
Copy link
Member

@jhpalmieri
Copy link
Member

Changed commit from e45a0b6 to cc213dc

@vbraun
Copy link
Member Author

vbraun commented Jul 12, 2015

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

8f4fb8eMore docstrings
f9a69a5Convert public attributes to properties and document
075228fMake package.tarball a Tarball instance

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2015

Changed commit from cc213dc to 075228f

@vbraun
Copy link
Member Author

vbraun commented Jul 12, 2015

comment:52

Done, still needs review

@jhpalmieri
Copy link
Member

comment:53

I get an error with tox:

$ tox 
GLOB sdist-make: /Users/palmieri/Desktop/Sage_stuff/git/sage/src/sage_bootstrap/setup.py
py26 create: /Users/palmieri/Desktop/Sage_stuff/git/sage/src/sage_bootstrap/.tox/py26
py26 installdeps: unittest2
py26 inst: /Users/palmieri/Desktop/Sage_stuff/git/sage/src/sage_bootstrap/.tox/dist/sage_bootstrap-1.0.zip
py26 installed: argparse==1.3.0,linecache2==1.0.0,sage-bootstrap==1.0,six==1.9.0,traceback2==1.4.0,unittest2==1.1.0,wheel==0.24.0
py26 runtests: PYTHONHASHSEED='2708481092'
py26 runtests: commands[0] | unit2 discover
............E..
======================================================================
ERROR: test_package (test.test_package.PackageTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/palmieri/Desktop/Sage_stuff/git/sage/src/sage_bootstrap/test/test_package.py", line 34, in test_package
    self.assertIsInstance(pkg.tarball, Tarball)
AttributeError: 'PackageTestCase' object has no attribute 'assertIsInstance'

----------------------------------------------------------------------
Ran 15 tests in 1.056s

FAILED (errors=1)
ERROR: InvocationError: '/Users/palmieri/Desktop/Sage_stuff/git/sage/src/sage_bootstrap/.tox/py26/bin/unit2 discover'

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

c56991bFix Python 2.6 test error

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2015

Changed commit from 075228f to c56991b

@vbraun
Copy link
Member Author

vbraun commented Jul 12, 2015

comment:55

Thanks, ``assertIsInstance` is Python 2.7+, fixed

@jhpalmieri
Copy link
Member

@jhpalmieri
Copy link
Member

Changed commit from c56991b to 60a581b

@jhpalmieri
Copy link
Member

Reviewer: John Palmieri

@jhpalmieri
Copy link
Member

comment:57

Okay, one more addition to the documentation. If you're happy with this, you can set this to positive review.

@vbraun
Copy link
Member Author

vbraun commented Jul 13, 2015

Changed branch from u/jhpalmieri/python_library_to_bootstrap_sage to 60a581b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants