s3rius / FastAPI-template

Feature rich robust FastAPI template.
MIT License
1.79k stars 161 forks source link

Using Mysql as the db is not working #167

Open ramoseh opened 1 year ago

ramoseh commented 1 year ago

when selecting the mysql database, the installation breaks in this line:

  • Installing mysqlclient (2.1.1): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel

  /bin/sh: mysql_config: command not found
  /bin/sh: mariadb_config: command not found
  /bin/sh: mysql_config: command not found
  mysql_config --version
  mariadb_config --version
  mysql_config --libs
  Traceback (most recent call last):
    File "/Users/hectorramos/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/Users/hectorramos/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/hectorramos/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
             ^^^^^^^^^^^^^^^^^^^^^
    File "/var/folders/91/cbx_6wfx1xjfxd27x0kfmd680000gn/T/tmp3w8km71r/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/var/folders/91/cbx_6wfx1xjfxd27x0kfmd680000gn/T/tmp3w8km71r/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
      self.run_setup()
    File "/var/folders/91/cbx_6wfx1xjfxd27x0kfmd680000gn/T/tmp3w8km71r/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 488, in run_setup
      self).run_setup(setup_script=setup_script)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/var/folders/91/cbx_6wfx1xjfxd27x0kfmd680000gn/T/tmp3w8km71r/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 15, in <module>
    File "/private/var/folders/91/cbx_6wfx1xjfxd27x0kfmd680000gn/T/tmpldu16aav/mysqlclient-2.1.1/setup_posix.py", line 70, in get_config
      libs = mysql_config("libs")
             ^^^^^^^^^^^^^^^^^^^^
    File "/private/var/folders/91/cbx_6wfx1xjfxd27x0kfmd680000gn/T/tmpldu16aav/mysqlclient-2.1.1/setup_posix.py", line 31, in mysql_config
      raise OSError("{} not found".format(_mysql_config_path))
  OSError: mysql_config not found

  at ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/chef.py:147 in _prepare
      143│ 
      144│                 error = ChefBuildError("\n\n".join(message_parts))
      145│ 
      146│             if error is not None:
    → 147│                 raise error from None
      148│ 
      149│             return path
      150│ 
      151│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with mysqlclient (2.1.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "mysqlclient (==2.1.1)"'.

  • Installing pre-commit (3.3.2)

an from that point poetry lock is not created correctly.

s3rius commented 1 year ago

Hi and thanks for creating this issue. This problem is not with FastAPI-template. Please install mysql_config package. It's required for building mysql library for python.