Skip to content

Commit

Permalink
part 2 of the tutorial, fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
toumorokoshi committed Jan 18, 2015
1 parent 860ee46 commit 9beffd7
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 15 deletions.
30 changes: 29 additions & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,32 @@ This is all you need to run warmup. Let's run them now:

And congrats, you've had your first Uranium run! Of course, all this
did was run virtualend and install Uranium. Now let's get some real
functionality done.
functionality.

------------------------------
Developing and Installing Eggs
------------------------------

We started with a blank Uranium file. To add eggs and develop-eggs,
you can add a couple new section to the uranium file:

.. code-block:: yaml
# this is the uranium.yaml from the first part
develop-eggs:
- .
eggs:
nose: ==1.3.4
And let's run uranium again. Now that you've 'warmed up', you don't have to run
warmup again, instead, you can run:

$ ./bin/uranium

You should see:

WARNING: Unable to install develop egg at /tmp/uranium-tut: Directory '/tmp/uranium-tut' is not installable

This is because we don't have any egg source in the current
directory. If you did this in such a directory, you would notice the
egg was installed for you.
6 changes: 5 additions & 1 deletion notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ Uranium needs to work in a variety of situations, so testing is key. Ultimately

# Known issues

* fix recursive value referencing
* uranium version conflicts.
* the uranium package currently lives in it's own sandbox, so
version conflicts between uranium's requirements and the users
will conflict.
* We should maybe sandbox Uranium's own depedencies


# Potential Problems
Expand Down
16 changes: 8 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from distutils.core import setup

install_requires = [
'docopt>=0.6.2',
'jinja2',
'pip>=6',
'pyyaml',
'requests',
'six',
'virtualenv>=1.11.6',
'docopt==0.6.2',
'jinja2==2.7.3',
'pip==6.0.6',
'pyyaml==3.11',
'requests==2.5.1',
'six==1.9.0',
'virtualenv==12.0.5',
'zc.buildout'
]

Expand All @@ -22,7 +22,7 @@
]

setup(name='uranium',
version='0.0.24',
version='0.0.25',
description='a build system for python',
long_description='a build system for python',
author='Yusuke Tsutsumi',
Expand Down
17 changes: 13 additions & 4 deletions uranium/pip_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import os
import logging
from pip.index import PackageFinder
from pip.req import InstallRequirement
from pip.locations import build_prefix, src_prefix
from pip.exceptions import DistributionNotFound
from pip.exceptions import DistributionNotFound, InstallationError
from pip.download import PipSession
from .req_set import UraniumRequirementSet
from uranium.utils import log_exception

DEFAULT_INDEX_URLS = ['https://pypi.python.org/simple/']
LOGGER = logging.getLogger(__name__)


class PipException(Exception):
Expand Down Expand Up @@ -43,11 +46,17 @@ def add_eggs(self, egg_name_list):
self._requirement_set.add_requirement(egg_requirement)

def add_develop_eggs(self, develop_egg_list):
errors = []
for egg_path in develop_egg_list:
egg_path = _expand_dir(egg_path)
egg_requirement = InstallRequirement.from_editable(egg_path)
self._requirement_set.add_requirement(egg_requirement)
self._develop_egg_original_paths[egg_path] = egg_requirement
try:
egg_requirement = InstallRequirement.from_editable(egg_path)
self._requirement_set.add_requirement(egg_requirement)
self._develop_egg_original_paths[egg_path] = egg_requirement
except InstallationError as e:
log_exception(LOGGER, logging.DEBUG)
errors.append((egg_path, str(e)))
return errors

def install(self):
try:
Expand Down
16 changes: 16 additions & 0 deletions uranium/tests/test_pip_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from uranium.pip_manager import PipManager
from nose.tools import eq_


class TestPipManager(object):

def setUp(self):
self.pip = PipManager()

def test_nonexistent_develop_egg(self):
"""
if there is an exception installing a develop egg,
warn instead of raise an exception
"""
errors = self.pip.add_develop_eggs(['./gibberish'])
eq_(len(errors), 1)
7 changes: 6 additions & 1 deletion uranium/uranium.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ def _create_bin_directory(self):
def _install_eggs(self):
develop_eggs = self._config.get('develop-eggs')
if develop_eggs:
self._pip.add_develop_eggs(develop_eggs)
errors = self._pip.add_develop_eggs(develop_eggs)
for egg_path, error in errors:
msg = "WARNING: Unable to install develop egg at {0}: {1}".format(
egg_path, error
)
LOGGER.warning(msg)
# for some reason install can only be run once
# it seems to be related to the packages being installed,
# then attempting to install them again with the same
Expand Down
10 changes: 10 additions & 0 deletions uranium/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import traceback


def log_exception(logger, level):
"""
log an exception at a specific level
this should be called during exception handling.
"""
logger.log(level, traceback.format_exc())

0 comments on commit 9beffd7

Please sign in to comment.