Skip to content

Instantly share code, notes, and snippets.

@Ivoz

Ivoz/repro-3.sh

Created May 13, 2014
Embed
What would you like to do?
bash script to reproduce https://github.com/pypa/pip/issues/3
#!/usr/bin/bash
# Reproduce namespace / editable install problem with pip
# https://github.com/pypa/pip/issues/3
# cleanup from previous invocations
foos=('foo-main' 'foo-client' 'foo-env')
rm -rf -- "${foos[@]}"
echo "Creating foo package..."
mkdir -p foo-main/foo
echo "__import__('pkg_resources').declare_namespace('foo')" > foo-main/foo/__init__.py
echo "
def thing():
return 'hello!'
" > foo-main/foo/run.py
echo "
from setuptools import setup, find_packages
setup(name='foo',
version='0.1.0',
author='PyPA',
author_email='pypa@pypa.pypa',
url='https://github.com/pypa',
license='MIT',
packages=find_packages(),
namespace_packages=['foo'],
zip_safe=False,
)
" > foo-main/setup.py
echo "Creating foo.client package..."
mkdir -p foo-client/foo/client
echo "__import__('pkg_resources').declare_namespace('foo')" > foo-client/foo/__init__.py
touch foo-client/foo/client/__init__.py
echo "
from foo.run import thing
def test():
print(thing())
" > foo-client/foo/client/bar.py
echo "
from setuptools import setup, find_packages
setup(name='foo.client',
version='0.1.0',
author='PyPA',
author_email='pypa@pypa.pypa',
url='https://github.com/pypa',
license='MIT',
packages=find_packages(),
namespace_packages=['foo'],
zip_safe=False,
)
" > foo-client/setup.py
echo "Creating virtualenv test environment..."
virtualenv -ppython2 foo-env
echo "Installing foo with pip normally..."
foo-env/bin/pip install ./foo-main/
echo "Installing foo.client with pip in development..."
foo-env/bin/pip install -e ./foo-client/
echo "running 'from foo.client import bar; bar.test()'..."
foo-env/bin/python -c "from foo.client import bar; bar.test()"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment