Skip to content

Commit

Permalink
Fixed bootstrap.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Guenther committed Jan 7, 2015
1 parent 687c2c8 commit fbf004c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 48 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ before_install:
- sudo apt-get update -qq
- sudo apt-get install --force-yes libboost-all-dev libblitz1-dev libatlas-dev libatlas-base-dev liblapack-dev libhdf5-serial-dev texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
- if [ -n "${NUMPYSPEC}" ]; then sudo apt-get install -qq gfortran; fi
- if [ -n "${NUMPYSPEC}" ]; then pip install --upgrade pip setuptools; fi
- if [ -n "${NUMPYSPEC}" ]; then pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel numpy$NUMPYSPEC; fi
- pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel matplotlib==1.3.0 sphinx nose==1.3.0 jinja2==2.6 pygments==1.6 setuptools==7.0
- pip install cpp-coveralls
- pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel matplotlib==1.3.0 sphinx nose==1.3.0 jinja2==2.6 pygments==1.6 cpp-coveralls
install:
- python bootstrap.py
- python bootstrap-buildout.py
- CFLAGS=-coverage ./bin/buildout
script:
- ./bin/python -c 'from bob.measure import get_config; print(get_config())'
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include LICENSE README.rst bootstrap.py buildout.cfg requirements.txt version.txt
include LICENSE README.rst bootstrap-buildout.py buildout.cfg requirements.txt version.txt
recursive-include doc conf.py *.rst
recursive-include bob *.h *.cpp
recursive-include bob/measure/data *.*
91 changes: 48 additions & 43 deletions bootstrap.py → bootstrap-buildout.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,54 @@
"file to be used."))
parser.add_option("-f", "--find-links",
help=("Specify a URL to search for buildout releases"))
parser.add_option("--allow-site-packages",
action="store_true", default=False,
help=("Let bootstrap.py use existing site packages"))
parser.add_option("--setuptools-version",
help="use a specific setuptools version")


options, args = parser.parse_args()

######################################################################
# load/install setuptools

to_reload = False
try:
import pkg_resources
import setuptools
if options.allow_site_packages:
import setuptools
import pkg_resources
from urllib.request import urlopen
except ImportError:
ez = {}

try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen

# XXX use a more permanent ez_setup.py URL when available.
exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py'
).read(), ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0)
ez['use_setuptools'](**setup_args)

if to_reload:
reload(pkg_resources)
import pkg_resources
# This does not (always?) update the default working set. We will
# do it.
for path in sys.path:
if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path)
from urllib2 import urlopen

######################################################################
# Try to best guess the version of buildout given setuptools
if options.version is None:

try:
from distutils.version import LooseVersion
package = pkg_resources.require('setuptools')[0]
v = LooseVersion(package.version)
if v < LooseVersion('0.7'):
options.version = '2.1.1'
except:
pass
ez = {}
exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)

if not options.allow_site_packages:
# ez_setup imports site, which adds site packages
# this will remove them from the path to ensure that incompatible versions
# of setuptools are not in the path
import site
# inside a virtualenv, there is no 'getsitepackages'.
# We can't remove these reliably
if hasattr(site, 'getsitepackages'):
for sitepackage_path in site.getsitepackages():
sys.path[:] = [x for x in sys.path if sitepackage_path not in x]

setup_args = dict(to_dir=tmpeggs, download_delay=0)

if options.setuptools_version is not None:
setup_args['version'] = options.setuptools_version

ez['use_setuptools'](**setup_args)
import setuptools
import pkg_resources

# This does not (always?) update the default working set. We will
# do it.
for path in sys.path:
if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path)

######################################################################
# Install buildout
Expand Down Expand Up @@ -132,10 +134,15 @@
_final_parts = '*final-', '*final'

def _final_version(parsed_version):
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
try:
return not parsed_version.is_prerelease
except AttributeError:
# Older setuptools
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True

index = setuptools.package_index.PackageIndex(
search_path=[setuptools_path])
if find_links:
Expand All @@ -162,8 +169,7 @@ def _final_version(parsed_version):
import subprocess
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
raise Exception(
"Failed to execute command:\n%s",
repr(cmd)[1:-1])
"Failed to execute command:\n%s" % repr(cmd)[1:-1])

######################################################################
# Import and run buildout
Expand All @@ -181,4 +187,3 @@ def _final_version(parsed_version):

zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)

0 comments on commit fbf004c

Please sign in to comment.