Skip to main content

Python stubs for FreeCAD

Project description

freecad-stubs

PyPI version GitHub license PyPI pyversions

Python stubs generated from FreeCAD source code.

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

Install stubs

You can install all stubs for freeCAD packages by running:

python -m pip install freecad-stubs 

Adding stubs to python path

There are a lot of possible methods. This is only example:

  1. Copy stubs from a desired branch from this repository.
    Checkout to desired branch and copy folder /freecad_stubs.

  2. (Optional) Or generate stubs manually. Copy/move generated stubs to location of your choice. For example:

    cp -r ./freecad_stubs "$HOME/.local/lib/python3.9/freecad_stubs" 
    
  3. Add location with stubs to python search path. For example:

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

Stub Generation

  1. Clone freecad repository.

    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/Mod
  2. Clone this repository

    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

    pytohn freecad-stubs/lib/freecad_stub_gen/__main__.py
    

    Required python version: >=3.10.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freecad-stubs-1.0.1.tar.gz (137.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freecad_stubs-1.0.1-py3-none-any.whl (145.8 kB view details)

Uploaded Python 3

File details

Details for the file freecad-stubs-1.0.1.tar.gz.

File metadata

  • Download URL: freecad-stubs-1.0.1.tar.gz
  • Upload date:
  • Size: 137.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.10.0rc1

File hashes

Hashes for freecad-stubs-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a19717bd8a5cacb4a7d6520fe2975f55c114a9b82666222ddb2371cd3754fece
MD5 acd6a13a6cf3468eb7a879946a1c2f1e
BLAKE2b-256 89d9b65f525551e3ac761b8285569bb8fca264e03ed332c76d7d44b9894b376b

See more details on using hashes here.

File details

Details for the file freecad_stubs-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: freecad_stubs-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 145.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.10.0rc1

File hashes

Hashes for freecad_stubs-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 423f690d4d8dc1e7942e84116efdc41fe30d57b255768a807fb9abaee7751b2c
MD5 e7508b6d9eff42ee83cea61977e57f83
BLAKE2b-256 42e49c8b2d41d68a47debca1f9d64224cab6709054e1546d081d29804e6dfaa6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page