Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows support #31

Closed
amigo00678 opened this issue Sep 20, 2016 · 9 comments
Closed

Add Windows support #31

amigo00678 opened this issue Sep 20, 2016 · 9 comments

Comments

@amigo00678
Copy link

amigo00678 commented Sep 20, 2016

Running 'python -m pip install asyncpg' causes an error on Windows:
`
running build_ext
building 'asyncpg.protocol.protocol' extension
creating build\temp.win32-3.5
creating build\temp.win32-3.5\Release
creating build\temp.win32-3.5\Release\asyncpg
creating build\temp.win32-3.5\Release\asyncpg\protocol
creating build\temp.win32-3.5\Release\asyncpg\protocol\record
C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /
W3 /GL /DNDEBUG /MD -IC:\Python35\include -IC:\Python35\include "-IC:\Program Files\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files\Windows Kits\8.1\include\shared" "-IC:\Program Files\Windows Kits\8.1\include\um" "-IC:\Program Files\Windows Kits\8.1\include\winrt" /Tcasyncpg/protocol/record/recordobj.c Fobuild\temp.win32-3.5\Release\asyncpg/protocol/record/recordobj.obj -O2
recordobj.c
C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Python35\include -IC:\Python35\include "-IC:\Program Files\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files\Windows Kits\8.1\include\shared" "-IC:\Program Files\Windows Kits\8.1\include\um" "-IC:\Program Files\Windows Kits\8.1\include\winrt" /Tcasyncpg/protocol/protocol.c /Fobuild\temp.win32-3.5\Rel
ease\asyncpg/protocol/protocol.obj -O2
protocol.c
asyncpg/protocol/protocol.c(276): fatal error C1083: Cannot open include file: 'arpa/inet.h': No such file or directory
error: command 'C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe' failed with exit status 2

@espositofulvio
Copy link

This is because asyncpg is not supported on windows. I've got a separate branch here https://github.com/espositofulvio/asyncpg/tree/windows which allows me to compile the extension and run a simple test

import asyncio
import asyncpg

async def init_app():
    connection = await asyncpg.connect(host='127.0.0.1', database='postgres', user='postgres', password='postgres' )
    async with connection.transaction():
        res = await connection.fetchval( 'select 2 ^ 5' )
        print( 'result is {0}'.format( res ) )

loop = asyncio.get_event_loop()
app = loop.run_until_complete(init_app())

But 99 tests out of 103 fail with the error "cluster is not running". I'm not sure what Cluster represents as I can find usages only in tests. Maybe someone from the core team can explain so I can try and make all tests pass on Windows as well.

@elprans
Copy link
Member

elprans commented Sep 29, 2016

There are some issues with starting the Postgres cluster on Windows that fails the tests. I haven't really looked into what exactly is wrong, but you can probably get that by putting subprocess.PIPE here.

@espositofulvio
Copy link

There are some issues with starting the Postgres cluster on Windows that fails the tests. I haven't really looked into what exactly is wrong, but you can probably get that by putting subprocess.PIPE here.

I've also got to conditionally add the local entry in pg_hba.conf because it doesn't work on windows and add an entry for "::1/128" as well.
I've reduced the failing tests to 34, most of which are:

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

Any hunch what might cause that?

@espositofulvio
Copy link

This is the first error from tests:

ERROR:  canceling statement due to user request                                                                                                                                                                                               
STATEMENT:  SELECT pg_sleep(20)                                                                                                                                                                                                               
Task exception was never retrieved                                                                                                                                                                                                            
future: <Task finished coro=<Connection._cancel_current_command.<locals>.cancel() done, defined at d:\Work\Lasco\asyncpg\asyncpg\connection.py:388> exception=InvalidStateError("FINISHED: <Future finished exception=ConnectionResetError(100
54, 'An existing connection was forcibly closed by the remote host', None, 10054, None) created at D:\\Programs\\Python\\lib\\asyncio\\base_events.py:252>",) created at d:\Work\Lasco\asyncpg\asyncpg\connection.py:419>                     
source_traceback: Object created at (most recent call last):                                                                                                                                                                                  
  File "D:\Programs\Python\lib\runpy.py", line 184, in _run_module_as_main                                                                                                                                                                    
    "__main__", mod_spec)                                                                                                                                                                                                                     
  File "D:\Programs\Python\lib\runpy.py", line 85, in _run_code                                                                                                                                                                               
    exec(code, run_globals)                                                                                                                                                                                                                   
  File "D:\Programs\Python\lib\unittest\__main__.py", line 18, in <module>                                                                                                                                                                    
    main(module=None)                                                                                                                                                                                                                         
  File "D:\Programs\Python\lib\unittest\main.py", line 94, in __init__                                                                                                                                                                        
    self.runTests()                                                                                                                                                                                                                           
  File "D:\Programs\Python\lib\unittest\main.py", line 255, in runTests                                                                                                                                                                       
    self.result = testRunner.run(self.test)                                                                                                                                                                                                   
  File "D:\Programs\Python\lib\unittest\runner.py", line 176, in run                                                                                                                                                                          
    test(result)                                                                                                                                                                                                                              
  File "D:\Programs\Python\lib\unittest\suite.py", line 84, in __call__                                                                                                                                                                       
    return self.run(*args, **kwds)                                                                                                                                                                                                            
  File "D:\Programs\Python\lib\unittest\suite.py", line 122, in run                                                                                                                                                                           
    test(result)                                                                                                                                                                                                                              
  File "D:\Programs\Python\lib\unittest\suite.py", line 84, in __call__                                                                                                                                                                       
    return self.run(*args, **kwds)                                                                                                                                                                                                            
  File "D:\Programs\Python\lib\unittest\suite.py", line 122, in run                                                                                                                                                                           
    test(result)                                                                                                                                                                                                                              
  File "D:\Programs\Python\lib\unittest\suite.py", line 84, in __call__                                                                                                                                                                       
    return self.run(*args, **kwds)                                                                                                                                                                                                            
  File "D:\Programs\Python\lib\unittest\suite.py", line 122, in run                                                                                                                                                                           
    test(result)                                                                                                                                                                                                                              
  File "D:\Programs\Python\lib\unittest\case.py", line 648, in __call__                                                                                                                                                                       
    return self.run(*args, **kwds)                                                                                                                                                                                                            
  File "D:\Programs\Python\lib\unittest\case.py", line 600, in run                                                                                                                                                                            
    testMethod()                                                                                                                                                                                                                              
  File "d:\Work\Lasco\asyncpg\asyncpg\_testbase.py", line 65, in wrapper                                                                                                                                                                      
    self.loop.run_until_complete(__meth__(self, *args, **kwargs))                                                                                                                                                                             
  File "D:\Programs\Python\lib\asyncio\base_events.py", line 375, in run_until_complete                                                                                                                                                       
    self.run_forever()                                                                                                                                                                                                                        
  File "D:\Programs\Python\lib\asyncio\base_events.py", line 345, in run_forever                                                                                                                                                              
    self._run_once()                                                                                                                                                                                                                          
  File "D:\Programs\Python\lib\asyncio\base_events.py", line 1304, in _run_once                                                                                                                                                               
    handle._run()                                                                                                                                                                                                                             
  File "D:\Programs\Python\lib\asyncio\events.py", line 125, in _run                                                                                                                                                                          
    self._callback(*self._args)                                                                                                                                                                                                               
  File "d:\Work\Lasco\asyncpg\asyncpg\connection.py", line 419, in _cancel_current_command                                                                                                                                                    
    self._loop.create_task(cancel())    

@nursike
Copy link

nursike commented Sep 30, 2016

@espositofulvio @amigo00678 I have the same problem with asyncpg on Windows. Did you figure out how to solve this issue?

@espositofulvio
Copy link

@Nursik91 unfortunately not yet. It's not very clear to me, I had a look at a couple of cases and I couldn't find a reason as to why that exceptions are thrown. It looks like await is not called on the future but I can actually see it in the test case, so I'm dead in the water. If you want to try it by yourself, have a look at https://github.com/espositofulvio/asyncpg/tree/windows where I'm developing windows support. I'm using cmder as shell, but make is not supported so I had to type each build command to compile the extension, you need VisualC++ 2015 installed by the way.

By the way, I've also tried switching to a ProactorLoopEvent as it is suggested for higher performance, but then there are loads of exceptions so I won't recommend using asyncpg in production on Windows until uvloop by MagickStack is ported to Windows as well.

@espositofulvio
Copy link

@elprans by the way, is there an internal effort at MagickStack to support Windows? I mean for uvloop and asyncpg mainly.

@elprans
Copy link
Member

elprans commented Oct 3, 2016

@espositofulvio I will try to look into asyncpg Windows issues this week.

elprans added a commit that referenced this issue Oct 20, 2016
@1st1
Copy link
Member

1st1 commented Oct 20, 2016

Closing this issue now.

@1st1 1st1 closed this as completed Oct 20, 2016
@elprans elprans changed the title Error installing on Windows Add Windows support Oct 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants