scons icon indicating copy to clipboard operation
scons copied to clipboard

CheckPython and CheckPythonHeaders

Open bdbaddog opened this issue 7 years ago • 2 comments

This issue was originally created at: 2006-02-12 09:11:26. This issue was reported by: gustavo.

gustavo said at 2006-02-12 09:11:26

This patch adds CheckPython and CheckPythonHeaders configuration tests. See docstring for respective documentation.

Caveat: it uses the 'subprocess' module, from python 2.4; I would suggest that it be shipped with scons and installed if python version < 2.4, since it is only a single .py, and "appears" to not use any python 2.x language features, but of course I didn't test.

issues@scons said at 2006-02-12 09:11:26

Converted from SourceForge tracker item 1430183

stevenknight said at 2006-05-26 04:31:51 Created an attachment (id=44)

Patch, copied from SourceForge tracker.

matigruca said at 2008-07-18 02:38:22

This enhancement proposal becomes a part of my GSoC 2008 project. Gary, thanks for bringing it up!

matigruca said at 2008-07-27 06:47:56

Hi,

as you may have noticed, I have added CheckPython and CheckPythonHeaders methods to SConf.py module[1].

The next step would be to add CheckPythonModule method. I actually have it working already (not committed yet), but I am not sure if it could be useful. The purpose of CheckPythonModule is to check if a given python module is importable using the python executable found by CheckPython method.

Example SConstruct file:

env = Environment()
conf = Configure(env)
if conf.CheckPython((2,2,2)):
   if not conf.CheckPythonModule('mechanize'):
       print "Module 'mechanize' not found"
       Exit(1)
else:
   print 'Python 2.2.2 or higher must be installed'
   Exit(1)
   conf.Finish()

The question is: would you like to see it in SCons?

I was also wondering about adding a possibility to check for the version number of given module, but the way version numbers are presented is not unified in any way (and what's more, some modules don't even have the __version__ attribute).

[1] - https://github.com/SCons/scons/wiki/CheckPython

gregnoel said at 2008-08-05 06:24:52

GSoC issues should be assigned to the 'anytime' milestone, since they are outside the normal release cycle.

dirkbaechle said at 2014-05-04 10:11:25

reassign

stevenknight attached SCons-CheckPython.diff at 2008-03-25 11:08:15.

Patch, copied from SourceForge tracker.

bdbaddog avatar Jan 02 '18 09:01 bdbaddog

Does this fill a distinctly different need than EnsurePythonVersion?

mwichmann avatar May 01 '21 17:05 mwichmann

Does this fill a distinctly different need than EnsurePythonVersion?

I think so. EnsurePythonVersion() would bail out SCons, but the check's would let you do different things with your build depending on what they check?

bdbaddog avatar May 01 '21 17:05 bdbaddog