Commit bf24783c authored by André Anjos's avatar André Anjos 💬

Remove bootstrap from this package

parent 0b8215d4
Pipeline #7760 passed with stages
in 13 minutes and 53 seconds
include LICENSE README.rst bootstrap-buildout.py buildout.cfg version.txt
include LICENSE README.rst buildout.cfg version.txt
recursive-include doc conf.py *.rst
recursive-include bob *.cpp *.h
recursive-include bob/extension/data *.tar.bz2
......@@ -26,10 +26,9 @@ Installation
------------
Follow our `installation`_ instructions. Then, using the Python interpreter
inside that distribution, bootstrap and buildout this package::
provided by the distribution, build this package with::
$ python bootstrap-buildout.py
$ ./bin/buildout
$ buildout
Contact
......
......@@ -190,12 +190,6 @@ def main(command_line_options = None):
else:
raise ValueError("The stable version '%s' cannot be smaller than the current version '%s'" % (args.stable_version, current_version))
if not os.path.exists('./bin/buildout'):
if args.force or args.no_buildout:
logger.warn("The bin/buildout script does not exist. Have you bootstrapped your system?")
else:
raise IOError("The bin/buildout script does not exist. Have you bootstrapped your system?")
if 'tag' in args.steps:
if args.stable_version is not None and Version(args.stable_version) > Version(current_version):
......@@ -214,7 +208,7 @@ def main(command_line_options = None):
if 'build' in args.steps:
if not args.no_buildout:
print ("\nBuilding the package")
run_commands(None, ['./bin/buildout'] + args.build_options)
run_commands(None, ['buildout'] + args.build_options)
if args.no_buildout:
if sys.executable:
......
......@@ -31,15 +31,11 @@ def _run(package, run_call):
with tarfile.open(tarball) as tar: tar.extractall(temp_dir)
package_dir = os.path.join(temp_dir, "bob.example.%s" % package)
# bootstrap
subprocess.call([sys.executable, "bootstrap-buildout.py"], cwd=package_dir)
assert os.path.exists(os.path.join(package_dir, "bin", "buildout"))
# buildout
# if we have a setup.py in our current directory, we develop both (as we might be in the current source directory of bob.extension and use it),
# otherwise we only develop the downloaded source package
develop = '%s\n.'%os.getcwd() if os.path.exists("setup.py") else '.'
subprocess.call(['./bin/buildout', 'buildout:prefer-final=false', 'buildout:develop=%s'%develop], cwd=package_dir)
subprocess.call(['buildout', 'buildout:prefer-final=false', 'buildout:develop=%s'%develop], cwd=package_dir)
assert os.path.exists(os.path.join(package_dir, "bin", "python"))
# nosetests
......
##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
"""
import os
import shutil
import sys
import tempfile
from optparse import OptionParser
tmpeggs = tempfile.mkdtemp()
usage = '''\
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
Bootstraps a buildout-based project.
Simply run this script in a directory containing a buildout.cfg, using the
Python that you want bin/buildout to use.
Note that by using --find-links to point to local resources, you can keep
this script from going over the network.
'''
parser = OptionParser(usage=usage)
parser.add_option("-v", "--version", help="use a specific zc.buildout version")
parser.add_option("-t", "--accept-buildout-test-releases",
dest='accept_buildout_test_releases',
action="store_true", default=False,
help=("Normally, if you do not specify a --version, the "
"bootstrap script and buildout gets the newest "
"*final* versions of zc.buildout and its recipes and "
"extensions for you. If you use this flag, "
"bootstrap and buildout will get the newest releases "
"even if they are alphas or betas."))
parser.add_option("-c", "--config-file",
help=("Specify the path to the buildout configuration "
"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
try:
if options.allow_site_packages:
import setuptools
import pkg_resources
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
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
ws = pkg_resources.working_set
cmd = [sys.executable, '-c',
'from setuptools.command.easy_install import main; main()',
'-mZqNxd', tmpeggs]
find_links = os.environ.get(
'bootstrap-testing-find-links',
options.find_links or
('http://downloads.buildout.org/'
if options.accept_buildout_test_releases else None)
)
if find_links:
cmd.extend(['-f', find_links])
setuptools_path = ws.find(
pkg_resources.Requirement.parse('setuptools')).location
requirement = 'zc.buildout'
version = options.version
if version is None and not options.accept_buildout_test_releases:
# Figure out the most recent final version of zc.buildout.
import setuptools.package_index
_final_parts = '*final-', '*final'
def _final_version(parsed_version):
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:
index.add_find_links((find_links,))
req = pkg_resources.Requirement.parse(requirement)
if index.obtain(req) is not None:
best = []
bestv = None
for dist in index[req.project_name]:
distv = dist.parsed_version
if _final_version(distv):
if bestv is None or distv > bestv:
best = [dist]
bestv = distv
elif distv == bestv:
best.append(dist)
if best:
best.sort()
version = best[-1].version
if version:
requirement = '=='.join((requirement, version))
cmd.append(requirement)
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])
######################################################################
# Import and run buildout
ws.add_entry(tmpeggs)
ws.require(requirement)
import zc.buildout.buildout
if not [a for a in args if '=' not in a]:
args.append('bootstrap')
# if -c was provided, we push it back into args for buildout' main function
if options.config_file is not None:
args[0:0] = ['-c', options.config_file]
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
By far, the easiest and best supported installation method for Bob
packages uses `zc.buildout`_.
Using buildout requires you define a configuration file, normally named
``buildout.cfg``, which describes which packages are supposed to be
installed on the current environment. `Our custom buildout
extension <https://pypi.python.org/pypi/bob.buildout>`__ will hook-in
externally compiled software from that configuration file.
The key-idea is that for every project, you create a new environment that contains the
packages you need for the task. A project may be a product you are
working on or a research paper, for you which you will publish
reproducible results. Each environment will be isolated so there is low
risk of interference between your projects.
By far, the easiest and best supported installation method for Bob packages
uses `zc.buildout`_. Using buildout requires you define a configuration file,
normally named ``buildout.cfg``, which describes which packages are supposed to
be installed on the current environment. `Our custom buildout extension
<https://pypi.python.org/pypi/bob.buildout>`__ will hook-in externally compiled
software from that configuration file.
The key-idea is that for every project, you create a new environment that
contains the packages you need for the task. A project may be a product you are
working on or a research paper, for you which you will publish reproducible
results. Each environment will be isolated so there is low risk of interference
between your projects.
.. note::
......@@ -28,15 +27,8 @@ it:
$ mkdir exp01
$ cd exp01
Download a stock bootstrap script for ``zc.buildout``:
.. code:: sh
$ wget https://bootstrap.pypa.io/bootstrap-buildout.py
Create ``buildout.cfg`` file, in the same folder as
``bootstrap-buildout.py``. The contents will depend on which Bob
packages you would like to work with, but it generally looks like this:
Create ``buildout.cfg`` file. The contents will depend on which Bob packages
you would like to work with, but it generally looks like this:
.. code:: ini
......@@ -75,13 +67,12 @@ packages: ``bob.io.image`` and ``bob.learn.linear``. Dependencies for
those packages will be automatically managed, **as long as you keep**
``bob.buildout`` **in your list of** ``extensions``.
Now, bootstrap your new environment and instruct ``zc.buildout`` to
download and install packages (and dependencies) locally:
Now, instruct ``zc.buildout`` to download and install packages (and
dependencies) locally:
.. code:: sh
$ python bootstrap-buildout.py
$ ./bin/buildout
$ buildout
.. note::
......@@ -89,7 +80,7 @@ download and install packages (and dependencies) locally:
.. code:: sh
$ ./bin/buildout -c develop.cfg
$ buildout -c develop.cfg
That is it! Once the buildout finishes, all packages have been
downloaded and installed locally. Buildout will create a ``python``
......@@ -178,10 +169,9 @@ yourself.
.. note::
mr.developer will not update your sources if they are already
checkedout. If you change your sources and run ``./bin/buildout``
again, it will not update your sources. You have to do that
manually.
mr.developer will not update your sources if they are already checkedout.
If you change your sources and run ``buildout`` again, it will not update
your sources. You have to do that manually.
Order of packages in ``eggs`` and ``develop``
......
......@@ -139,13 +139,12 @@ Finally, the function ``reverse`` from the module ``_library`` is imported into
To compile your C++ Python bindings and the pure C++ libraries, you can follow the same instructions as shown above:
To compile your C++ Python bindings and the pure C++ libraries, you can follow
the same instructions as shown above:
.. code-block:: sh
$ python bootstrap-buildout.py
...
$ ./bin/buildout
$ buildout
...
.. note::
......@@ -273,9 +272,7 @@ As shown above, to compile your C++ Python bindings and the pure C++ libraries,
.. code-block:: sh
$ python bootstrap-buildout.py
...
$ ./bin/buildout
$ buildout
...
This will automatically check out all required ``bob_packages`` and compile them locally.
......@@ -286,9 +283,7 @@ To get the source code compiled using another build directory, you can define a
.. code-block:: sh
$ python bootstrap-buildout.py
...
$ BOB_BUILD_DIRECTORY=/tmp/build_bob ./bin/buildout
$ BOB_BUILD_DIRECTORY=/tmp/build_bob buildout
...
The C++ code of this package, **and the code of all other** ``bob_packages`` will be compiled using the selected directory.
......
......@@ -122,18 +122,12 @@ package, all of which is contained in the ``setup`` function:
In detail, it defines the name and the version of this package, which files belong to the package (those files are automatically collected by the ``find_packages`` function), other packages that we depend on, namespaces (see below) and console scripts.
The full set of options can be inspected in the `Setuptools documentation <https://setuptools.readthedocs.io>`_.
To be able to use the package, we first need to build it.
Here is how to go from nothing to everything:
To be able to use the package, we first need to build it. Here is how to go
from nothing to everything:
.. code-block:: sh
$ python bootstrap-buildout.py
Creating directory '/home/user/bob.example.project/bin'.
Creating directory '/home/user/bob.example.project/parts'.
Creating directory '/home/user/bob.example.project/eggs'.
Creating directory '/home/user/bob.example.project/develop-eggs'.
Generated script '/home/user/bob.example.project/bin/buildout'.
$ ./bin/buildout
$ buildout
Getting distribution for 'bob.buildout'.
Got bob.buildout 2.0.0.
Getting distribution for 'zc.recipe.egg>=2.0.0a3'.
......@@ -247,10 +241,11 @@ Again, ``mr.developer`` does not automatically place the packages into the ``dev
Running buildout
================
Finally, running buildout is a two-step process, which is detailed above.
The command line ``./bin/buildout`` will actually run buildout and build your local environment.
All options in the buildout.cfg can be overwritten on command line, by specifying ``buildout:option=...``, where ``option`` can be any entry in the ``buildout.cfg``.
Finally, buildout will perform the following steps:
Finally, running buildout is a single step process, which is detailed above.
The command line ``buildout`` will actually run buildout and build your local
environment. All options in the buildout.cfg can be overwritten on command
line, by specifying ``buildout:option=...``, where ``option`` can be any entry
in the ``buildout.cfg``. Finally, buildout will perform the following steps:
1. It checks out the packages that you specified using ``mr.developer``.
2. It develops all packages in the ``develop`` section.
......@@ -267,7 +262,7 @@ In our example, this is ``./bin/version.py``.
One thing to note in package development is that when you
change the entry points in ``setup.py`` of a package, you need to
run ``./bin/buildout`` again.
run ``buildout`` again.
Your local environment
======================
......
......@@ -31,10 +31,9 @@ Installation
------------
Follow our `installation`_ instructions. Then, using the Python interpreter
provided by the distribution, bootstrap and buildout this package::
provided by the distribution, build this package with::
$ python bootstrap-buildout.py
$ ./bin/buildout
$ buildout
Documentation and Further Information
......
##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
"""
import os
import shutil
import sys
import tempfile
from optparse import OptionParser
__version__ = '2015-07-01'
# See zc.buildout's changelog if this version is up to date.
tmpeggs = tempfile.mkdtemp(prefix='bootstrap-')
usage = '''\
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
Bootstraps a buildout-based project.
Simply run this script in a directory containing a buildout.cfg, using the
Python that you want bin/buildout to use.
Note that by using --find-links to point to local resources, you can keep
this script from going over the network.
'''
parser = OptionParser(usage=usage)
parser.add_option("--version",
action="store_true", default=False,
help=("Return bootstrap.py version."))
parser.add_option("-t", "--accept-buildout-test-releases",
dest='accept_buildout_test_releases',
action="store_true", default=False,
help=("Normally, if you do not specify a --version, the "
"bootstrap script and buildout gets the newest "
"*final* versions of zc.buildout and its recipes and "
"extensions for you. If you use this flag, "
"bootstrap and buildout will get the newest releases "
"even if they are alphas or betas."))
parser.add_option("-c", "--config-file",
help=("Specify the path to the buildout configuration "
"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("--buildout-version",
help="Use a specific zc.buildout version")
parser.add_option("--setuptools-version",
help="Use a specific setuptools version")
parser.add_option("--setuptools-to-dir",
help=("Allow for re-use of existing directory of "
"setuptools versions"))
options, args = parser.parse_args()
if options.version:
print("bootstrap.py version %s" % __version__)
sys.exit(0)
######################################################################
# load/install setuptools
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
ez = {}
if os.path.exists('ez_setup.py'):
exec(open('ez_setup.py').read(), ez)
else:
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():
# Strip all site-packages directories from sys.path that
# are not sys.prefix; this is because on Windows
# sys.prefix is a site-package directory.
if sitepackage_path != sys.prefix:
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
if options.setuptools_to_dir is not None:
setup_args['to_dir'] = options.setuptools_to_dir
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
ws = pkg_resources.working_set
setuptools_path = ws.find(
pkg_resources.Requirement.parse('setuptools')).location
# Fix sys.path here as easy_install.pth added before PYTHONPATH
cmd = [sys.executable, '-c',
'import sys; sys.path[0:0] = [%r]; ' % setuptools_path +
'from setuptools.command.easy_install import main; main()',
'-mZqNxd', tmpeggs]
find_links = os.environ.get(
'bootstrap-testing-find-links',
options.find_links or
('http://downloads.buildout.org/'
if options.accept_buildout_test_releases else None)
)
if find_links:
cmd.extend(['-f', find_links])
requirement = 'zc.buildout'
version = options.buildout_version
if version is None and not options.accept_buildout_test_releases:
# Figure out the most recent final version of zc.buildout.
import setuptools.package_index
_final_parts = '*final-', '*final'
def _final_version(parsed_version):
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:
index.add_find_links((find_links,))
req = pkg_resources.Requirement.parse(requirement)
if index.obtain(req) is not None:
best = []
bestv = None
for dist in index[req.project_name]:
distv = dist.parsed_version
if _final_version(distv):
if bestv is None or distv > bestv:
best = [dist]
bestv = distv
elif distv == bestv:
best.append(dist)
if best:
best.sort()
version = best[-1].version
if version:
requirement = '=='.join((requirement, version))
cmd.append(requirement)
import subprocess
if subprocess.call(cmd) != 0:
raise Exception(
"Failed to execute command:\n%s" % repr(cmd)[1:-1])
######################################################################
# Import and run buildout
ws.add_entry(tmpeggs)
ws.require(requirement)
import zc.buildout.buildout
if not [a for a in args if '=' not in a]:
args.append('bootstrap')
# if -c was provided, we push it back into args for buildout' main function
if options.config_file is not None:
args[0:0] = ['-c', options.config_file]
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
......@@ -31,10 +31,9 @@ Installation
------------
Follow our `installation`_ instructions. Then, using the Python interpreter
provided by the distribution, bootstrap and buildout this package::
provided by the distribution, buildout this package::
$ python bootstrap-buildout.py
$ ./bin/buildout
$ buildout
Documentation and Further Information
......
......@@ -31,10 +31,9 @@ Installation
------------
Follow our `installation`_ instructions. Then, using the Python interpreter
provided by the distribution, bootstrap and buildout this package::
provided by the distribution, build this package with::
$ python bootstrap-buildout.py
$ ./bin/buildout
$ buildout
Documentation and Further Information
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment