freecad-stubs


Namefreecad-stubs JSON
Version 1.0.17 PyPI version JSON
download
home_page
SummaryPython stubs for FreeCAD
upload_time2024-02-06 03:56:02
maintainer
docs_urlNone
authorostr00000
requires_python>=3.6
licenseGPL-3.0
keywords freecad stubs
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # freecad-stubs

[![PyPI version](https://img.shields.io/pypi/v/freecad-stubs)](https://pypi.org/project/freecad-stubs/)
[![GitHub license](https://img.shields.io/github/license/ostr00000/freecad-stubs)](https://github.com/ostr00000/freecad-stubs/blob/main/LICENSE)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/freecad-stubs)](https://pypi.python.org/pypi/freecad-stubs/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)

Python stubs generated from FreeCAD source code.

## Install stubs

You can install all stubs for freeCAD packages by running:

```bash
python -m pip install freecad-stubs
```

If you installed this package,
then you probably develop some FreeCAD components/scripts.
You should remember to set up your IDE by adding path to the real FreeCAD libraries,
especially for modules written mainly in python (ex. `Draft`),
because this package does not provide stubs for that module :confused:
(yet - you may contribute).

Also note that `App` or `Gui` are only aliases available in FreeCAD.
To fully use advantage of stubs
you should always import a module you are referencing
(ex. `import FreeCADGui as Gui`).

## Generating stubs manually

Package on pypi always has stubs generated for the newest freecad (master branch).
If you need older version you may try to install specific version from pypi
or manually run a tool from this repository to generate stubs.

### Stub source

Stubs are generated based on several available info:

- `*Py.xml` files - mainly docstrings, argument names, properties.
- corresponding `*PyImp.cpp` file - argument types are extracted from C code.
- other `*.cpp` files - functions or modules.

Unfortunately not all typing information may be generated.
For example some objects are added dynamically.
There are also many special cases
therefore not all object are correctly mapped.
Moreover, some of C function has errors - invalid types, missing arguments
(you can see more these errors if you change logger flag in configuration
file `freecad-stubs/lib/freecad_stub_gen/config.py`)

### Stub Generation

1. Clone [freecad repository](https://github.com/FreeCAD/FreeCAD).

   ```shell
   git clone https://github.com/FreeCAD/FreeCAD.git
   ```

   #### Warning: FreeCAD repository has over `1.29 GB`

   You may download only these required folders:

   - /src/App
   - /src/Base
   - /src/Gui
   - /src/Main
   - /src/Mod

2. Clone this repository

   ```shell
   git clone https://github.com/ostr00000/freecad-stubs
   ```

3. Configure paths
   In the file `freecad-stubs/lib/freecad_stub_gen/config.py`
   set desired configuration:

   - `SOURCE_DIR` - `src` folder from FreeCAD repository,
   - `TARGET_DIR` - target folder where stubs should be generated.
     #### Warning: `TARGET_DIR` folder and its content may be removed when generating stubs.

4. Run the main file from this project in Python

   ```shell
   python freecad-stubs/lib/freecad_stub_gen/__main__.py
   ```

   Required python version: `>=3.11`.

### Adding stubs to python path

At this point stubs must be already generated.
There are a lot of possible methods. This is only example:

1. Copy stubs from `TARGET_DIR` to location of your choice. For example:.

   ```shell
   cp -r ./freecad_stubs "$HOME/.local/lib/python3.9/freecad_stubs"
   ```

2. Add location with stubs to python search path.
   For example:

   ```shell
   echo "$HOME/.local/lib/python3.9/freecad_stubs" > "$HOME/.local/lib/python3.9/site-packages/freecad_stubs.pth"
   ```

### Implementation progress

#### Stub source

- [x] generate class stub (xml files):
  - [x] property in xml,
  - [x] dynamic property added in cpp,
  - [x] method (+ static/class method),
  - [x] rich comparison (ex. `__eq__` method),
  - [x] number protocol (ex. `__add__` method),
- [x] generate class stub (cpp files):
  - [x] dynamically added in `init_type()`,
  - [ ] qt slots,
  - [x] qt signals,
- [x] generate functions stub (cpp files):
  - [x] declared in `PyMethodDef` array,
  - [x] dynamically added in module constructor (subclass `Py::ExtensionModule`),

#### Stub quality

- [x] found class/function/method name,
- [x] copy docstring (+ generate property docstring),
- [x] guess argument names from C code or from docstrings,
- [x] found function/method argument types based
  on [c-api](https://docs.python.org/3/c-api/arg.html),
- [x] argument default values,
- [x] function/method return type,
- [x] raised exception in docstrings,
- [x] property getter type,
- [x] property setter type,
- [x] add comment "This class can be imported" for importable classes,
- [x] dynamically generated exceptions,

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "freecad-stubs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "FreeCAD,stubs",
    "author": "ostr00000",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/c9/cb/97e0e797e6c73e7490286466c8e5c0d97f8b0c589eb6da739bb2b2c1c0a0/freecad-stubs-1.0.17.tar.gz",
    "platform": null,
    "description": "# freecad-stubs\n\n[![PyPI version](https://img.shields.io/pypi/v/freecad-stubs)](https://pypi.org/project/freecad-stubs/)\n[![GitHub license](https://img.shields.io/github/license/ostr00000/freecad-stubs)](https://github.com/ostr00000/freecad-stubs/blob/main/LICENSE)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/freecad-stubs)](https://pypi.python.org/pypi/freecad-stubs/)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n\nPython stubs generated from FreeCAD source code.\n\n## Install stubs\n\nYou can install all stubs for freeCAD packages by running:\n\n```bash\npython -m pip install freecad-stubs\n```\n\nIf you installed this package,\nthen you probably develop some FreeCAD components/scripts.\nYou should remember to set up your IDE by adding path to the real FreeCAD libraries,\nespecially for modules written mainly in python (ex. `Draft`),\nbecause this package does not provide stubs for that module :confused:\n(yet - you may contribute).\n\nAlso note that `App` or `Gui` are only aliases available in FreeCAD.\nTo fully use advantage of stubs\nyou should always import a module you are referencing\n(ex. `import FreeCADGui as Gui`).\n\n## Generating stubs manually\n\nPackage on pypi always has stubs generated for the newest freecad (master branch).\nIf you need older version you may try to install specific version from pypi\nor manually run a tool from this repository to generate stubs.\n\n### Stub source\n\nStubs are generated based on several available info:\n\n- `*Py.xml` files - mainly docstrings, argument names, properties.\n- corresponding `*PyImp.cpp` file - argument types are extracted from C code.\n- other `*.cpp` files - functions or modules.\n\nUnfortunately not all typing information may be generated.\nFor example some objects are added dynamically.\nThere are also many special cases\ntherefore not all object are correctly mapped.\nMoreover, some of C function has errors - invalid types, missing arguments\n(you can see more these errors if you change logger flag in configuration\nfile `freecad-stubs/lib/freecad_stub_gen/config.py`)\n\n### Stub Generation\n\n1. Clone [freecad repository](https://github.com/FreeCAD/FreeCAD).\n\n   ```shell\n   git clone https://github.com/FreeCAD/FreeCAD.git\n   ```\n\n   #### Warning: FreeCAD repository has over `1.29 GB`\n\n   You may download only these required folders:\n\n   - /src/App\n   - /src/Base\n   - /src/Gui\n   - /src/Main\n   - /src/Mod\n\n2. Clone this repository\n\n   ```shell\n   git clone https://github.com/ostr00000/freecad-stubs\n   ```\n\n3. Configure paths\n   In the file `freecad-stubs/lib/freecad_stub_gen/config.py`\n   set desired configuration:\n\n   - `SOURCE_DIR` - `src` folder from FreeCAD repository,\n   - `TARGET_DIR` - target folder where stubs should be generated.\n     #### Warning: `TARGET_DIR` folder and its content may be removed when generating stubs.\n\n4. Run the main file from this project in Python\n\n   ```shell\n   python freecad-stubs/lib/freecad_stub_gen/__main__.py\n   ```\n\n   Required python version: `>=3.11`.\n\n### Adding stubs to python path\n\nAt this point stubs must be already generated.\nThere are a lot of possible methods. This is only example:\n\n1. Copy stubs from `TARGET_DIR` to location of your choice. For example:.\n\n   ```shell\n   cp -r ./freecad_stubs \"$HOME/.local/lib/python3.9/freecad_stubs\"\n   ```\n\n2. Add location with stubs to python search path.\n   For example:\n\n   ```shell\n   echo \"$HOME/.local/lib/python3.9/freecad_stubs\" > \"$HOME/.local/lib/python3.9/site-packages/freecad_stubs.pth\"\n   ```\n\n### Implementation progress\n\n#### Stub source\n\n- [x] generate class stub (xml files):\n  - [x] property in xml,\n  - [x] dynamic property added in cpp,\n  - [x] method (+ static/class method),\n  - [x] rich comparison (ex. `__eq__` method),\n  - [x] number protocol (ex. `__add__` method),\n- [x] generate class stub (cpp files):\n  - [x] dynamically added in `init_type()`,\n  - [ ] qt slots,\n  - [x] qt signals,\n- [x] generate functions stub (cpp files):\n  - [x] declared in `PyMethodDef` array,\n  - [x] dynamically added in module constructor (subclass `Py::ExtensionModule`),\n\n#### Stub quality\n\n- [x] found class/function/method name,\n- [x] copy docstring (+ generate property docstring),\n- [x] guess argument names from C code or from docstrings,\n- [x] found function/method argument types based\n  on [c-api](https://docs.python.org/3/c-api/arg.html),\n- [x] argument default values,\n- [x] function/method return type,\n- [x] raised exception in docstrings,\n- [x] property getter type,\n- [x] property setter type,\n- [x] add comment \"This class can be imported\" for importable classes,\n- [x] dynamically generated exceptions,\n",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "Python stubs for FreeCAD",
    "version": "1.0.17",
    "project_urls": {
        "repository": "https://github.com/ostr00000/freecad-stubs"
    },
    "split_keywords": [
        "freecad",
        "stubs"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed450b128d38e770a4d9b755bc0459985403179b11685d591db763147526c145",
                "md5": "d0956fd517d26031ecd44aa071ae8d98",
                "sha256": "036861aaa912c4d5f9c60d907bf92b83095dd7cb08f3dc7dd41faeac93dd850b"
            },
            "downloads": -1,
            "filename": "freecad_stubs-1.0.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0956fd517d26031ecd44aa071ae8d98",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 213523,
            "upload_time": "2024-02-06T03:55:59",
            "upload_time_iso_8601": "2024-02-06T03:55:59.902972Z",
            "url": "https://files.pythonhosted.org/packages/ed/45/0b128d38e770a4d9b755bc0459985403179b11685d591db763147526c145/freecad_stubs-1.0.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9cb97e0e797e6c73e7490286466c8e5c0d97f8b0c589eb6da739bb2b2c1c0a0",
                "md5": "22faf7551a086ef528ae54b0bc488391",
                "sha256": "3fabb8fc076be9428bce1efd4263adfc2d112a7b9e9a76b43f48a127b8ddfd1e"
            },
            "downloads": -1,
            "filename": "freecad-stubs-1.0.17.tar.gz",
            "has_sig": false,
            "md5_digest": "22faf7551a086ef528ae54b0bc488391",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 202080,
            "upload_time": "2024-02-06T03:56:02",
            "upload_time_iso_8601": "2024-02-06T03:56:02.994110Z",
            "url": "https://files.pythonhosted.org/packages/c9/cb/97e0e797e6c73e7490286466c8e5c0d97f8b0c589eb6da739bb2b2c1c0a0/freecad-stubs-1.0.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-06 03:56:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ostr00000",
    "github_project": "freecad-stubs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "freecad-stubs"
}
        
Elapsed time: 0.17685s