Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Symlinks and relative paths in easy_install.pth break portability of virtualenvs #20

Open
christian-oudard opened this issue Jan 17, 2013 · 7 comments

Comments

@christian-oudard
Copy link
Contributor

So, in our server setup, we have numerous symlinks to the various code versions. We are running the terrarium install from a symlinked "~/current/" directory, and it creates a frozen virtualenv with a non portable easy_install.pth. It contains entries like this:

../../../../../../../mnt/srv/server_name/releases/20130116140210-heads-master-0-g47d7e44/src/pymysql

When it should actually contain:
../../src/pymysql

This is basically the relative path going all the way up to the root, then back down the non-symlinked path to the same place as we started.

The problem here is that we end up including "server_name" in the .pth file, which breaks when we are on a different game server installing the same packages, and the game name is different.

I see three possible solutions here:

  1. Always have server_name be the same across games, which is confusing and would take a lot of work.
  2. Always make sure that you never run terrarium from a path that contains symlinks. This is something that should be well documented by terrarium.
  3. Make terrarium generate easy_install.pth more intelligently.

Can we try to figure out how to do option 3?

@winhamwr
Copy link
Contributor

My guess is that the symlinked directory use-case is fairly common. Versioning our virtualenv on deployment, just like we do with our code, is actually on my todo list.

It definitely seems like option 3 is doable.

@christian-oudard
Copy link
Contributor Author

So, I've fixed it with option 3, but it required forking virtualenv:
pypa/virtualenv#389

Not sure if it's possible to do something like this for older versions of virtualenv, just by tweaking it from the terrarium side.

@kylegibson
Copy link
Member

terrarium can definitely post-process the easy_install.pth file for older versions of virtualenv

@christian-oudard
Copy link
Contributor Author

Cool. I'm not really sure how to approach that though. Maybe we could just re-implement make_virtualenv_relocatable on our own?

@kylegibson
Copy link
Member

That may do it. It will be awhile before I will have the time to tackle this, so feel free to take a stab at it meanwhile.

@christian-oudard
Copy link
Contributor Author

I think I got it. I put up a pull request, but I'm not sure how to link it to this ticket.

@kylegibson
Copy link
Member

Christian, if you want, you can use hub to turn this issue into a pull-request. Something like this:

hub pull-request -i 20 -b PolicyStat/terrarium:master -h brooklynpacket/terrarium:master

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants