sagemath/sage

Replace `have_program` usage by Features

seblabbe opened this issue · 13 comments

After #32650, remaining usage of have_program are:

$ git grep have_program
src/sage/interfaces/chomp.py:        from sage.misc.sage_ostools import have_program
src/sage/interfaces/chomp.py:        _have_chomp[program] = have_program(program)
src/sage/interfaces/phc.py:            from sage.misc.sage_ostools import have_program
src/sage/interfaces/phc.py:            if not have_program('phc'):
src/sage/misc/dist.py:    from sage.misc.sage_ostools import have_program
src/sage/misc/dist.py:        cmd_inside_sage = have_program(cmd, path=SAGE_BIN)
src/sage/misc/dist.py:        cmd_outside_sage = have_program(cmd, path=PATH)
src/sage/misc/sage_ostools.pyx:def have_program(program, path=None):
src/sage/misc/sage_ostools.pyx:        sage: from sage.misc.sage_ostools import have_program
src/sage/misc/sage_ostools.pyx:        sage: have_program('ls')
src/sage/misc/sage_ostools.pyx:        sage: have_program('there_is_not_a_program_with_this_name')
src/sage/misc/sage_ostools.pyx:        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
src/sage/misc/sage_ostools.pyx:        sage: have_program('sage', '/there_is_not_a_path_with_this_name')
src/sage/misc/sage_ostools.pyx:        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
src/sage/misc/viewer.py:    from sage.misc.sage_ostools import have_program
src/sage/misc/viewer.py:    elif have_program('xdg-open'):
src/sage/misc/viewer.py:                if have_program(cmd):
src/sage/misc/viewer.py:                if have_program(cmd):
src/sage/misc/viewer.py:                if have_program(cmd):

See also:

  • #33405 Eliminate direct use of os.getenv in sage.interfaces
  • #30207 Deprecate sage.misc.dist.install_scripts
  • #30207 Deprecate sage.misc.dist
  • #33931 Deprecate sage.misc.viewer
  • #33777 Deprecate the CHomP interface

CC: @seblabbe @tornaria

Component: distribution

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

comment:1

#30207 proposes to deprecate sage.misc.dist

Description changed:

--- 
+++ 
@@ -22,3 +22,5 @@
 src/sage/misc/viewer.py:                if have_program(cmd):
 src/sage/misc/viewer.py:                if have_program(cmd):
 ```
+
+See also: #33405 Eliminate direct use of `os.getenv` in sage.interfaces

Description changed:

--- 
+++ 
@@ -23,4 +23,6 @@
 src/sage/misc/viewer.py:                if have_program(cmd):
 ```
 
-See also: #33405 Eliminate direct use of `os.getenv` in sage.interfaces
+See also: 
+- #33405 Eliminate direct use of `os.getenv` in sage.interfaces
+- #30207 Deprecate `sage.misc.dist.install_scripts`
comment:7

I can try to convert the chomp stuff to something in features, but I can't test it very well because CHomP doesn't build on OS X, with an error

In file included from /Users/jpalmier/Desktop/Sage/git/CHomP/source/chomp-matrix.cpp:4:
/Users/jpalmier/Desktop/Sage/git/CHomP/include/chomp/Ring.h:224:3: error: C++ requires a type specifier for all declarations
  BOOST_SERIALIZATION_SPLIT_MEMBER()

BOOST_SERIALIZATION_SPLIT_MEMBER seems to come from /usr/local/include/boost/, and I don't know why it's not being found. I wonder if it's time to deprecate the CHomP stuff in Sage anyway; the software at https://github.com/marciogameiro/CHomP hasn't been modified in 5 years.

comment:8

I also feel like there must be a good way to replace sage/misc/viewer.py these days.

comment:9

Should we deprecate sage/misc/dist.py? It obviously hasn't been examined in a while, since it still talks about installing a script for mercurial. It is an artifact of older days when a feature of Sage was that it provided copies of gap, gp/pari, etc., as opposed to now, when we are trying to modularize and we want Sage to rely on system versions of those packages.

comment:10

I'm in favor of deprecating sage.misc.dist (see #30207).

comment:11

Replying to @jhpalmieri:

I wonder if it's time to deprecate the CHomP stuff in Sage anyway

I agree. Looks like it was only provided by an old-style spkg

comment:12

Deprecating CHomP is now #33777.

comment:13

Replying to @jhpalmieri:

I also feel like there must be a good way to replace sage/misc/viewer.py these days.

there's https://docs.python.org/3/library/webbrowser.html

comment:14

Replying to @mkoeppe:

Replying to @jhpalmieri:

I also feel like there must be a good way to replace sage/misc/viewer.py these days.

there's https://docs.python.org/3/library/webbrowser.html

Oh, I see:

webbrowser.open(r'file:///path/to/file')

works for me on OS X, for pdf and image files. For png and jpg files, there is also PIL:

from PIL import Image
with Image.open('filename') as im:
    im.show()
comment:15

See #33931 for the deprecation of sage.misc.viewer.

Description changed:

--- 
+++ 
@@ -26,3 +26,6 @@
 See also: 
 - #33405 Eliminate direct use of `os.getenv` in sage.interfaces
 - #30207 Deprecate `sage.misc.dist.install_scripts`
+- #30207 Deprecate `sage.misc.dist`
+- #33931 Deprecate `sage.misc.viewer`
+- #33777 Deprecate the CHomP interface