Skip to content

Replace eggs with wheels#428

Merged
dannon merged 56 commits intogalaxyproject:devfrom
natefoo:smash_eggs
Oct 22, 2015
Merged

Replace eggs with wheels#428
dannon merged 56 commits intogalaxyproject:devfrom
natefoo:smash_eggs

Conversation

@natefoo
Copy link
Member

@natefoo natefoo commented Jul 5, 2015

Smash Eggs

More importantly, replace all of our custom egg installation code with a very slightly modified version of pip. The modification is necessary if/until wheel is updated to include support for Linux wheels.

Other changes include

  • Removal of the awful lib/pkg_resources.py
  • Relocated the bit of eggs code that checked the Galaxy config to determine what dependencies are needed to a wheels module.
  • galaxyproject/docker-build has been updated with scripts and images to support building wheels for distribution on 32 and 64 bit Linux.

On virtualenvs

scripts/common_startup.sh will create a virtualenv at $galaxy_root/.venv if one is not already active and wheels will be installed to here. Otherwise, Galaxy will use whatever virtualenv is currently active (in $VIRTUAL_ENV).

Whatever virtualenv Galaxy is started under will be passed to jobs if a virtualenv is not already active in the job environment (and it exists at the same path on the compute resource). You can force jobs to use a different virtualenv using the <env> tag in a job destination, e.g.:

<destination id="foo">
    <env file="/path/to/venv/bin/activate"/>
</destination>

