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

Get tests working on Windows, fix issue #11 #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/buildout/wheel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


orig_distros_for_location = setuptools.package_index.distros_for_location
orig_distros_for_filename = setuptools.package_index.distros_for_filename


def unpack_wheel(spec, dest):
Expand Down Expand Up @@ -136,8 +137,25 @@ def distros_for_location(location, basename, metadata=None):
return orig_distros_for_location(location, basename, metadata=metadata)


def distros_for_filename(filename, metadata=None):
"""Yield possible egg or source distribution objects based on a filename

Here we override setuptools to *not* call pkg_resources.normalize_path on
filename because we need to preserve case on case-sensitive systems
(Windows).
"""
basename = os.path.basename(filename)
if basename.endswith('.whl'):
return distros_for_location(
os.path.realpath(filename), os.path.basename(filename), metadata
)
else:
return orig_distros_for_filename(filename, metadata)


def load(buildout):
setuptools.package_index.distros_for_location = distros_for_location
setuptools.package_index.distros_for_filename = distros_for_filename
buildout.old_unpack_wheel = zc.buildout.easy_install.UNPACKERS.get('.whl')
zc.buildout.easy_install.UNPACKERS['.whl'] = unpack_wheel
logger.debug('Patched in wheel support')
Expand All @@ -147,3 +165,4 @@ def unload(buildout):
if buildout.old_unpack_wheel is not None:
zc.buildout.easy_install.UNPACKERS['.whl'] = buildout.old_unpack_wheel
setuptools.package_index.distros_for_location = orig_distros_for_location
setuptools.package_index.distros_for_filename = orig_distros_for_filename
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

setup(name='demo',
setup(name='Demo',
version = '1.0',
py_modules=['demo'],
py_modules=['Demo'],
)
4 changes: 2 additions & 2 deletions src/buildout/wheel/tests/samples/getvals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import demo, extdemo
import Demo, extdemo
with open('vals', 'w') as f:
f.write("%s %s" % (demo.value, extdemo.val))
f.write("%s %s" % (Demo.value, extdemo.val))
33 changes: 20 additions & 13 deletions src/buildout/wheel/tests/testwheel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gc
import os
import shutil
import sys
Expand All @@ -20,9 +21,20 @@ def globs(self):

def setUp(self):
self.here = os.path.dirname(__file__)
self.fake_buildout = None
zc.buildout.testing.buildoutSetUp(self)

def tearDown(self):
if self.fake_buildout:
pkg_resources.load_entry_point(
'buildout.wheel', 'zc.buildout.unloadextension', 'wheel'
)(self.fake_buildout)

# For Windows, have to force gc to close handle on '.whl' file
# prior to the rmtree done by buildoutTearDown
self.fake_buildout = None
gc.collect()

zc.buildout.testing.buildoutTearDown(self)
os.chdir(self.here)

Expand All @@ -33,35 +45,30 @@ def test_install_wheels(self):
shutil.copytree(join(self.here, 'samples'), join(build, 'samples'))
ws = zc.buildout.easy_install.install(
['setuptools', 'wheel'], None, check_picked=False, path=sys.path)
[py] = zc.buildout.easy_install.scripts(
py = zc.buildout.easy_install.scripts(
[], ws, sys.executable, dest=build, interpreter='py')
os.chdir(join(build, 'samples', 'demo'))
os.chdir(join(build, 'samples', 'Demo'))
zc.buildout.easy_install.call_subprocess(
[py, 'setup.py', 'bdist_wheel', '-d', eggs])
py + ['setup.py', 'bdist_wheel', '-d', eggs])
os.chdir(join('..', 'extdemo'))
zc.buildout.easy_install.call_subprocess(
[py, 'setup.py', 'bdist_wheel', '-d', eggs])
py + ['setup.py', 'bdist_wheel', '-d', eggs])
os.chdir(join('..'))

buildout = Buildout()
pkg_resources.load_entry_point(
'buildout.wheel', 'zc.buildout.extension', 'wheel')(buildout)

@self.register_teardown
def unload():
pkg_resources.load_entry_point(
'buildout.wheel', 'zc.buildout.unloadextension', 'wheel'
)(buildout)
self.fake_buildout = buildout

ws = zc.buildout.easy_install.install(
['demo', 'extdemo'],
['Demo', 'extdemo'],
join(self.sample_buildout, 'eggs'),
index=eggs,
check_picked=False,
path=sys.path)
[py] = zc.buildout.easy_install.scripts(
py = zc.buildout.easy_install.scripts(
[], ws, sys.executable, dest=join(self.sample_buildout, 'bin'),
interpreter='py')
zc.buildout.easy_install.call_subprocess([py, 'getvals.py'])
zc.buildout.easy_install.call_subprocess(py + ['getvals.py'])
with open('vals') as f:
self.assertEqual('1 42', f.read())