Python frameworks

mark brethen mbrethen at aim.com
Tue Aug 9 16:18:34 PDT 2011


OK, here's how I understand it. Taking a look at  'spyder' in /opt/local/bin:

Marks-MacBook-Pro:bin marbre$ more spyder
#!/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
from spyderlib import spyder
spyder.main()

And in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python, the Python 2.7.2 Launcher is run.  Which explains why spyder will run Python 2.7 in its console regardless of what is in PATH. 

The 'programs.py' script seems to be where module existence is checked by spyder. This function is called by 'pylintgui.py' to check for pylint:

def is_program_installed(basename, get_path=False):
    """Return True if program is installed and present in PATH"""
    for path in os.environ["PATH"].split(os.pathsep):
        abspath = osp.join(path, basename)
        if osp.isfile(abspath):
            if get_path:
                return abspath
            else:
                return True
    else:
        return False

I also found this function:

def is_module_installed(module_name):
    """Return True if module *module_name* is installed"""
    try:
        __import__(module_name)
        return True
    except ImportError:
        return False

I'm sure what calls this, but I would think it would stand a better chance of success in the MacPorts python framework. 


-Mark



On Aug 8, 2011, at 5:43 PM, Brandon Allbery wrote:

> On Mon, Aug 8, 2011 at 12:48, Ryan Schmidt <ryandesign at macports.org> wrote:
> On Aug 6, 2011, at 11:20, mark brethen wrote:
> >> I'm kind of reluctant to handle this in Spyder's code (of course, if it's the only way, we will take action anyway) because there is absolutely no reason for MacPorts to differentiate pylint scripts depending on Python minor version number: after all, this script is an executable that should behaves exactly the same way on any Python version.
> 
> I understand the developer's viewpoint, but he is probably not aware of all of the complexities involving software packaging.
> 
> We have multiple ports for spyder and pylint in MacPorts (for each of several versions of Python). These can be installed simultaneously, so they cannot install the same files. So none of these can install an executable /opt/local/bin/pylint.
> 
> Strictly speaking, it's not a package manager issue, it's a configuration manager issue.  This kind of thing comes up most often in managed environments using configuration managers such as Puppet, bcfg2, Chef, cfengine, etc., as well as university environments such as depot (CMU), Athena (MIT), and Nikola (UW); this is somewhat important for research professors and students working on their Ph.D theses who don't want to risk having to deal with path or version vagaries across platforms.
> 
> The correct answer here is for spyder to use a global config file to get the default values for these settings, so that $configuration_manager_of_choice can configure the install in the local support tree to use programs from the local support tree.
>  
> -- 
> brandon s allbery                                      allbery.b at gmail.com
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
> 



More information about the macports-users mailing list