kintree


Namekintree JSON
Version 1.0.7 PyPI version JSON
download
home_pagehttps://github.com/sparkmicro/Ki-nTree
SummaryFast part creation in KiCad and InvenTree
upload_time2024-03-05 20:51:06
maintainereeintech
docs_urlNone
authoreeintech
requires_python>=3.9,<3.12
licenseGPL-3.0-or-later
keywords inventree kicad digikey mouser component part create
VCS
bugtrack_url
requirements digikey-api Flet thefuzz inventree kiutils mouser multiprocess PyYAML validators wrapt_timeout_decorator
Travis-CI No Travis.
coveralls test coverage
            # <img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/logo.png" width="auto" height="32"> Ki-nTree
### Fast part creation for [KiCad](https://kicad.org/) and [InvenTree](https://inventree.org/) 
[![License: GPL v3.0](https://img.shields.io/badge/license-GPL_v3.0-green.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Python Versions](https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/python_versions.svg)](https://www.python.org/)
[![PyPI](https://img.shields.io/pypi/v/kintree)](https://pypi.org/project/kintree/)
[![Tests | Linting | Publishing](https://github.com/sparkmicro/Ki-nTree/actions/workflows/test_deploy.yaml/badge.svg)](https://github.com/sparkmicro/Ki-nTree/actions)
[![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)

## :warning: InvenTree Compatibility
InvenTree `0.12` introduced a new parameter template system which was not supported until version `0.12.6` came out, see https://github.com/sparkmicro/Ki-nTree/issues/165 for more details. In short, Ki-nTree currently supports InvenTree `0.11` or older versions, and `0.12.6` and future versions. From `0.13.0` onwards a InvenTree setting needs to be modified for Ki-nTree to work: `InvenTree Settings` -> `Part Parameters` -> `Enforce Parameter Units` -> **OFF** (requires administrator rights)

## :fast_forward: [Demo Video](https://youtu.be/YeWBqOCb4pw)

<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_v1_example.png" width="auto" height="auto">

## Introduction
Ki-nTree (pronounced "Key Entry" or "Key 'n' Tree") aims to:
* automate part creation of KiCad library parts
* automate part creation of InvenTree parts
* synchronize parts data between KiCad and InvenTree

Ki-nTree works with:
- [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
- the awesome open-source [InvenTree Inventory Management System](https://github.com/inventree/inventree) built and maintained by [@SchrodingersGat](https://github.com/SchrodingersGat) and [@matmair](https://github.com/matmair)
- the reliable and SCM-friendly KiCad file parser [KiUtils](https://github.com/mvnmgrx/kiutils) built and maintained by [@mvnmgrx](https://github.com/mvnmgrx)
- the amazing [Digi-Key API python library](https://github.com/peeter123/digikey-api) built and maintained by [@peeter123](https://github.com/peeter123)
- the [Mouser Python API](https://github.com/sparkmicro/mouser-api/) built and maintained by [@eeintech](https://github.com/eeintech)

> :warning: **Important Note**
>
> Ki-nTree version `1.0.x` and forward support KiCad versions **6 and up**.
>
> Ki-nTree versions `0.5.x` and `0.6.x` only support KiCad version **6** (`pip install kintree==0.6.6`).
>
> To use with KiCad version **5**, use older Ki-nTree `0.4.x` versions (`pip install kintree==0.4.8`).

Ki-nTree was developed by [@eeintech](https://github.com/eeintech) for [SPARK Microsystems](https://www.sparkmicro.com/), who generously accepted to make it open-source!

## Get Started

### Requirements

* Ki-nTree is currently tested for Python 3.9 to 3.11 versions.
* 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.
> [Here is a video](https://youtu.be/OI1EGEc0Ju0) to help with the different steps
* 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"
* 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"

### Installation (system wide)

1. Install using Pip

``` bash
pip install -U kintree
```

2. Run Ki-nTree

``` bash
kintree
```

### Run in virtual environment (contained)

##### Linux / MacOS

Create a virtual environment and activate it with:

``` bash
$ python3 -m venv env-kintree
$ source env-kintree/bin/activate
```

Then follow the steps from the [installation section](#installation-system-wide).

##### Windows

In Git Bash, use the following commands to create and activate a virtual environment:
``` bash
$ python3 -m venv env-kintree
$ source env-kintree/Scripts/activate
```
For any other Windows terminal, refer to the [official documentation](https://docs.python.org/library/venv.html#creating-virtual-environments)

### Packages
#### Arch Linux

Ki-nTree is [available on Arch Linux's AUR](https://aur.archlinux.org/packages/python-kintree/) as `python-kintree`.

### Usage Instructions

#### Before Starting

If 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:

> :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).

``` bash
python3 -m kintree.setup_inventree
```

If the InvenTree category tree is **not setup** before starting to use Ki-nTree, you **won't be able to add parts** to InvenTree.

#### Advanced Configuration

Configuration files are stored in the folder pointed by the `Configuration Files Folder` path in the "User Settings" window:

<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_v1_settings_user.png" width="600" height="auto">

<details>
<summary><b>Click here to read about configuration files</b></summary>
<p>

Ki-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.

Below is a summary table of the different configuration files, their function and if they are updated by the GUI:
| Filename | Function | GUI Update? |
| --- | --- | --- |
| `categories.yaml` | InvenTree categories hierarchy tree and category codes for IPN generation (see [Before Starting section](#before-starting)) | :x: |
| `general.yaml` | General user settings | :heavy_check_mark: |
| `internal_part_number.yaml` | Controls for IPN generation | :heavy_check_mark: |
| `inventree_<env>.yaml` | InvenTree login credentials, per environment (`<env>=['dev', 'prod']`) | :heavy_check_mark: |
| `kicad.yaml` | KiCad symbol, footprint and library paths | :heavy_check_mark: |
| `kicad_map.yaml` | Mapping between InvenTree parent categories and KiCad symbol/footprint libraries and templates | :x: |
| `parameters.yaml` | List of InvenTree parameters templates (see [InvenTree Part Parameters documentation](https://docs.inventree.org/en/latest/part/parameter/)) | :x: |
| `parameters_filters.yaml` | Mapping between InvenTree parent categories and InvenTree parameters templates | :x: |
| `search_api.yaml` | Generic controls for Supplier search APIs like cache validity | :heavy_check_mark: |
| `supplier_parameters.yaml` | Mapping between InvenTree parameters templates and suppliers parameters/attributes, sorted by InvenTree parent categories (see [Part Parameters section](#part-parameters)) | :x: |
| `<supplier>_config.yaml` | Mapping for supplier name and search results fields, to overwrite defaults (`<supplier>=['digikey', 'element14', 'lcsc', 'mouser']`) | :x: |
| `<supplier>_api.yaml` | Required supplier API fields, custom to each supplier (`<supplier>=['digikey', 'element14', 'lcsc', 'mouser']`) | :heavy_check_mark: |
| `digikey_categories.yaml` | Mapping between InvenTree categories and Digi-Key categories | :x: |
| `digikey_parameters.yaml` | Mapping between InvenTree parameters and Digi-Key parameters/attributes | :x: |

> Ki-nTree only supports matching between InvenTree and Digi-Key categories and parameters/attributes (help wanted!)

</p>
</details>

#### InvenTree Permissions

Each InvenTree user has a set of permissions associated to them.
Please refer to the [InvenTree documentation](https://inventree.readthedocs.io/en/latest/settings/permissions/) to understand how to setup user permissions.

The minimum set of user/group permission required to add parts to InvenTree is:
- "Part - Add" to add InvenTree parts
- "Purchase Orders - Add" to add manufacturers, suppliers and their associated parts

If you wish to automatically add subcategories while creating InvenTree parts, you will need to enable the "Part Categories - Add" permission.

Note that each time you enable the "Add" permission to an object, InvenTree automatically enables the "Change" permission to that object too.

#### Settings
1. 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))
2. Click on "Settings > Supplier > Mouser" and fill in the Mouser part search API key
3. Click on "Settings > Supplier > Element14" and fill in the Element14 product search API key (key is shared with Farnell and Newark)
4. Click on "Settings > KiCad", browse to the location where KiCad symbol, template and footprint libraries are stored on your computer then click "Save"
5. 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 check communication with server)  
  a. It is possible to define a Proxy Server over which all interactions with InvenTree will be routed. To set a proxy server use the "Enable Proxy Support" switch in "Settings > InvenTree" and define the proxy address in the new input field.  
  b. Instead of user credential authentication token authentication is also supported. To use a token add it it to the "Password or Token" field and leave the "Username" empty. You can retrieve your personal access token from your InvenTree server by sending an get-request to its api url `api/user/token/`.
  c. If needed this tool can try to download the parts datasheet from the suppliers and upload it it to the attachment section of each part. For this just activate "Upload Datasheets to InvenTree" in the InvenTree settings
  d. It is also possible to sync the prices in InvenTree with the latest supplier prices. For this enable "Upload Pricing Data to InvenTree"
6. If your InvenTree server requires a IPN in a specific pattern make sure to adjust "Settings > InvenTree > Internal Part Number" to match it or adjust the servers pattern to the one yo set in Ki-nTree 


#### Get Digi-Key API token
<details>
<summary>Show steps (click to expand)</summary>
<p>

Enter your Digi-Key developer account credentials then login. The following page will appear (`user@email.com` will show your email address):

<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/digikey_api_approval_request.png" width="600" height="auto">

Click on "Allow", another page will open.  
Click on the "Advanced" button, then click on "Proceed to localhost (unsafe)" at the bottom of the page:

<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/digikey_api_approval_request2.png"  width="600" height="auto">

> 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)

Lastly, a new page will open with a "You may now close this window." message, proceed to get the token.

</p>
</details>

#### Part Parameters

Ki-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:
``` yaml
CATEGORY_NAME:
  INVENTREE_PARAMETER_NAME:
    - SUPPLIER_1_PARAMETER_NAME_1
    - SUPPLIER_1_PARAMETER_NAME_2
    - SUPPLIER_2_PARAMETER_NAME_1
```

It is also possible to cross reference the mappings of different categories. To define one or multiple parent categories a parameter named `parent` can be added where the items then are the desired parent categories. If a parameter name is present in both parent and child, the childs definition will override the parent.

A template image for an category can be set by using the `image` parameter. The sole item in this parameter must the filename of an already existing part image on the the InvenTree server.

Refer to [this file](https://github.com/sparkmicro/Ki-nTree/blob/main/kintree/config/inventree/supplier_parameters.yaml) as a starting point / example.

#### Part Number Search

Ki-nTree currently supports APIs for the following electronics suppliers: Digi-Key, Mouser, Element14, TME and LCSC.

1. 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
2. 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)
3. 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)
4. Then, you will be prompted with selecting the KiCad symbol library, the template and the footprint library to use for this part
5. 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  
6. Finally, if the part was created or found in InvenTree, your browser will automatically open a new tab with the part information

#### Kicad Templates

The automatic part generation in KiCad is controlled via templates:

* Template examples are shipped together with Ki-nTree, these can be adjusted to your liking or you also can create completely new ones.
* Each template has its own library file where the file name defines the templates name.
* The templates can use the parameters and attributes of the InvenTree part on a wildcard base. So you can add for example `Resistance@Tolerance` into a field and the resulting part will then have the resistance and the tolerance value inside this text field. 
* Using the templates and wildcards without the InvenTree functions enabled is also possible. In this case the library parameter wildcards need to be configured in the `supplier_parameters.yaml` for each library individually.


Enjoy!

*For any problem/bug you find, please [report an issue](https://github.com/sparkmicro/Ki-nTree/issues).*

## Development

### Requirements

You need `python>=3.9` and `poetry`.

You 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.

### Setup and run
1. Clone this repository
``` bash
git clone https://github.com/sparkmicro/Ki-nTree
```

2. Install the requirements into a `poetry`-managed virtual environment
``` bash
poetry install
Installing dependencies from lock file
...
Installing the current project: kintree (1.0.99)
```
> Note: the version is not accurate (placeholder only)

3. Run Ki-nTree in the virtual environment
```bash
poetry run python -m kintree_gui
```
or

```bash
$ poetry shell
$ python -m kintree_gui
```

#### Build
1. Make sure you followed the previous installation steps, then run:
``` bash
$ poetry build
Building kintree (1.0.99)
  - Building sdist
  - Built kintree-1.0.99.tar.gz
  - Building wheel
  - Built kintree-1.0.99-py3-none-any.whl
```
2. Exit the virtual environment (`Ctrl + D` on Linux; you can also close the
   terminal and reopen it in the same folder).

   Run `pip install dist/<wheel_file>.whl` with the file name from the previous
   step. For example:

```bash
pip install dist/kintree-1.0.99-py3-none-any.whl
```

3. You can now start Ki-nTree by typing `kintree` in the terminal, provided
   that your python dist path is a part of your `$PATH`.

## License
The 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:
* https://github.com/mvnmgrx/kiutils
* https://github.com/peeter123/digikey-api

The [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/)).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sparkmicro/Ki-nTree",
    "name": "kintree",
    "maintainer": "eeintech",
    "docs_url": null,
    "requires_python": ">=3.9,<3.12",
    "maintainer_email": "eeintech@eeinte.ch",
    "keywords": "inventree,kicad,digikey,mouser,component,part,create",
    "author": "eeintech",
    "author_email": "eeintech@eeinte.ch",
    "download_url": "https://files.pythonhosted.org/packages/1b/6f/bc2ee0d104e646b9d232e2103760c6ee220e5dba23248ff7318318ede0aa/kintree-1.0.7.tar.gz",
    "platform": null,
    "description": "# <img src=\"https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/logo.png\" width=\"auto\" height=\"32\"> Ki-nTree\n### Fast part creation for [KiCad](https://kicad.org/) and [InvenTree](https://inventree.org/) \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## :warning: InvenTree Compatibility\nInvenTree `0.12` introduced a new parameter template system which was not supported until version `0.12.6` came out, see https://github.com/sparkmicro/Ki-nTree/issues/165 for more details. In short, Ki-nTree currently supports InvenTree `0.11` or older versions, and `0.12.6` and future versions. From `0.13.0` onwards a InvenTree setting needs to be modified for Ki-nTree to work: `InvenTree Settings` -> `Part Parameters` -> `Enforce Parameter Units` -> **OFF** (requires administrator rights)\n\n## :fast_forward: [Demo Video](https://youtu.be/YeWBqOCb4pw)\n\n<img src=\"https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_v1_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 [InvenTree Inventory Management System](https://github.com/inventree/inventree) built and maintained by [@SchrodingersGat](https://github.com/SchrodingersGat) and [@matmair](https://github.com/matmair)\n- the reliable and SCM-friendly KiCad file parser [KiUtils](https://github.com/mvnmgrx/kiutils) built and maintained by [@mvnmgrx](https://github.com/mvnmgrx)\n- the amazing [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\n> :warning: **Important Note**\n>\n> Ki-nTree version `1.0.x` and forward support KiCad versions **6 and up**.\n>\n> Ki-nTree versions `0.5.x` and `0.6.x` only support KiCad version **6** (`pip install kintree==0.6.6`).\n>\n> To use with KiCad version **5**, use older Ki-nTree `0.4.x` versions (`pip install kintree==0.4.8`).\n\nKi-nTree was developed 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.9 to 3.11 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#### 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/kintree_v1_settings_user.png\" width=\"600\" height=\"auto\">\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 | :heavy_check_mark: |\n| `internal_part_number.yaml` | Controls for IPN generation | :heavy_check_mark: |\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 | :heavy_check_mark: |\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 | :x: |\n| `digikey_parameters.yaml` | Mapping between InvenTree parameters and Digi-Key parameters/attributes | :x: |\n\n> Ki-nTree only supports matching between InvenTree and Digi-Key categories and parameters/attributes (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 check communication with server)  \n  a. It is possible to define a Proxy Server over which all interactions with InvenTree will be routed. To set a proxy server use the \"Enable Proxy Support\" switch in \"Settings > InvenTree\" and define the proxy address in the new input field.  \n  b. Instead of user credential authentication token authentication is also supported. To use a token add it it to the \"Password or Token\" field and leave the \"Username\" empty. You can retrieve your personal access token from your InvenTree server by sending an get-request to its api url `api/user/token/`.\n  c. If needed this tool can try to download the parts datasheet from the suppliers and upload it it to the attachment section of each part. For this just activate \"Upload Datasheets to InvenTree\" in the InvenTree settings\n  d. It is also possible to sync the prices in InvenTree with the latest supplier prices. For this enable \"Upload Pricing Data to InvenTree\"\n6. If your InvenTree server requires a IPN in a specific pattern make sure to adjust \"Settings > InvenTree > Internal Part Number\" to match it or adjust the servers pattern to the one yo set in Ki-nTree \n\n\n#### Get Digi-Key API token\n<details>\n<summary>Show steps (click to expand)</summary>\n<p>\n\nEnter your Digi-Key developer 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\nIt is also possible to cross reference the mappings of different categories. To define one or multiple parent categories a parameter named `parent` can be added where the items then are the desired parent categories. If a parameter name is present in both parent and child, the childs definition will override the parent.\n\nA template image for an category can be set by using the `image` parameter. The sole item in this parameter must the filename of an already existing part image on the the InvenTree server.\n\nRefer to [this file](https://github.com/sparkmicro/Ki-nTree/blob/main/kintree/config/inventree/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, TME 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\n#### Kicad Templates\n\nThe automatic part generation in KiCad is controlled via templates:\n\n* Template examples are shipped together with Ki-nTree, these can be adjusted to your liking or you also can create completely new ones.\n* Each template has its own library file where the file name defines the templates name.\n* The templates can use the parameters and attributes of the InvenTree part on a wildcard base. So you can add for example `Resistance@Tolerance` into a field and the resulting part will then have the resistance and the tolerance value inside this text field. \n* Using the templates and wildcards without the InvenTree functions enabled is also possible. In this case the library parameter wildcards need to be configured in the `supplier_parameters.yaml` for each library individually.\n\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.9` 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 (1.0.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 (1.0.99)\n  - Building sdist\n  - Built kintree-1.0.99.tar.gz\n  - Building wheel\n  - Built kintree-1.0.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-1.0.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## License\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://github.com/mvnmgrx/kiutils\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/)).\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "Fast part creation in KiCad and InvenTree",
    "version": "1.0.7",
    "project_urls": {
        "Homepage": "https://github.com/sparkmicro/Ki-nTree",
        "Repository": "https://github.com/sparkmicro/Ki-nTree"
    },
    "split_keywords": [
        "inventree",
        "kicad",
        "digikey",
        "mouser",
        "component",
        "part",
        "create"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67ad52ae858d437797e1f2f35aa568df2d9b2979576db92a23800f7aa13f68d8",
                "md5": "a670bf993bc505c1bc9cffdce232712a",
                "sha256": "b4bb373a941426c103f03736bd50719e54016e9fb65a3b68f96a0a5b44c40d55"
            },
            "downloads": -1,
            "filename": "kintree-1.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a670bf993bc505c1bc9cffdce232712a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<3.12",
            "size": 157956,
            "upload_time": "2024-03-05T20:51:04",
            "upload_time_iso_8601": "2024-03-05T20:51:04.661643Z",
            "url": "https://files.pythonhosted.org/packages/67/ad/52ae858d437797e1f2f35aa568df2d9b2979576db92a23800f7aa13f68d8/kintree-1.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b6fbc2ee0d104e646b9d232e2103760c6ee220e5dba23248ff7318318ede0aa",
                "md5": "7e4e90696b042593ec76c3ea66df7a1c",
                "sha256": "068759b238ee8bcd10701bd10bef90f21135a003d17f3b0233d0b29c49a9a237"
            },
            "downloads": -1,
            "filename": "kintree-1.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "7e4e90696b042593ec76c3ea66df7a1c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<3.12",
            "size": 134579,
            "upload_time": "2024-03-05T20:51:06",
            "upload_time_iso_8601": "2024-03-05T20:51:06.669125Z",
            "url": "https://files.pythonhosted.org/packages/1b/6f/bc2ee0d104e646b9d232e2103760c6ee220e5dba23248ff7318318ede0aa/kintree-1.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-05 20:51:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sparkmicro",
    "github_project": "Ki-nTree",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "digikey-api",
            "specs": [
                [
                    "<",
                    "2.0"
                ],
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "Flet",
            "specs": [
                [
                    "<",
                    "0.8"
                ],
                [
                    ">=",
                    "0.7.4"
                ]
            ]
        },
        {
            "name": "thefuzz",
            "specs": [
                [
                    "<",
                    "1.0"
                ],
                [
                    ">=",
                    "0.19.0"
                ]
            ]
        },
        {
            "name": "inventree",
            "specs": [
                [
                    ">=",
                    "0.12.1"
                ],
                [
                    "<",
                    "1.0"
                ]
            ]
        },
        {
            "name": "kiutils",
            "specs": [
                [
                    "<",
                    "2.0"
                ],
                [
                    ">=",
                    "1.4.0"
                ]
            ]
        },
        {
            "name": "mouser",
            "specs": [
                [
                    ">=",
                    "0.1.3"
                ],
                [
                    "<",
                    "1.0"
                ]
            ]
        },
        {
            "name": "multiprocess",
            "specs": [
                [
                    ">=",
                    "0.70.12"
                ],
                [
                    "<",
                    "0.71"
                ]
            ]
        },
        {
            "name": "PyYAML",
            "specs": [
                [
                    "<",
                    "7.0"
                ],
                [
                    ">=",
                    "6.0.1"
                ]
            ]
        },
        {
            "name": "validators",
            "specs": [
                [
                    "<",
                    "1.0"
                ],
                [
                    ">=",
                    "0.19.0"
                ]
            ]
        },
        {
            "name": "wrapt_timeout_decorator",
            "specs": [
                [
                    "<",
                    "2.0"
                ],
                [
                    ">=",
                    "1.3.12"
                ]
            ]
        }
    ],
    "lcname": "kintree"
}
        
Elapsed time: 0.20639s