# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['kintree',
 'kintree.common',
 'kintree.config',
 'kintree.database',
 'kintree.kicad',
 'kintree.kicad.lib_utils',
 'kintree.search',
 'kintree.wrapt_timeout_decorator']

package_data = \
{'': ['*'],
 'kintree.config': ['digikey/*',
                    'element14/*',
                    'inventree/*',
                    'kicad/*',
                    'lcsc/*',
                    'mouser/*',
                    'search/*',
                    'settings/*'],
 'kintree.kicad': ['templates/*', 'templates_project/*']}

install_requires = \
['PySimpleGUI>=4.60.4,<5.0.0',
 'PyYAML>=5.4.1,<6.0.0',
 'digikey-api>=1.0.0,<2.0.0',
 'fuzzywuzzy>=0.18.0,<0.19.0',
 'inventree>=0.9.2,<0.10.0',
 'mouser>=0.1.2,<0.2.0',
 'multiprocess>=0.70.14,<0.71.0',
 'python-Levenshtein>=0.12.2,<0.13.0',
 'validators>=0.19.0,<0.20.0',
 'wrapt>=1.14.1,<2.0.0']

entry_points = \
{'console_scripts': ['kintree = kintree.kintree_gui:main',
                     'kintree_setup_inventree = '
                     'kintree.setup_inventree:setup_inventree']}

setup_kwargs = {
    'name': 'kintree',
    'version': '0.6.6',
    'description': 'Fast part creation in KiCad and InvenTree',
    'long_description': '# Ki-nTree\n### Fast part creation in [KiCad](https://kicad.org/) and [InvenTree](https://inventree.readthedocs.io/) \n[![License: GPL v3.0](https://img.shields.io/badge/license-GPL_v3.0-green.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Python Versions](https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/python_versions.svg)](https://www.python.org/)\n[![PyPI](https://img.shields.io/pypi/v/kintree)](https://pypi.org/project/kintree/)\n[![Tests | Linting | Publishing](https://github.com/sparkmicro/Ki-nTree/actions/workflows/test_deploy.yaml/badge.svg)](https://github.com/sparkmicro/Ki-nTree/actions)\n[![Coverage Status](https://coveralls.io/repos/github/sparkmicro/Ki-nTree/badge.svg?branch=main&service=github)](https://coveralls.io/github/sparkmicro/Ki-nTree?branch=main)\n\n## Demo Videos :fast_forward: [Full Demo](https://youtu.be/haSAu926BOI) :fast_forward: [KiCad Demo](https://youtu.be/NSMfCCD0uVw)\n\n<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_example.png"  width="auto" height="auto">\n\n## Introduction\nKi-nTree (pronounced "Key Entry" or "Key \'n\' Tree") aims to:\n* automate part creation of KiCad library parts\n* automate part creation of InvenTree parts\n* synchronize parts data between KiCad and InvenTree\n\nKi-nTree works with:\n- [Digi-Key](https://developer.digikey.com/), [Mouser](https://www.mouser.com/api-hub/), [Element14](https://partner.element14.com/docs) and [LCSC](https://lcsc.com/) **enormous** part databases and free APIs\n- the awesome open-source [Digi-Key API python library](https://github.com/peeter123/digikey-api) built and maintained by [@peeter123](https://github.com/peeter123)\n- the [Mouser Python API](https://github.com/sparkmicro/mouser-api/) built and maintained by [@eeintech](https://github.com/eeintech)\n- the awesome open-source [InvenTree Inventory Management System](https://github.com/inventree/inventree) built and maintained by [@SchrodingersGat](https://github.com/SchrodingersGat)\n- [KiCad](https://www.kicad.org/) (of course!) and their open-source [library utils](https://gitlab.com/kicad/libraries/kicad-library-utils)\n\n> **Important Note**\n>\n> Because of limited maintenance bandwidth, Ki-nTree versions `0.5.x` and newer will only support KiCad version **6**.\n> To keep using Ki-nTree with KiCad version **5**, use older `0.4.x` versions (`pip install kintree==0.4.8`).\n\nKi-nTree was developped by [@eeintech](https://github.com/eeintech) for [SPARK Microsystems](https://www.sparkmicro.com/), who generously accepted to make it open-source!\n\n## Get Started\n\n### Requirements\n\n* Ki-nTree is currently tested for Python 3.8 to 3.10 versions.\n* Ki-nTree requires a Digi-Key **production** API instance. To create one, go to https://developer.digikey.com/. Create an account, an organization and add a **production** API to your organization. Save both Client ID and Secret keys.\n> [Here is a video](https://youtu.be/OI1EGEc0Ju0) to help with the different steps\n* Ki-nTree requires a Mouser Search API key. To request one, head over to https://www.mouser.ca/api-search/ and click on "Sign Up for Search API"\n* Ki-nTree requires an Element14 Product Search API key to fetch part information for the following suppliers: Farnell (Europe), Newark (North America) and Element14 (Asia-Pacific). To request one, head over to https://partner.element14.com/ and click on "Register"\n\n### Installation (system wide)\n\n1. Install using Pip\n\n``` bash\npip install -U kintree\n```\n\n2. Run Ki-nTree\n\n``` bash\nkintree\n```\n\n### Run in virtual environment (contained)\n\n##### Linux / MacOS\n\nCreate a virtual environment and activate it with:\n\n``` bash\n$ python3 -m venv env-kintree\n$ source env-kintree/bin/activate\n```\n\nThen follow the steps from the [installation section](#installation-system-wide).\n\n##### Windows\n\nIn Git Bash, use the following commands to create and activate a virtual environment:\n``` bash\n$ python3 -m venv env-kintree\n$ source env-kintree/Scripts/activate\n```\nFor any other Windows terminal, refer to the [official documentation](https://docs.python.org/library/venv.html#creating-virtual-environments)\n\n### Packages\n#### Arch Linux\n\nKi-nTree is [available on Arch Linux\'s AUR](https://aur.archlinux.org/packages/python-kintree/) as `python-kintree`.\n\n### Usage Instructions\n\n> :warning: Warning: **KiCad library writer is still in development**: Make sure to open KiCad libraries inside the symbol editor and save them after adding symbols.\n\n#### Before Starting\n\nIf you intend to use Ki-nTree with InvenTree, this tool offers to setup the InvenTree category tree with a simple script that you can run as follow:\n\n> :warning: Warning: Before running it, make sure you have setup your category tree in your `categories.yaml` configuration file according to your own preferences, else it will use the [default setup](https://github.com/sparkmicro/Ki-nTree/blob/main/kintree/config/inventree/categories.yaml).\n\n``` bash\npython3 -m kintree.setup_inventree\n```\n\nIf the InvenTree category tree is **not setup** before starting to use Ki-nTree, you **won\'t be able to add parts** to InvenTree.\n\n#### Advanced Configuration\n\nConfiguration files are stored in the folder pointed by the `Configuration Files Folder` path in the "User Settings" window:\n\n<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/settings_user_cache.png" width="600" height="auto">\n\n\n<details>\n<summary><b>Click here to read about configuration files</b></summary>\n<p>\n\nKi-nTree uses a number of YAML configuration files to function. New users shouldn\'t need to worry about them to try out Ki-nTree (except for `categories.yaml` as mentioned in the previous section), however they can be modified to customize behavior and workflow.\n\nBelow is a summary table of the different configuration files, their function and if they are updated by the GUI:\n| Filename | Function | GUI Update? |\n| --- | --- | --- |\n| `categories.yaml` | InvenTree categories hierarchy tree and category codes for IPN generation (see [Before Starting section](#before-starting)) | :x: |\n| `general.yaml` | General user settings | _Partial_ |\n| `internal_part_number.yaml` | Controls for IPN generation | :x: |\n| `inventree_<env>.yaml` | InvenTree login credentials, per environment (`<env>=[\'dev\', \'prod\']`) | :heavy_check_mark: |\n| `kicad.yaml` | KiCad symbol, footprint and library paths | :heavy_check_mark: |\n| `kicad_map.yaml` | Mapping between InvenTree parent categories and KiCad symbol/footprint libraries and templates | :x: |\n| `parameters.yaml` | List of InvenTree parameters templates (see [InvenTree Part Parameters documentation](https://docs.inventree.org/en/latest/part/parameter/)) | :x: |\n| `parameters_filters.yaml` | Mapping between InvenTree parent categories and InvenTree parameters templates | :x: |\n| `search_api.yaml` | Generic controls for Supplier search APIs like cache validity and category matching ratio | :x: |\n| `supplier_parameters.yaml` | Mapping between InvenTree parameters templates and suppliers parameters/attributes, sorted by InvenTree parent categories (see [Part Parameters section](#part-parameters)) | :x: |\n| `<supplier>_config.yaml` | Mapping for supplier name and search results fields, to overwrite defaults (`<supplier>=[\'digikey\', \'element14\', \'lcsc\', \'mouser\']`) | :x: |\n| `<supplier>_api.yaml` | Required supplier API fields, custom to each supplier (`<supplier>=[\'digikey\', \'element14\', \'lcsc\', \'mouser\']`) | :heavy_check_mark: |\n| `digikey_categories.yaml` | Mapping between InvenTree categories and Digi-Key categories | :heavy_check_mark: |\n| `digikey_parameters.yaml` | Mapping between InvenTree parameters and Digi-Key parameters/attributes | :x: |\n\n> In versions `0.6.x` and older, Ki-nTree only supports matching between InvenTree and Digi-Key categories and parameters/attibutes (help wanted!)\n\n</p>\n</details>\n\n#### InvenTree Permissions\n\nEach InvenTree user has a set of permissions associated to them.\nPlease refer to the [InvenTree documentation](https://inventree.readthedocs.io/en/latest/settings/permissions/) to understand how to setup user permissions.\n\nThe minimum set of user/group permission required to add parts to InvenTree is:\n- "Part - Add" to add InvenTree parts\n- "Purchase Orders - Add" to add manufacturers, suppliers and their associated parts\n\nIf you wish to automatically add subcategories while creating InvenTree parts, you will need to enable the "Part Categories - Add" permission.\n\nNote that each time you enable the "Add" permission to an object, InvenTree automatically enables the "Change" permission to that object too.\n\n#### Settings\n1. With Ki-nTree GUI open, click on "Settings > Supplier > Digi-Key" and fill in both Digi-Key API Client ID and Secret keys (optional: click on "Test" to [get an API token](#get-digi-key-api-token))\n2. Click on "Settings > Supplier > Mouser" and fill in the Mouser part search API key\n3. Click on "Settings > Supplier > Element14" and fill in the Element14 product search API key (key is shared with Farnell and Newark)\n4. Click on "Settings > KiCad", browse to the location where KiCad symbol, template and footprint libraries are stored on your computer then click "Save"\n5. If you intend to use InvenTree with this tool, click on "Settings > InvenTree" and fill in your InvenTree server address and credentials then click "Save" (optional: click on "Test" to get an API token)\n\n#### Get Digi-Key API token\n<details>\n<summary>Show steps (click to expand)</summary>\n<p>\n\nEnter your Digi-Key developper account credentials then login. The following page will appear (`user@email.com` will show your email address):\n\n<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/digikey_api_approval_request.png" width="600" height="auto">\n\nClick on "Allow", another page will open.  \nClick on the "Advanced" button, then click on "Proceed to localhost (unsafe)" at the bottom of the page:\n\n<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/digikey_api_approval_request2.png"  width="600" height="auto">\n\n> On Chrome, if the "Proceed to localhost (unsafe)" link does not appear, enable the following flag: [chrome://flags/#allow-insecure-localhost](chrome://flags/#allow-insecure-localhost)\n\nLastly, a new page will open with a "You may now close this window." message, proceed to get the token.\n\n</p>\n</details>\n\n#### Part Parameters\n\nKi-nTree uses **supplier** parameters to populate **InvenTree** parameters. In order to match between supplier and InvenTree, users need to setup the configuration file `supplier_parameters.yaml` with the following mapping for each category:\n``` yaml\nCATEGORY_NAME:\n  INVENTREE_PARAMETER_NAME:\n    - SUPPLIER_1_PARAMETER_NAME_1\n    - SUPPLIER_1_PARAMETER_NAME_2\n    - SUPPLIER_2_PARAMETER_NAME_1\n```\n\nRefer to [this file](https://github.com/sparkmicro/Ki-nTree/blob/main/kintree/config/search/supplier_parameters.yaml) as a starting point / example.\n\n#### Part Number Search\n\nKi-nTree currently supports APIs for the following electronics suppliers: Digi-Key, Mouser, Element14 and LCSC.\n\n1. In the main window, enter the part number and select the supplier in drop-down list, then click "CREATE". It will start by fetching part data using the supplier\'s API\n2. In the case Digi-Key has been selected and the API token is not found or expired, a browser window will pop-up. To get a new token: [follow those steps](#get-digi-key-api-token)\n3. Once the part data has been successfully fetched from the supplier\'s API, you will be prompted to add/confirm/edit the part information, followed by the `Category` and `Subcategory` to use for this part (Ki-nTree tries to match them automatically)\n4. Then, you will be prompted with selecting the KiCad symbol library, the template and the footprint library to use for this part\n5. It will take some time to complete the part creation in InvenTree and/or KiCad, once it finishes you\'ll be notified of the result  \n6. Finally, if the part was created or found in InvenTree, your browser will automatically open a new tab with the part information\n\nEnjoy!\n\n*For any problem/bug you find, please [report an issue](https://github.com/sparkmicro/Ki-nTree/issues).*\n\n## Development\n\n### Requirements\n\nYou need `python>=3.8` and `poetry`.\n\nYou can install poetry by following the instructions [on its official website](https://python-poetry.org/docs/master/#installation), by using `pip install poetry` or by installing a package on your Linux distro.\n\n### Setup and run\n1. Clone this repository\n``` bash\ngit clone https://github.com/sparkmicro/Ki-nTree\n```\n\n2. Install the requirements into a `poetry`-managed virtual environment\n``` bash\npoetry install\nInstalling dependencies from lock file\n...\nInstalling the current project: kintree (0.4.99)\n```\n> Note: the version is not accurate (placeholder only)\n\n3. Run Ki-nTree in the virtual environment\n```bash\npoetry run python -m kintree_gui\n```\nor\n\n```bash\n$ poetry shell\n$ python -m kintree_gui\n```\n\n#### Build\n1. Make sure you followed the previous installation steps, then run:\n``` bash\n$ poetry build\nBuilding kintree (0.6.99)\n  - Building sdist\n  - Built kintree-0.6.99.tar.gz\n  - Building wheel\n  - Built kintree-0.6.99-py3-none-any.whl\n```\n2. Exit the virtual environment (`Ctrl + D` on Linux; you can also close the\n   terminal and reopen it in the same folder).\n\n   Run `pip install dist/<wheel_file>.whl` with the file name from the previous\n   step. For example:\n\n```bash\npip install dist/kintree-0.6.99-py3-none-any.whl\n```\n\n3. You can now start Ki-nTree by typing `kintree` in the terminal, provided\n   that your python dist path is a part of your `$PATH`.\n\n## Roadmap\n\n> Priority goes to implementing new features over GUI improvements  \n> Open to new ideas and pull requests :smiley:\n\n#### Versions 1.0.x or later\n##### New Features\n\n- Revamp category selection based on hierarchical structure from InvenTree ([reference](https://github.com/sparkmicro/Ki-nTree/issues/87)) \n- Allow user to decide the category code to use for IPN\n- Enable option to download and save PDF files locally/to internal server storage\n\n##### Improvements\n\n- Optimize the category search ([reference](https://github.com/sparkmicro/Ki-nTree/issues/104))\n- Migrate KiCad library management to [KiUtils](https://github.com/mvnmgrx/kiutils) ([reference](https://github.com/sparkmicro/Ki-nTree/issues/119))\n\n##### GUI\n\n- Migrate to [Flet](https://github.com/flet-dev/flet) ([reference](https://github.com/sparkmicro/Ki-nTree/issues/37))\n\n## License\n\nThe Ki-nTree source code is licensed under the [GPL3.0 license](https://github.com/sparkmicro/Ki-nTree/blob/main/LICENSE) as it uses source code under that license:\n* https://gitlab.com/kicad/libraries/kicad-library-utils\n* https://github.com/peeter123/digikey-api\n\nThe [KiCad templates](https://github.com/sparkmicro/Ki-nTree/tree/main/kintree/kicad/templates) are licensed under the [Creative Commons CC0 1.0 license](https://github.com/sparkmicro/Ki-nTree/blob/main/kintree/kicad/templates/LICENSE) which means that "you can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission" ([reference](https://creativecommons.org/publicdomain/zero/1.0/)).',
    'author': 'eeintech',
    'author_email': 'eeintech@eeinte.ch',
    'maintainer': 'eeintech',
    'maintainer_email': 'eeintech@eeinte.ch',
    'url': 'https://github.com/sparkmicro/Ki-nTree',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.8,<3.11',
}


setup(**setup_kwargs)
