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

don't rely on distutils.sysconfig directly to determine Python lib dir #156

Merged
merged 10 commits into from Mar 28, 2013
16 changes: 13 additions & 3 deletions easybuild/easyblocks/generic/pythonpackage.py
Expand Up @@ -31,7 +31,6 @@
@author: Pieter De Baets (Ghent University)
@author: Jens Timmerman (Ghent University)
"""
import distutils.sysconfig
import os
import tempfile
from os.path import expanduser
Expand Down Expand Up @@ -69,7 +68,7 @@ def __init__(self, *args, **kwargs):
self.unpack_options = ''

self.python = None
self.pylibdir = distutils.sysconfig.get_python_lib(prefix='')
self.pylibdir = None

# make sure there's no site.cfg in $HOME, because setup.py will find it and use it
if os.path.exists(os.path.join(expanduser('~'), 'site.cfg')):
Expand All @@ -78,13 +77,24 @@ def __init__(self, *args, **kwargs):
if not 'modulename' in self.options:
self.options['modulename'] = self.name.lower()

def prepare_step(self):
"""Prepare by determining Python site lib dir."""

# we can't simply import distutils.sysconfig, because then we would be talking to the system Python
cmd = ' '.join(['python -c "',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you think it helps readability, being the dict one line below (as we do in other dictionary items);
other than that, I have no more remarks, at least from a visual check of the code. It seems like a code factorization effort, good.

'import os;',
'import distutils.sysconfig;',
'print os.path.join(*distutils.sysconfig.get_python_lib().split(os.sep)[-3:]);',
'"',
])
(self.pylibdir, _) = run_cmd(cmd, simple=False)

def configure_step(self):
"""Configure Python package build."""

self.python = get_software_root('Python')
if not self.python:
self.log.error('Python module not loaded.')

self.log.debug("Python library dir: %s" % self.pylibdir)

if self.sitecfg is not None:
Expand Down
4 changes: 1 addition & 3 deletions easybuild/easyblocks/n/neuron.py
Expand Up @@ -27,7 +27,6 @@

@author: Kenneth Hoste (Ghent University)
"""
import distutils.sysconfig
import os
import re

Expand Down Expand Up @@ -197,9 +196,8 @@ def make_module_req_guess(self):
})

if self.with_python:
pylibdir = distutils.sysconfig.get_python_lib(prefix='')
guesses.update({
'PYTHONPATH': [pylibdir],
'PYTHONPATH': [self.pylibdir],
})

return guesses
Expand Down
8 changes: 0 additions & 8 deletions easybuild/easyblocks/p/python_meep.py
Expand Up @@ -31,7 +31,6 @@
@author: Pieter De Baets (Ghent University)
@author: Jens Timmerman (Ghent University)
"""
import distutils.sysconfig
import glob
import os
import shutil
Expand All @@ -47,13 +46,6 @@ class EB_python_minus_meep(EasyBlock):
Support for building and installing python-meep
"""

def __init__(self, *args, **kwargs):
"""Initialize custom variables."""
super(EB_python_minus_meep, self).__init__(*args, **kwargs)

# template for Python packages lib dir
self.pylibdir = distutils.sysconfig.get_python_lib(prefix='')

def configure_step(self):
"""Just check whether dependencies (Meep, Python) are available."""

Expand Down