1

I am currently trying to make use of pypy to try and see with a profiler if I will get better results than now, currently using only python 3.8

I have installed pypy 3.9 for windows 10 (64 bits) and been upgrading pip, setuptools, as well as wheels before installing anything, most of packages have been working fine (websockets, google-auth, ...) but when installing aiopg (built on psycopg2) I get this error:

pip install psycopg2
Collecting psycopg2
  Using cached psycopg2-2.9.3.tar.gz (380 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  Ôöé exit code: 1
  Ôò░ÔöÇ> [46 lines of output]
      running egg_info
      creating C:\Users\charl\AppData\Local\Temp\pip-pip-egg-info-slfqnpdw\psycopg2.egg-info
      writing C:\Users\charl\AppData\Local\Temp\pip-pip-egg-info-slfqnpdw\psycopg2.egg-info\PKG-INFO
      writing dependency_links to C:\Users\charl\AppData\Local\Temp\pip-pip-egg-info-slfqnpdw\psycopg2.egg-info\dependency_links.txt
      writing top-level names to C:\Users\charl\AppData\Local\Temp\pip-pip-egg-info-slfqnpdw\psycopg2.egg-info\top_level.txt
      writing manifest file 'C:\Users\charl\AppData\Local\Temp\pip-pip-egg-info-slfqnpdw\psycopg2.egg-info\SOURCES.txt'
      c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\config\setupcfg.py:459: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
        warnings.warn(msg, warning_class)
      Traceback (most recent call last):
        File "<string>", line 36, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\charl\AppData\Local\Temp\pip-install-_oajyk5x\psycopg2_8ddd8ed44adb43868bba1fd17520cb9c\setup.py", line 572, in <module>
          'Download': 'https://pypi.org/project/psycopg2/',
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\core.py", line 177, in setup
          return run_commands(dist)
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\core.py", line 193, in run_commands
          dist.run_commands()
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\dist.py", line 1229, in run_command
          super().run_command(command)
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
          cmd_obj.run()
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\command\egg_info.py", line 308, in run
          self.find_sources()
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\command\egg_info.py", line 315, in find_sources
          mm.run()
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\command\egg_info.py", line 550, in run
          self.add_defaults()
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\command\egg_info.py", line 587, in add_defaults
          sdist.add_defaults(self)
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\command\sdist.py", line 252, in add_defaults
          self._add_defaults_ext()
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\command\sdist.py", line 336, in _add_defaults_ext
          build_ext = self.get_finalized_command('build_ext')
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\cmd.py", line 304, in get_finalized_command
          cmd_obj.ensure_finalized()
        File "c:\pypy3.8-v7.3.8-win64\lib\site-packages\setuptools\_distutils\cmd.py", line 107, in ensure_finalized
          self.finalize_options()
        File "C:\Users\charl\AppData\Local\Temp\pip-install-_oajyk5x\psycopg2_8ddd8ed44adb43868bba1fd17520cb9c\setup.py", line 381, in finalize_options
          for token in pg_config_helper.query("ldflags").split():
        File "C:\Users\charl\AppData\Local\Temp\pip-install-_oajyk5x\psycopg2_8ddd8ed44adb43868bba1fd17520cb9c\setup.py", line 124, in query
          result = result.decode('ascii')
      UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 13: ordinal not in range(128)
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
Ôò░ÔöÇ> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I have been trying the following:

  • Pypy 3.8 with python 3.8 : same error despite clearing pip cache
  • "pip install psycopg2-binary" : same error
  • downgrading psycopg2 version : same error until the version is too low : another error due to the fact that the package doesnt exist for my python version
  • downloading the whl and installing "manually" : not working for different reason : "psycopg2-2.9.3-cp38-cp38-win_amd64.whl is not a supported wheel on this platform." despite using python x64 3.8 :
pip -V
pip 22.1.2 from c:\pypy3.8-v7.3.8-win64\lib\site-packages\pip (python 3.8)

I've tried using asyncpg since it seems like a really fast postgresql library and my server is mostly made of sql requests and I got :

asyncpg/protocol/record/recordobj.c(549): warning C4013: '_PyUnicodeWriter_Dealloc' non d\x82fini(e)\xff; extern retournant int pris par d\x82faut
     asyncpg/protocol/record/recordobj.c(549): error C2065: 'writer'\xff: identificateur non d\x82clar\x82
     C:\Users\charl\AppData\Local\Temp\pip-build-env-goboqejq\overlay\Lib\site-packages\setuptools\config\pyprojecttoml.py:123: _InvalidFile: The given `pyproject.toml` file is invalid and would be ignored.
         !!


         ############################
         # Invalid `pyproject.toml` #
         ############################

         Any configurations in `pyproject.toml` will be ignored.
         Please note that future releases of setuptools will halt the build process
         if an invalid file is given.

         To prevent setuptools from considering `pyproject.toml` please
         DO NOT include the `[project]` or `[tool.setuptools]` tables in your file.


     !!

       if _skip_bad_config(project_table, orig_setuptools_table, dist):
     error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
     [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

psycopg on the other hand worked, but I don't want to use it.

Any fellow windows friend having similar problems?

Charles L.
  • 13
  • 1
  • 5
  • 1
    From what I remember psycopg2 does not work on pypy. You could try [psycopg2cffi](https://github.com/chtd/psycopg2cffi#installation). – IamFr0ssT Jun 16 '22 at 10:54
  • Alright then, I decided to use asyncpg and uvloop instead of pypy – Charles L. Jun 16 '22 at 15:19
  • I could have mentioned [pyston](https://github.com/pyston/pyston) instead of pypy. It is faster with django rest framework than cpython, from 3s to 500ms in a specific slow call (most time is spent on serialization), and I didn't need any changes in code for it to run. Do keep in mind that Python 3.11 to 3.14 have plans to improve speed significantly, so that might help in the long run. – IamFr0ssT Jun 16 '22 at 15:33
  • Are you using a directory or user name with unicode characters in it? I see `pip-install-_oajyk5x` in the traceback. PyPy on window's console handling is not very polished, I have seen problems when using unicode characters. – mattip Jun 17 '22 at 09:48
  • With that, I don't think psyocpg2 can be installed on PyPy and @lamFrosst's suggestion to use psycopg2cffi is the best answer – mattip Jun 17 '22 at 09:58

0 Answers0