# Copyright (C) 2019-2022 HERE Global B.V. and its affiliate(s).
# All rights reserved.
#
# This software and other materials contain proprietary information
# controlled by HERE and are protected by applicable copyright legislation.
# Any use and utilization of this software and other materials and
# disclosure to any third parties is conditional upon having a separate
# agreement with HERE for the access, use, utilization or disclosure of this
# software. In the absence of such agreement, the use of the software is not
# allowed.


"""This is the setup file as used by ``setuptools`` and ``pip``."""  # noqa E501

import pathlib

from setuptools import find_namespace_packages, setup

# Note this file is public: it's included in the output source distribution packages (sdist)

dirname = pathlib.Path(__file__).parent.resolve()

with open(dirname / "README.md", encoding="utf-8") as f:
    readme = f.read()

with open(dirname / "pyproject.toml", encoding="utf-8") as f:
    version_line = next(x for x in f.read().strip().split("\n") if x.startswith("version"))
    version = version_line.split('"')[1]

requirements = []
dependency_links = []

with open(dirname / "requirements.txt", encoding="utf-8") as f:
    for req in f.read().strip().split("\n"):
        if req.startswith("--extra-index-url"):
            url_params = req.strip().split()
            dependency_links.append(url_params[1])
        else:
            requirements.append(req)

# Filter requirements to remove pip configurable parameters
requirements = [x for x in requirements if x and "--" not in x and "#" not in x]

# Parameters are included in the `setup` call

pkg_name = "here-services"  # noqa E501
pkg_params: dict = {}

packages = find_namespace_packages(
    exclude=["tests", "tests.*", "platform-verification", "platform-verification.*"]
)

doc_url = "https://stg3.www.here.com/docs/de-DE/bundle/data-sdk-for-python-developer-guide-v2/page/README.html"  # noqa E501

setup(
    name=pkg_name,
    description="HERE Platform Python SDK, Services access package",
    version=version,
    url="https://here.com",
    author="HERE Global B.V. and its affiliate(s)",
    # SPDX-License-Identifier: LicenseRef-Proprietary-HERE
    license="HERE Proprietary License",
    long_description=readme,
    long_description_content_type="text/markdown",
    python_requires=">=3.9",
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Intended Audience :: Developers",
        "License :: Other/Proprietary License",
        "Natural Language :: English",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: Microsoft :: Windows",
        "Operating System :: POSIX",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Programming Language :: Python :: 3.12",
        "Programming Language :: Python :: 3 :: Only",
        "Programming Language :: Python :: Implementation :: CPython",
        "Programming Language :: Python :: Implementation :: PyPy",
        "Topic :: Scientific/Engineering :: GIS",
        "Topic :: Software Development :: Libraries",
        "Topic :: Software Development :: Libraries :: Python Modules",
    ],
    project_urls={
        "Documentation": doc_url,
        "Source": "ssh://git@main.gitlab.in.here.com:3389/sdk/pysdk-nagini.git",
    },
    packages=packages,
    install_requires=requirements,
    dependency_links=dependency_links,
    include_package_data=True,
    **pkg_params,
)
