# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               python 1.0

name                    py-scrapy
version                 2.5.0
revision                1
# epoch needed due to previous downgrading version
epoch                   1
maintainers             {khindenburg @kurthindenburg} openmaintainer
platforms               darwin
license                 BSD

description             A high-level Web Crawling and Web Scraping framework
long_description        Scrapy is a high level scraping and web crawling \
                        framework for writing spiders to crawl and parse web \
                        pages for all kinds of purposes, from information \
                        retrieval to monitoring or testing web sites.

homepage                https://pypi.python.org/pypi/${python.rootname}
distname                Scrapy-${version}
master_sites            pypi:[string index ${python.rootname} 0]/${python.rootname}/

checksums               rmd160  63a31248b7a5b769a6cca544f47e180ce3a5ed07 \
                        sha256  0a68ed41f7173679f160c4cef2db05288548c21e7164170552adae8b13cefaab \
                        size    1071824

python.versions 27 36 37 38 39

if {${name} ne ${subport}} {
    depends_build-append    port:py${python.version}-setuptools
    depends_lib-append      port:py${python.version}-cssselect \
                            port:py${python.version}-dispatcher \
                            port:py${python.version}-h2 \
                            port:py${python.version}-itemadapter \
                            port:py${python.version}-itemloaders \
                            port:py${python.version}-lxml \
                            port:py${python.version}-openssl \
                            port:py${python.version}-parsel \
                            port:py${python.version}-priority \
                            port:py${python.version}-protego \
                            port:py${python.version}-queuelib \
                            port:py${python.version}-service_identity \
                            port:py${python.version}-twisted \
                            port:py${python.version}-w3lib \
                            port:py${python.version}-zopeinterface

    # Note testing is currently broken; if you want to test:
    # 0) Install the version you want to use
    # 1) change 'if 0' to 'if 1'
    # 2) run port test pyXX-scrapy
    # 3) once it adds all dependents, Ctrl-C
    # 4) cd work/Scrapy-version
    # 5) py.test-version -vvv
    # 6) Ctrl-C and it should start - there will be a lot of failures
    # 7) Alternatively, run some basic commands using py-scrapy
    if {0} {
    depends_test-append \
        port:py${python.version}-pytest \
        port:py${python.version}-pytest-asyncio \
        port:py${python.version}-botocore \
        port:py${python.version}-jmespath \
        port:py${python.version}-leveldb \
        port:py${python.version}-pillow \
        port:py${python.version}-sybil \
        port:py${python.version}-testfixtures

    set pyver [join [split ${python.version} {}] {.}]
    test.run            yes
    test.cmd            py.test-${pyver}
    test.target
    test.env            PYTHONPATH=${worksrcpath}/build/lib
    }

    if {${python.version} eq 27} {
        version             1.8.0
        revision            0
        epoch               1
        # Below distname is required for this to work
        distname            Scrapy-${version}
        master_sites        https://files.pythonhosted.org/packages/source/S/Scrapy/

        checksums           rmd160  8cc9d59d8428fb948ed1463274bb895d09a86e38 \
                            sha256  fe06576f9a4971de9dc0175c60fd92561e8275f2bad585c1cb5d65c5181b2db0 \
                            size    977658

        depends_lib-append  port:py${python.version}-functools32
        depends_lib-delete  port:py${python.version}-itemadapter \
                            port:py${python.version}-itemloaders

        test.run            no
        livecheck.type      none
    }

    livecheck.type          none
} else {
    livecheck.type          pypi
}
