Closed simon-king-jena closed 15 years ago
Unfortunately, I have no idea how a non-destructive doc-test may look like. Certainly > it would hardly be acceptable to have a doc-test that installs something.
We could have an official "test" spkg. And it would be marked
optional -- admin
meaning one must have write privileges to the sage install in order to run it. The test would install and uninstall that package.
William
Replying to @williamstein:
We could have an official "test" spkg. And it would be marked
optional -- admin
meaning one must have write privileges to the sage install in order to run it. The test would install and uninstall that package.
Sorry, at that point I have to pass out. So far, I did not produce a new package (hopefully I'll learn it soon), and also I don't how one can un-install a package.
Replying to @williamstein:
We could have an official "test" spkg. And it would be marked
optional -- admin
meaning one must have write privileges to the sage install in order to run it. The test would install and uninstall that package.
Another idea: Call the test package tomato.spkg
, and construct it such that the attempt to install it would actually have no effect.
Hence, there were no need to mark it optional -- admin
, and also no need to uninstall it.
That package would just comprise a Makefile with the simple content
all:
echo "Tomato ejects itself"
Would it work? At least it would be rather "pythonic"...
Cheers, Simon
Please open a ticket for a test-dummy.spkg and I will provide one. Uninstalling spkg per see is not really supported at the moment, but we can delete the entry from $SAGE_ROOT/spkg/installed/ manually.
Cheers,
Michael
Replying to @sagetrac-mabshoff:
Please open a ticket for a test-dummy.spkg and I will provide one. Uninstalling spkg per see is not really supported at the moment, but we can delete the entry from $SAGE_ROOT/spkg/installed/ manually.
Done, see #4617.
Cheers, Simon
REFEREE REPORT:
I don't love the design, but a small change could fix it so I would like it.
Can you change it so install_latest_version is not exported to the global namespace. Instead, if one calls install_package('...') with an input that doesn't contain a dash (i.e., doesn't contain any version number), then install_package simply calls install_latest_version.
The whole reason you wrote install_latest_version is because install_package is just really incompletely implemented, so just use it to implement the rest of install_package, and don't add more to the global namespace.
William
Dear William,
I removed the install_latest_version
, so the global name space is not further polluted. Instead, I moved the code into install_package
.
So, now, install_package
first tests whether there is a unique package name that starts with the given string (Note: This is done regardless whether it contains a dash or not. I hope this is not a problem). If there is a unique package, it is installed.
If the optional parameter 'forced' is not used, then it is only tried to find the package name among those packages that are not installed. In that way, an unintentional re-install is impossible.
I guess there will be no doc-test unless someone produces a test_dummy.spkg
Attachment: installpackage.patch.gz
install_package: If there is a unique package starting with a given string, it gets installed
Fortunately you didn't review the patch that I had submitted a few hours ago. I was in a hurry, didn't test it, and had a mistake...
But the current patch does what I announced. My tests:
install_package('pil')
, it said that there is no package with that name (perhaps it would be better to say 'no uninstalled package').install_package('pil',True)
did a re-install.install_package('p')
showed a list of possible extensions and raised an error.What do you think:
REFEREE REPORT:
The logic is now somewhat broken, unfortunately. E.g.,
sage: install_package('database_sloane')
... it works ...
but then
sage: install_package('database_sloane')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/was/build/sage-3.2.1.alpha1/<ipython console> in <module>()
/home/was/build/sage-3.2.1.alpha1/local/lib/python2.5/site-packages/sage/misc/package.pyc in install_package(package, force)
78 raise ValueError, "There is more than one package name starting with '%s'. Please specify!"%(package)
79 if len(L)==0:
---> 80 raise ValueError, "There is no package name starting with '%s'."%(package)
81 os.system('sage -f "%s"'%(L[0]))
82 __installed_packages = None
ValueError: There is no package name starting with 'database_sloane'.
sage: install_package('database_sloane_oeis-2005-12')
same error as above.
which is the wrong error message.
Replying to @williamstein:
REFEREE REPORT:
The logic is now somewhat broken, unfortunately. E.g., ValueError: There is no package name starting with 'database_sloane'.
Yep, this is what I meant when I said in my previous comment "(perhaps it would be better to say 'no uninstalled package')".
The logic is:
I agree that the error message may be clearer. So, back at work...
Attachment: installpackageErrorMessage.patch.gz
To be applied after the first patch: Improving the error message
After applying the second patch: If the name is non-unique, I get with force install:
sage: install_package('p',True)
Possible package names starting with 'p' are:
palp-1.1.p1
...
pyx-0.8.1
ValueError: There is more than one package name starting with 'p'. Please specify!
and without force:
sage: install_package('p')
Possible names of non-installed packages starting with 'p':
phc-2.3.39.p0
...
pyx-0.8.1
ValueError: There is more than one package name starting with 'p'. Please specify!
If the package exists, without 'force' I get:
sage: install_package('pil')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
...
ValueError: Package is already installed. Try install_package('pil',force=True)
Is this better?
Remains the doc-test issue. I leave it up to you whether one should wait for the test_dummy.spkg, so, I keep the summary [with patch, needs work].
Remains the doc-test issue. I leave it up to you whether one should wait for the test_dummy.spkg, so, I keep the summary [with patch, needs work].
For this sort of thing, I'm not too worried. 100% coverage is critical in cases when it is at least reasonably straightforward how to write the doctests. Here it is itself pretty confusing.
Looks great!!
Merged both patches in Sage 3.2.1.rc0
William wrote at http://groups.google.com/group/sage-devel/browse_thread/thread/de91554d761c5f1b?hl=en
''I think nobody every implemented a "install latest version of package foo" yet for Sage. That's been on the todo list for years. ''
It is not difficult to implement, using the existing functtions from sage.misc.package, namely
install_package
andoptional_package
etc.I implemented a function
install_latest_version
inpackage.py
and included it inall.py
.Now, one can install the optional pil-1.1.6 package with
Repeating the command yields the Traceback
Forced re-installation is then possible with
If there is no possible package name extension, a Traceback results. There is also a Traceback if the extension is not unique. In that case, before raising the error, a list of all possible extensions is shown.
Or should this function not raise an error?
Unfortunately I have no idea how to have a non-destructive doc-test. Certainly it'd not be acceptable to have a doc-test installing something.
Unfortunately, I have no idea how a non-destructive doc-test may look like. Certainly it would hardly be acceptable to have a doc-test that installs something.
Component: packages: standard
Keywords: installing package latest version
Issue created by migration from https://trac.sagemath.org/ticket/4587