Two versions of SQLAlchemy side-by-side?
We have SQLAlchemy 0.3.3 installed via setuptools. I upgraded to 0.4.5 today but had to back that out (by editing easy-install.pth) because of API changes. Now I have these two installs .../site-packages/SQLAlchemy-0.3.3-py2.4.egg .../site-packages/SQLAlchemy-0.4.5-py2.4.egg Is there a way to import the 0.4.5 version for testing without disturbing the 0.3.3 version? I tried placing the 0.4.5 egg directory in PYTHONPATH but I still get the 0.3.3 version when I "import sqlalchemy". What's a fella to do? Thanks, Skip
The quick hack to request a version, good to use in the interpreter or a "throw-away" script: import pkg_resources pkg_resources.require('SQLAlchemy==0.4.5') import sqlalchemy This works when the directory that SQLAlchemy-0.4.5-py2.4.egg is in is listed in sys.path. On Tue, Apr 29, 2008 at 11:11 AM, <skip@pobox.com> wrote:
We have SQLAlchemy 0.3.3 installed via setuptools. I upgraded to 0.4.5 today but had to back that out (by editing easy-install.pth) because of API changes. Now I have these two installs
.../site-packages/SQLAlchemy-0.3.3-py2.4.egg .../site-packages/SQLAlchemy-0.4.5-py2.4.egg
Is there a way to import the 0.4.5 version for testing without disturbing the 0.3.3 version? I tried placing the 0.4.5 egg directory in PYTHONPATH but I still get the 0.3.3 version when I "import sqlalchemy".
What's a fella to do?
Thanks,
Skip
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
Alexander> The quick hack to request a version, good to use in the Alexander> interpreter or a "throw-away" script: Alexander> import pkg_resources Alexander> pkg_resources.require('SQLAlchemy==0.4.5') Alexander> import sqlalchemy Alexander> This works when the directory that SQLAlchemy-0.4.5-py2.4.egg Alexander> is in is listed in sys.path. Thanks, however that raises a VersionConflict exception: >>> pkg_resources.require('SQLAlchemy==0.4.5') Traceback (most recent call last): File "<stdin>", line 1, in ? File "/opt/app/g++lib6/python-2.4.5/lib/python2.4/site-packages/setuptools-0.6c7-py2.4.egg/pkg_resources.py", line 626, in require needed = self.resolve(parse_requirements(requirements)) File "/opt/app/g++lib6/python-2.4.5/lib/python2.4/site-packages/setuptools-0.6c7-py2.4.egg/pkg_resources.py", line 528, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (SQLAlchemy 0.3.3 (/opt/app/g++lib6/python-2.4.5/lib/python2.4/site-packages/SQLAlchemy-0.3.3-py2.4.egg), Requirement.parse('SQLAlchemy==0.4.5')) I need 0.3.3 to be the default version, but need to be able to import 0.4.5 for testing. Thx, Skip
On Tue, Apr 29, 2008 at 11:42 AM, <skip@pobox.com> wrote:
Alexander> The quick hack to request a version, good to use in the Alexander> interpreter or a "throw-away" script:
Alexander> import pkg_resources Alexander> pkg_resources.require('SQLAlchemy==0.4.5') Alexander> import sqlalchemy
Alexander> This works when the directory that SQLAlchemy-0.4.5-py2.4.egg Alexander> is in is listed in sys.path.
Thanks, however that raises a VersionConflict exception:
>>> pkg_resources.require('SQLAlchemy==0.4.5') Traceback (most recent call last): File "<stdin>", line 1, in ? File "/opt/app/g++lib6/python-2.4.5/lib/python2.4/site-packages/setuptools-0.6c7-py2.4.egg/pkg_resources.py", line 626, in require needed = self.resolve(parse_requirements(requirements)) File "/opt/app/g++lib6/python-2.4.5/lib/python2.4/site-packages/setuptools-0.6c7-py2.4.egg/pkg_resources.py", line 528, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (SQLAlchemy 0.3.3 (/opt/app/g++lib6/python-2.4.5/lib/python2.4/site-packages/SQLAlchemy-0.3.3-py2.4.egg), Requirement.parse('SQLAlchemy==0.4.5'))
I need 0.3.3 to be the default version, but need to be able to import 0.4.5 for testing.
Ah. Yes. I install everything --multi-version so I have forgotten about this issue with the default working set. Maybe __requires__ = ['SQLAlchemy==0.4.5'] import pkg_resources import sqlalchemy will help pkg_resources create the desired WorkingSet.
>> Thanks, however that raises a VersionConflict exception: Alexander> Ah. Yes. I install everything --multi-version so I have Alexander> forgotten about this issue with the default working Alexander> set. Maybe Alexander> __requires__ = ['SQLAlchemy==0.4.5'] Alexander> import pkg_resources Alexander> import sqlalchemy Thanks. Worked like a charm. I'll have to check out --multi-version. I've never used it before. Is there any downside to using it? Skip
At 01:18 PM 4/29/2008 -0500, skip@pobox.com wrote:
Thanks. Worked like a charm. I'll have to check out --multi-version. I've never used it before. Is there any downside to using it?
The only downside is that you won't be able to "import sqlalchemy" at all, without first importing pkg_resources and require()-ing the desired version. And in your current scenario, you'll want to keep 0.3.3 as your default since other packages with an open-ended version requirement would end up selecting 0.4.5.
participants (3)
-
Alexander Michael
-
Phillip J. Eby
-
skip@pobox.com