Re: how to compile psycopg2 on windows?

Поиск
Список
Период
Сортировка
От Jason Erickson
Тема Re: how to compile psycopg2 on windows?
Дата
Msg-id 20110109104116.R39273@stickpeople.com
обсуждение исходный текст
Ответ на Re: how to compile psycopg2 on windows?  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список psycopg
On Sun, 9 Jan 2011, Daniele Varrazzo wrote:

> On Sun, Jan 9, 2011 at 7:45 AM, Bright Pan <loststriker@gmail.com> wrote:
>> i compiled pscopg2 2.3.2 and install successful, but the error is happen:
>> ImportError: DLL load failed.
>> i find the file�_psycopg.pyd is only 127KB, but official package on windows
>> is 1MB�.
>> the following is my compiling step:
>> python setup.py build_ext -c mingw32�install
>
> Probably you have built a library dynamically linked to the libpq,
> whereas the Jason packages have the libpq statically linked. The
> setting can be configured using the static_libpq setting in the
> setup.cfg.
>
> This of course doesn't solve all the issues of the Windows build. I
> know Jason is polishing the build system he uses for his packages,
> which is not a trivial one as he also builds the libpq and the ssl
> libs together with psycopg. I hope good news should come from him,
> also about the issue #20 :)

I believe Daniele is directing you in the right direction.  The package I
build is statically linked to both libpq and openssl, resulting in the 1MB
size.  In the past when I've only linked to libpq, the size is around
500KB, just to give you an idea.  Based upon your size, I would think that
it is linking to import library pointing to the libpq.dll.

You did not mention how you got the PostgreSQL 'code' (Standard
download/installation, compiling by self).  Looking at the 9.0 prebuilt
binaries, the libpq.lib points to the libpq.dll. To confuse you even more,
if you build the code yourself, the names differs as follows:
     libpq.lib    400KB --> static libpq library (not libpq.dll)
     libpqdll.lib  32KB --> loads libpq.dll

Hmm, so short answer is that depending on how you get the binaries
partially determines static/dynamic linkage.  So the 'static_libpq'
setting mentioned previously might not do what it says.  Arrrrg.


As a test, you could place the libpq.dll into \windows\system32 and see if
you still get the error (There is a more pythonic location to place it,
too, at %PYTHONDIR%\Lib\site-packages\psycopg2).  If libpq.dll is already
in system32, it could be an older version causing problems.  If placing it
in system32 works, you can then move it to a more pythonic location.

-jason



>
> What Python version are you using anyway? I remember building with up
> to Python 2.5 was an easy task using this bundle [1], but with Python
> 2.6 I found problems, maybe related to the issue #3308 [2]
>
> [1] http://www.develer.com/oss/GccWinBinaries
> [2] http://bugs.python.org/issue3308
>
> -- Daniele

В списке psycopg по дате отправления:

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: Re: how to compile psycopg2 on windows?
Следующее
От: Jason Erickson
Дата:
Сообщение: psycopg2 w/apache on win32 (Issue #20)