![]() ❗ TODO: Is there any better way to do this? resources This can be done by running the file directly with exec. In the setup.py we do not have access to the library itself, so the _version_ must be imported without the assumption that the package is installed. The version should then be imported to the root- _init_.py to use it like this: import freecad.workbench_starterkit It's common practice to include a version-string in the python-package. If you need advanced options to install your package, please have a look at the setuptools docs. The setup.py file located in the main directory is a minimal example to get an extension installed. In addition, utilizing pip also provides powerful possibilities to install third party dependencies. With pip and pypi a third option is introduced. adds the root-directory to easy_install.path.Ĭurrently FreeCAD has several ways to install packages: Simply link the extension to a location where python can find it.Start FreeCAD from the root-directory you are working in (eg.If you want to work on your extension you have the following options: (But as with python3 this _init_.py should not exist anyway, this isn't a problem.) Further it's not allowed to add variables to the freecad-namespace directly. This means it is not allowed to set any variables in the _init_.py of freecad. The "freecad" namespace is not allowed to be used directly. If the repository contains only one pthon-package it makes sense to choose the same names for the repository-name, python-package and the pypi-package. This name must not contain any python operator symbols like "-". You simply specify all packages and modules in the packages section of the setup.py. Notes: it's possible that there are several packages in one repository with only one setup.py. The name of the package which can be imported from python. The name of the repository AKA freecad.repository_name ❗ Do not put very time-intensive code in these files to reduce the start-up time. Note: init_gui.py are called at startup of FreeCAD. This is the minimal structure of a namespace-package to add a workbench to FreeCAD. ( The python import will not yet work on every system, but we are working towards a standardization). Launching freecadcmd or importing FreeCAD ( import freead) will call the _init_.py file. Called when you import your package: from freecad import my_packageīoth of these initialization files are called when the FreeCAD-gui is launched. _init_.py: entry function for non-gui FreeCAD and python.init_gui.py: mandatory for modules adding new functionality to the GUI.Structure of a namespace-workbench: Initialization Files For more discussion about the motivation behind the "namespace-workbench" see Motivation for namespace-workbenches. (See Glossary terms used in this discussion). In addition the "namespace-workbench" is now an optional (and preffered) way to extend the FreeCAD. The origin workbench type is called "legacy-workbench". Note: There are currently two FreeCAD workbench styles. Pip uninstall freecad.workbench_starterkit ![]() To try the latest release of this template: # Install this template If all you want is to create an extension for FreeCAD (module, additional gui-stuff, workbench), simple copy this repo and start replacing things. As python-packaging and packaging for FreeCAD is not an easy task, this repository should give an overview of the things learned so far. This is a template for a FreeCAD workbench / module. If so please have a look at the traditional workbench structure. ❗ Don't use this repo if you care about py2-support and support of freecad < 0.18. FreeCAD Workbench-Starterkit Compatibility (important) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |