{% set name = "psycopg2" %}
{% set version = "2.9.1" %}

package:
  name: {{ name|lower }}-split
  version: {{ version }}

source:
  url: https://pypi.io/packages/source/p/psycopg2/psycopg2-{{ version }}.tar.gz
  sha256: de5303a6f1d0a7a34b9d40e4d3bef684ccc44a49bbe3eb85e3c0bffb4a131b7c
  patches:
    - have_openssl.patch

build:
  number: 0

outputs:
  - name: {{ name }}
    script: install_psycopg2.sh  # [unix]
    script: install_psycopg2.bat  # [win]
    requirements:
      build:
        - python                                 # [build_platform != target_platform]
        - cross-python_{{ target_platform }}     # [build_platform != target_platform]
        - postgresql                             # [build_platform != target_platform]
        - {{ compiler('c') }}
      host:
        - python
        - pip
        - openssl  # [not linux]
        - postgresql
      run:
        - python
        # libpq is a repackaging of only the library to connect to postgres
        - libpq
        - openssl  # [not linux]

    test:
      imports:
        - psycopg2
        - psycopg2._psycopg
      commands:
        - pip check
      requires:
        - pip

  # alternative name for the package, patched to rename the package in the
  # metadata so pip check will pass for packages that depend on pyscopg2-binary
  - name: psycopg2-binary
    script: install_psycopg2-binary.sh
    build:
      noarch: python
      skip: true  # [not linux or py!=38 or ppc64le or aarch64]
    requirements:
      host:
        - python >=3.6
        - pip
      run:
        - python >=3.6
        - {{ pin_subpackage(name, max_pin='x.x.x.x.x.x') }}
    test:
      imports:
        - psycopg2
      commands:
        - pip check
      requires:
        - pip

about:
  home: http://initd.org/psycopg/
  license: LGPL-3.0-or-later
  license_family: LGPL
  license_file: LICENSE
  summary: PostgreSQL database adapter for Python
  description: |
    Psycopg is the most popular PostgreSQL adapter for the Python programming
    language. Its main features are the complete implementation of the Python DB
    API 2.0 specification and the thread safety.
  doc_url: http://initd.org/psycopg/docs/
  doc_source_url: https://github.com/psycopg/psycopg2/blob/master/doc/src/index.rst
  dev_url: https://github.com/psycopg/psycopg2/

extra:
  recipe-maintainers:
    - msarahan
    - ocefpaf
    - xylar
