Skip to content

Commit

Permalink
Merge pull request #318 from learningequality/mmvp
Browse files Browse the repository at this point in the history
Mmvp to master
  • Loading branch information
jamalex authored Aug 1, 2016
2 parents 7fc73f8 + a46c232 commit e964a5e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 84 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test:
test-all:
tox

assets:
assets: staticdeps
npm run build

coverage:
Expand All @@ -59,7 +59,12 @@ release: clean assets
python setup.py sdist upload
python setup.py bdist_wheel upload

sdist: clean assets
staticdeps: clean
pip install -t kolibri/dist/ -r requirements.txt

dist: staticdeps assets
pip install -r requirements/build.txt
python setup.py sdist
python setup.py bdist_wheel
pex . --disable-cache -o dist/`python setup.py --fullname`.pex -m kolibri --python-shebang=/usr/bin/python
ls -l dist
2 changes: 1 addition & 1 deletion docs/dev/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Make targets
------------

To build both the slim Kolibri and the one with bundled dependencies, simply
run `make sdist`. The `.whl` files will now be available in `dist/*whl` and
run `make dist`. The `.whl` files will now be available in `dist/*whl` and
you can install them with `pip install dist/filename.whl`.

Automated CI tests
Expand Down
4 changes: 1 addition & 3 deletions kolibri/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
from kolibri import dist as kolibri_dist # noqa

# Setup path in case we are running with dependencies bundled into Kolibri
sys.path.append(
os.path.realpath(os.path.dirname(kolibri_dist.__file__))
)
sys.path = [os.path.realpath(os.path.dirname(kolibri_dist.__file__))] + sys.path

import django # noqa
import importlib # noqa
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[pytest]
testpaths = test/ kolibri/
DJANGO_SETTINGS_MODULE = kolibri.deployment.default.settings.test
norecursedirs = dist tmp* .svn .*
11 changes: 9 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Base requirements are empty. All of our minimum requirements are specified in setup.py's install_requires variable!
-e .
django-filter==0.13.0
django-js-reverse==0.7.2
six==1.10.0
djangorestframework==3.3.3
django==1.9.7
colorlog==2.6.0
docopt==0.6.2
django-mptt==0.8.5
https://github.com/cherrypy/cherrypy/archive/v6.2.0.zip
1 change: 1 addition & 0 deletions requirements/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# include base.txt
sphinx
sphinx-rtd-theme
pex
77 changes: 3 additions & 74 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def read_file(fname):
return open(fname).read().decode("utf-8")
return open(fname).read()

dist_name = 'kolibri'
dist_name = 'kolibri-static'

readme = read_file('README.rst')
doclink = """
Expand Down Expand Up @@ -53,21 +53,9 @@ def read_file(fname):
static_requirements = []
static_dir = os.path.dirname(os.path.realpath(kolibri_dist.__file__))

install_requires = [
'cherrypy==6.0.2',
'django-filter==0.13.0',
'django-js-reverse==0.7.2',
'six==1.10.0',
'djangorestframework==3.3.3',
'django==1.9.7',
'colorlog==2.6.0',
'docopt==0.6.2',
'django-mptt>=0.8.4', # apparently you also need to have the dependency_links packages be included in install_requires
]
install_requires = []

dependency_links = [
'http://github.com/django-mptt/django-mptt/tarball/9e131f91#egg=django-mptt-0.8.4'
]
dependency_links = []

# Check if user supplied the special '--static' option
if '--static' in sys.argv:
Expand Down Expand Up @@ -150,65 +138,6 @@ def enable_log_to_stdout(logname):
# add ch to logger
log.addHandler(ch)


# If it's a static build, we invoke pip to bundle dependencies in python-packages
# This would be the case for commands "bdist" and "sdist"
if static_requirements and is_building_dist:

sys.stderr.write(
"This is a static build... invoking pip to put static dependencies in "
"dist-packages/\n\n"
"Requirements:\n\n" + "\n".join(static_requirements)
)

current_dir = os.path.dirname(os.path.realpath(__file__))
static_cache_dir = os.path.join(current_dir, 'dist-packages-cache')
static_temp_dir = os.path.join(current_dir, 'dist-packages-temp')

# Create directory where dynamically created dependencies are put
if not os.path.exists(static_cache_dir):
os.mkdir(static_cache_dir)

# Should remove the temporary directory always
if os.path.exists(static_temp_dir):
sys.stderr.write("Removing previous temporary sources for pip {}".format(static_temp_dir))
shutil.rmtree(static_temp_dir)

# Install from pip

# Code modified from this example:
# http://threebean.org/blog/2011/06/06/installing-from-pip-inside-python-or-a-simple-pip-api/
import pip.commands.install

# Ensure we get output from pip
enable_log_to_stdout('pip.commands.install')

def install_distributions(distributions):
command = pip.commands.install.InstallCommand()
opts, ___ = command.parser.parse_args([])
opts.target_dir = static_dir
opts.build_dir = static_temp_dir
opts.download_cache = static_cache_dir
opts.isolated = True
opts.compile = False
opts.ignore_dependencies = True
# opts.use_wheel = False
opts.no_clean = False
command.run(opts, distributions)
# requirement_set.source_dir = STATIC_DIST_PACKAGES_TEMP
# requirement_set.install(opts)

install_distributions(static_requirements)

elif is_building_dist:

if len(os.listdir(static_dir)) > 3:
raise RuntimeError(
"Please empty {} - make clean!".format(
static_dir
)
)

setup(
name=dist_name,
version=kolibri.__version__,
Expand Down
5 changes: 3 additions & 2 deletions test/conditional/test_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ cd "$DIR/../../"

# Install build deps
pip install -r requirements/build.txt
pip install -r requirements/test.txt

# Build .whl
npm install
make sdist
pip install dist/kolibri-*.whl
make dist
pip install dist/kolibri*.whl

cd "$PREVIOUS_CWD"

Expand Down

0 comments on commit e964a5e

Please sign in to comment.