Skip to content

Commit

Permalink
Upgrade bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
datakurre committed Nov 11, 2014
1 parent e7c2d35 commit 2b4eb9d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 29 deletions.
60 changes: 34 additions & 26 deletions bootstrap.py
Expand Up @@ -56,39 +56,48 @@
"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"))


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

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)
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 @@ -149,8 +158,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 Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -38,7 +38,6 @@
'decorator', # required by r.selenium2library on Python 2.6.x
'five.globalrequest',
'plone.app.testing',
'plone.namedfile [blobs]',
'plone.testing',
'plone.uuid',
'robotframework',
Expand Down
8 changes: 8 additions & 0 deletions src/plone/app/robotframework/config.py
Expand Up @@ -16,3 +16,11 @@
HAS_DEXTERITY_RELATIONS = False
else:
HAS_DEXTERITY_RELATIONS = True


try:
pkg_resources.get_distribution('z3c.blobfile')
except pkg_resources.DistributionNotFound:
HAS_BLOBS = False
else:
HAS_BLOBS = True
10 changes: 8 additions & 2 deletions src/plone/app/robotframework/content.py
Expand Up @@ -10,11 +10,10 @@

from plone.app.robotframework.config import HAS_DEXTERITY
from plone.app.robotframework.config import HAS_DEXTERITY_RELATIONS
from plone.app.robotframework.config import HAS_BLOBS

if HAS_DEXTERITY:
from plone.app.textfield.value import RichTextValue
from plone.namedfile.file import NamedBlobFile
from plone.namedfile.file import NamedBlobImage

from plone.dexterity.utils import getAdditionalSchemata
from z3c.form.interfaces import IDataConverter
Expand All @@ -24,6 +23,13 @@
from zope.globalrequest import getRequest
from zope.schema.interfaces import IFromUnicode

if HAS_BLOBS:
from plone.namedfile.file import NamedBlobFile
from plone.namedfile.file import NamedBlobImage
else:
from plone.namedfile.file import NamedFile as NamedBlobFile
from plone.namedfile.file import NamedImage as NamedBlobFile

if HAS_DEXTERITY_RELATIONS:
from zope.intid.interfaces import IIntIds
from z3c.relationfield import RelationValue
Expand Down

0 comments on commit 2b4eb9d

Please sign in to comment.