Galaxy needs to become installable in the traditional python setup.py install manner which will change some things about how virtualenvs are handled in the future (tl;dr, we don't need to "handle" them all unless you are running directly from source), but that is the next project. This was all recently done for Pulsar so Galaxy can steal from there. =)

TODO

  • Replace distribute in bx-python with setuptools.
  • Figure out how to build OS X wheels for distribution.
  • Remove all eggs imports and eggs require()s
  • Get rid of the SVGFig dependency
  • Do not attempt to install all dependencies every time (determine what's missing and attempt to install those).
  • Fail to start if a virtualenv does not exist and cannot be created.
  • Figure out how to support modified packages (Whoosh, sqlalchemy-migrate). pip install git+https:// works, but then it's a little trickier to correctly answer "Is sqlalchemy-migrate installed, and is it the right version?"
  • Build and host wheels for everything that does not already have them (and possibly even the stuff already in PyPI). We should provide wheels for anything that does not provide them, possibly even for pure-python modules since it'll still be faster to install a wheel even though there is no C compilation involved.
  • Figure out how to build psycopg2 and MySQL_Python (anyone using MySQL can just pip install MySQL-python (which common-startup.sh will in fact attempt to do)
  • The pysam wheel is broken: ImportError: /home/nate/galaxy/galaxy/.venv/local/lib/python2.7/site-packages/pysam/calignmentfile.so: undefined symbol: hts_idx_load_literal
  • The bx wheel is broken (possibly due to being built w/o numpy installed?): ImportError: No module named bigbed_file
  • Test drmaa and pbs runners
  • Create an sdist for everything on wheels.galaxyproject.org
  • Test and document creating (or sharing) a venv w/ necessary wheels when running on the cluster
  • Build remaining OS X wheels
  • When using run.sh, ignore whatever virtualenv is active and use .venv. If you want to use something else, either start without run.sh or use run.sh --skip-venv. In the future, we won't mess with venvs at all since Galaxy should install in the standard Pythonic way.
  • Merge updated SOABI code from SOABI support for Python 2.X and PyPy pypa/pip#3075 into natefoo/pip linux-wheels branch

Questions

  • Should we pin exact versions of dependencies? I have a strong preference to say no, and as a concession say we should pin to "less than the next major version" e.g. SQLAlchemy<1.1. Although this does present one small problem - we will have to ensure that we always have wheels built for every version published on PyPI (we can certainly automate this) or else pip will bypass the wheels and install from source, unless we use pip install --only-binary. However, if we use --only-binary, then we cannot trivially fall back to compiling from source on platforms that we do not have wheels for. I was won over by the argument that we should pin exact versions ("exact set of versioned dependencies for an exact version of Galaxy), but that we will:
    • Fetch new dependency versions as they are released
    • Build wheels for them
    • Test Galaxy against these new wheel versions
    • If the tests pass, automatically issue a PR against Galaxy to bump the version
  • ~~Should the existence of $galaxy_root/.venv take precedence over $VIRTUAL_ENV (since I keep installing all of Galaxy's wheels in my tox venv =P)?~~use --skip-venv if you don't want .venv to take precedence.

@mr-c
Copy link
Contributor

mr-c commented Jul 5, 2015

Fantastic work, 👍

@dannon
Copy link
Member

dannon commented Jul 5, 2015

Regarding dependency pinning, +1 to SQLAlchemy<1.1. We don't want automatic major version updates to happen without testing, but it'd definitely be nice to make minor updates less onerous.

@natefoo
Copy link
Member Author

natefoo commented Jul 5, 2015

@jxtx converted bx-python back to setuptools, so that one's done.

@nsoranzo
Copy link
Member

nsoranzo commented Jul 5, 2015

This is going to be awesome!

@jmchilton
Copy link
Member

135 additions and 5,471 deletions. 😈

@natefoo
Copy link
Member Author

natefoo commented Jul 5, 2015

OS X wheels built with python.org builds of Python (which are multi-arch Intel builds using the 10.6 SDK) work on all later versions of OS X. I am starting to upload these to https://wheels.galaxyproject.org/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently checks out the repository again every time I run it. Changing to pip install -e git+https://github.com/natefoo/pip@linux-wheels#egg=pip allows it just to update.

@nsoranzo
Copy link
Member

Remove all eggs imports and eggs require()s

@natefoo: Will it be possible to change all pkg_resources.require()s to imports?

@natefoo
Copy link
Member Author

natefoo commented Jul 13, 2015

@nsoranzo In theory it should be possible to simply remove them. They should precede the name they are importing, which should now succeed since everything should be accessible on sys.path from the beginning.

`{eggs,pkg_resources}.require`. Probably broke some stuff where we were
trying to be smart about whether a particular egg was available, but
Galaxy does at least start.
@natefoo
Copy link
Member Author

natefoo commented Jul 15, 2015

I thought I wrote this down somewhere but now I can't find it...

The suggestion from @jxtx regarding pinning was to pin to exact versions but to automate checking for minor version updates, automatically build wheels, and then PR with the new versions so that tests are run. If tests pass, then we can merge the PR and have updated versions.

This ensures that each stable release of Galaxy will have an exact set of versioned dependencies.

@natefoo
Copy link
Member Author

natefoo commented Jul 15, 2015

@martenson Are our modifications to Whoosh forked somewhere?

@natefoo
Copy link
Member Author

natefoo commented Jul 15, 2015

bx wheel fixed with galaxyproject/starforge@bcd773f

@natefoo
Copy link
Member Author

natefoo commented Jul 15, 2015

Also, if anyone has any ideas on how to automate building wheels on OS X, I'd appreciate them since obviously we can't use docker-build there. @jxtx claims it's possible to virtualize OS X on non-Apple hardware these days?

@jxtx
Copy link
Contributor

jxtx commented Jul 15, 2015

Definitely possible. Questionably legal. http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/

@natefoo
Copy link
Member Author

natefoo commented Aug 17, 2015

I've been working on the "figure out how to build psycopg2" option, and the plan that I like the best goes like this:

Using galaxyproject/starforge#27 (and some stuff I still need to push to that PR) it'll be possible to build wheels on many different distros using docker. Right now I plan to build for both 32- and 64-bit Debian 6, 7, and 8, Ubuntu 12.04 and 14.04, and CentOS/RHEL 6 and 7. Also if anyone wants to add SLES/openSUSE support that would be good too. This means we get to dynamically link the vendor-provided libpq rather than our own statically-compiled and probably out-of-date-and-buggy version.

There'll also be a fallback generic linux-x86_64 wheel that will be statically compiled against psycopg2. Maybe.

@hexylena
Copy link
Member

@natefoo :D

@natefoo
Copy link
Member Author

natefoo commented Sep 17, 2015

SVGFig is now available here, and versioned tarballs are still accessible (as of now) from Google Code via this wiki page. So I downloaded the upstream 1.1.6 tarball, fixed the version number in setup.py, created an sdist, uploaded that to wheels.galaxyproject.org, and then built a (generic py2) wheel from that in docker-build (and uploaded it to wheels.galaxyproject.org).

@natefoo
Copy link
Member Author

natefoo commented Sep 18, 2015

@dannon can you re-enlighten me as to what version of sqlalchemy-migrate we need to use? IIRC it was just that we needed to use the version from git as opposed to the published version in PyPI? Because the version in PyPI is only a couple weeks old now so maybe it's good.

@natefoo
Copy link
Member Author

natefoo commented Oct 22, 2015

IT'S HAPPENING

@martenson
Copy link
Member

damn @natefoo ; I think @jxtx does not approve of that emoticon :D

gratz on the tests though, wheels are coming!

@hexylena
Copy link
Member

@natefoo I can't find a reaction gif for how excited I am for this. Well done.

@natefoo
Copy link
Member Author

natefoo commented Oct 22, 2015

So on a scale of -1 to +1, how do people feel about this? =D

@jxtx
Copy link
Contributor

jxtx commented Oct 22, 2015

image

@martenson
Copy link
Member

👍

@jmchilton
Copy link
Member

This is going to break a lot of stuff, I would suggest we get drunk tonight
and merge this at Zeno's. #mergethebigonesdrunk
On Oct 22, 2015 12:53 PM, "Eric Rasche" notifications@github.com wrote:

@natefoo https://github.com/natefoo I can't find a reaction gif for how
excited I am for this. Well done.


Reply to this email directly or view it on GitHub
#428 (comment).

@hexylena
Copy link
Member

Works for me on:

  • pre-existing with eggs
  • intside a venv and not

Doesn't work for me on:

  • virtualenv using --skip-venv

    (asdf)hxr@leda:~/work/galaxy$ sh run.sh --skip-venv
    Activating virtualenv at /home/hxr/work/galaxy/.venv
    Obtaining pip from git+https://github.com/natefoo/pip@linux-wheels#egg=pip
    Updating ./.venv/src/pip clone (to linux-wheels)
    

    that flag seems to only be available on run_tests.sh

  • Installing own wheels to a venv using pip install...

    (asdf)hxr@leda:~/work/galaxy$ pip install --index-url=https://wheels.galxayproject.org/ -r requirements.txt
    Downloading/unpacking Cheetah==2.4.4 (from -r requirements.txt (line 2))
    Cannot fetch index base URL https://wheels.galxayproject.org/
    Could not find any downloads that satisfy the requirement Cheetah==2.4.4 (from -r requirements.txt (line 2))
    Cleaning up...
    No distributions at all found for Cheetah==2.4.4 (from -r requirements.txt (line 2))
    Storing debug log for failure in /home/hxr/.pip/pip.log
    

1335497891219

Untested:

  • Non-Debianish Linuxes
  • Macs of various flavors
  • Galaxy servers using PostgreSQL on a variety of platforms
  • Upgrading a CloudMan instance
  • Using a non-standard Python (compiled from source)
  • Run Galaxy on your PDP-11

@hexylena
Copy link
Member

That said, neither of those cases are things which should prevent this merge and can't be solved in the next two months... so 👍
00

@natefoo
Copy link
Member Author

natefoo commented Oct 22, 2015

@erasche Why fix later what I can fix now before I forget how everything works?

@jmchilton +:100:

@dannon
Copy link
Member

dannon commented Oct 22, 2015

Super exciting, but, for me on OSX, upgrading from existing install:

Found existing installation: mercurial 3.5.2
Detected a distutils installed project ('mercurial') which we cannot uninstall. The metadata provided by distutils does not contain a list of files which have been installed, so pip does not know which files to uninstall.
You must give at least one requirement to install (see "pip help install")
Activating virtualenv at /Users/yoplait/work/galaxy/.venv
Traceback (most recent call last):
  File "./scripts/paster.py", line 26, in <module>
    from galaxy.util.pastescript import serve
  File "/Users/yoplait/work/galaxy/lib/galaxy/util/__init__.py", line 36, in <module>
    import docutils.core
ImportError: No module named docutils.core

Wiped out pre-existing .venv, same thing.

@natefoo
Copy link
Member Author

natefoo commented Oct 22, 2015

@dannon What's your $PYTHONPATH look like? virtualenv-burrito screws everything up.

@dannon
Copy link
Member

dannon commented Oct 22, 2015

[yoplait@malleus:~/work/galaxy] echo $PYTHONPATH                               smash_eggs ✭
/usr/local/lib/python2.7/site-packages

(brew installed python on El Capitan!)

@hexylena
Copy link
Member

@natefoo

Why fix later what I can fix now before I forget how everything works?

fair enough. :)

@natefoo
Copy link
Member Author

natefoo commented Oct 22, 2015

@erasche Well why'd you type wheels.galxay instead of wheels.galaxy... oh... nevermind. (fixed my comment above where I typo'd it). Also, --skip-venv support coming shortly.

@dannon What if you start with PYTHONPATH unset?

If it works, that's gonna be a fun one to deal with. Perhaps we should unset PYTHONPATH in the event that --skip-venv is not used.

@hexylena
Copy link
Member

@natefoo tested again with a correct URL, works. :)

Edit:

Downloading/unpacking python-lzo==1.8 (from -r requirements.txt (line 10))
  Could not find any downloads that satisfy the requirement python-lzo==1.8 (from -r requirements.txt (line 10))
Cleaning up...
No distributions at all found for python-lzo==1.8 (from -r requirements.txt (line 10))
Storing debug log for failure in /home/hxr/.pip/pip.log

than an editable directly from github.

Also, use `set -e` in scripts/common_startup.sh to fail if anything
fails, rather than chaining a bunch of things with `&&` but not properly
handling failure cases.
@dannon
Copy link
Member

dannon commented Oct 22, 2015

@natefoo With an unset pythonpath, there is no mercurial issue, but then I hit:

  Could not find a version that satisfies the requirement pysam==0.8.3gx1 (from -r requirements.txt (line 13)) (from versions: 0.8.3+gx1)
No matching distribution found for pysam==0.8.3gx1 (from -r requirements.txt (line 13))
You must give at least one requirement to install (see "pip help install")
Activating virtualenv at /Users/yoplait/work/galaxy/.venv
Traceback (most recent call last):
  File "./scripts/paster.py", line 26, in <module>
    from galaxy.util.pastescript import serve
  File "/Users/yoplait/work/galaxy/lib/galaxy/util/__init__.py", line 36, in <module>
    import docutils.core
ImportError: No module named docutils.core

@nturaga
Copy link
Contributor

nturaga commented Oct 22, 2015

Activating virtualenv at /Users/nturaga/Documents/PR_testing/galaxy/.venv Ignoring indexes: https://pypi.python.org/simple Requirement already up-to-date: pip in ./.venv/lib/python2.7/site-packages Requirement already satisfied (use --upgrade to upgrade): Cheetah==2.4.4 in ./.venv/lib/python2.7/site-packages (from -r requirements.txt (line 2)) ... serving on http://127.0.0.1:8080

Works for me...

@natefoo
Copy link
Member Author

natefoo commented Oct 22, 2015

For the record, @erasche's problems were fixed with the addition of installing the Galaxy-modified pip.

@dannon
Copy link
Member

dannon commented Oct 22, 2015

+1

dannon added a commit that referenced this pull request Oct 22, 2015
@dannon dannon merged commit e423ab6 into galaxyproject:dev Oct 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants