Elasticbeanstalk with MySQL (deploying Django app)

0

Having a bit of a mare trying to deploy my Django app to Elasticbeanstalk AWS

I'm getting issues related to the installation of mysql. See log files:


----------------------------------------
/var/log/eb-engine.log
----------------------------------------
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      Trying pkg-config --exists mysqlclient
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
      Trying pkg-config --exists mariadb
      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
      Trying pkg-config --exists libmariadb
      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
      Traceback (most recent call last):
        File "/var/app/venv/staging-LQM1lest/lib64/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/var/app/venv/staging-LQM1lest/lib64/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/var/app/venv/staging-LQM1lest/lib64/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-0u1shkl5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-0u1shkl5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-0u1shkl5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 155, in <module>
        File "<string>", line 49, in get_config_posix
        File "<string>", line 28, in find_package_name
      Exception: Can not find valid pkg-config name.
      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
      [end of output]

My Python pip requirements file is:

beautifulsoup4==4.12.3
bs4==0.0.2
Django==2.2
gunicorn==20.1.0
mysqlclient==2.2.4
numpy==1.24.4
pandas==2.0.3
python-dateutil==2.9.0.post0
pytz==2024.1
six==1.16.0
soupsieve==2.5
sqlparse==0.4.4
tzdata==2024.1
whitenoise==6.4.0

and I've also specified the SQL flags in an addition .config file in the .ebextensions folder

option_settings:
  aws:elasticbeanstalk:application:environment:
    MYSQLCLIENT_CFLAGS: "-I/usr/include/mysql"
    MYSQLCLIENT_LDFLAGS: "-L/usr/lib64/mysql"

as well as yum package installation files in another:

packages:  
  yum:
    python3-devel: []
    mariadb-devel.x86_64: []
    mariadb.x86_64: []
    gcc: []

NOTE - Available yum packages related to MySQL

MySQL-python.x86_64 : An interface to MySQL
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
dovecot-mysql.x86_64 : MySQL back end for dovecot
freeradius-mysql.x86_64 : MySQL support for freeradius
libdbi-dbd-mysql.x86_64 : MySQL plugin for libdbi
mysql-connector-java.noarch : Official JDBC driver for MySQL
mysql-connector-odbc.x86_64 : ODBC driver for MySQL
pcp-pmda-mysql.x86_64 : Performance Co-Pilot (PCP) metrics for MySQL
perl-DBD-MySQL.x86_64 : A MySQL interface for Perl
php-mysql.x86_64 : A module for PHP applications that use MySQL databases
php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
qt-mysql.x86_64 : MySQL driver for Qt's SQL classes
qt-mysql.i686 : MySQL driver for Qt's SQL classes
qt3-MySQL.x86_64 : MySQL drivers for Qt 3's SQL classes
qt3-MySQL.i686 : MySQL drivers for Qt 3's SQL classes
qt5-qtbase-mysql.x86_64 : MySQL driver for Qt5's SQL classes
qt5-qtbase-mysql.i686 : MySQL driver for Qt5's SQL classes
redland-mysql.x86_64 : MySQL storage support for Redland
rsyslog-mysql.x86_64 : MySQL support for rsyslog
mariadb.x86_64 : A community developed branch of MySQL
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients

Some guidance on how to move forward would be appreciated, as I've been stuck playing with different options for a while

wmbm
asked a month ago140 views
1 Answer
1

Here is an example .ebextensions/mysqlclient.config file that installs the necessary packages:

packages:
  yum:
    mysql-devel: []
  # Uncomment the following lines if you are using a Debian-based distribution
  # apt:
  #   libmysqlclient-dev: []
commands:
  set_mysqlclient_env:
    command: |
      echo "export MYSQLCLIENT_CFLAGS=$(mysql_config --cflags)" >> /opt/elasticbeanstalk/hooks/appdeploy/pre/00_set_mysqlclient_env.sh
      echo "export MYSQLCLIENT_LDFLAGS=$(mysql_config --libs)" >> /opt/elasticbeanstalk/hooks/appdeploy/pre/00_set_mysqlclient_env.sh

Sets the MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS environment variables using the output of mysql_config, which provides the compiler options needed to compile the client.

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
Artem
reviewed a month ago
  • As far as my research goes, only mariadb-devel.x86_64 and mariadb.x86_64 are available on the yum package list for this environment (which contain mysql) -> See list of mysql yum packages above

  • try to add this after your mariadb installation

    commands: set_mysqlclient_env: command: | echo "export MYSQLCLIENT_CFLAGS=$(mysql_config --cflags)" >> /opt/elasticbeanstalk/hooks/appdeploy/pre/00_set_mysqlclient_env.sh echo "export MYSQLCLIENT_LDFLAGS=$(mysql_config --libs)" >> /opt/elasticbeanstalk/hooks/appdeploy/pre/00_set_mysqlclient_env.sh

  • Same error unfortunately. I have noticed that if I ssh into my instance the environmental varaibles for the sql flags are empty.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions