PolicyStat / terrarium

Package and ship relocatable python virtualenvs, like a boss.
https://terrarium.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
171 stars 14 forks source link

Symlinks cause environment egg-link to point to old path #35

Closed zalmoxis closed 11 years ago

zalmoxis commented 11 years ago

When creating the same virtualenv in a different location, the egg files for src packages (-e github-package) point to the old location src directory. Since that no longer exists, the imports fail.

winhamwr commented 11 years ago

Hey Darie!

Hrm. We definitely use lots of -e links in our setup, so I know this isn't a general issue with editable packages. Could you provide reproduction steps? Commands you're running? Maybe it's something with a specific requirement?

-Wes

zalmoxis commented 11 years ago

ploybot.egg-link that lives in

/srv/www/addibuy_staging_20130418_141722/env/lib/python2.6/site-packages

looks like (note that the timestamp in the directory name is an old one)

../../../../../addibuy_staging_20130415_172815/env/src/ploybot

when it should look like:

../../../src/ploybot

The place where my env lives changes name on each deployment. I don't see why the relative path should go any further than the env root. I'd fix this right away, but I can't figure out where this tidbit happens for egg-link files.

The command I run is:

c = ("terrarium --target %s/env/ --storage-dir %s install %s/requirements.txt") % (env.root, terrariums_storage_dir, env.root)

which should look like

terrarium --target /srv/www/addibuy_20130418_141722/env/ --storage-dir /srv/www/terrariums/ install /srv/www/addibuy_20130418_141722/requirements.txt

This is run as a subsequent deployment. The newly built terrarium is alright except for that relative path in the egg-link that includes the old directory name. I can see how this may work in some setups where that directory doesn't change name, but there is no reason for the egg-link file to include that directory name. All tests should continue to pass with the removal of that portion.

EDIT: Also, the second -e requirement ploybot-config has the same issue:

../../../../../addibuy_staging_20130415_172815/env/src/ploybot-config
kylegibson commented 11 years ago

Hi zalmoxis,

Thanks for the detailed report of the issue. The relative path conversion is actually taken care of by pip, unfortunately it doesn't do a good job in this case.

Could you give #22 a try and let us know if that fixes this problem for you?

winhamwr commented 11 years ago

And if it does work, and you can slap a unit test on it, you would be a hero :)

zalmoxis commented 11 years ago

I'll check it out. There are no symlinks involved in my case though.

zalmoxis commented 11 years ago

Ok. This was very helpful. Turns out I was actually accidentaly symlinking instead of copying the project dir before rsyncing. The patch you pointed DID fix the problem. I did however fixed my code to not use symlinks and the non-patched terrarium works fine. I am very pressed by time right now with a client project actually. I'll see how I clear up to get to that unit test. Thanks Wes!

winhamwr commented 11 years ago

Cool. Glad you could get it working. Closing this issue as a dupe of #22