Package: setuptools-pyecore
Table of ContentsOverviewInstallationFrom Source CodeFrom PyPIFrom GitHub ReleasesUsageIntegrationConfigurationSampleOverviewAsetuptoolscommand for generating Python code from Ecore models.This is an extension forsetuptoolsintegrating thepyecoregencode generator into the Python packaging process. It encapsulatespyecoregenand provides the user asetuptoolscommand calledpyecoreto control the generation process.In a basic setup the user doesn’t have to configure the generation process at all becausesetuptools-pyecorediscovers Ecore models located in the current working directory and triggers the code generation for each detected Ecore model. Also a meaningful output folder is chosen automatically.Of course the user has to possibility to customize the generation process. The command line options ofpyecoregenare also available through thepyecoresetuptools command. The user has the choice to pass the options on the command line or configure the code generation in a dedicated section in thesetup.cfgfile.Installationsetuptools-pyecorecan be installed in various ways. To run it the following prerequisites have to be fulfilled:Python 3.4+setuptoolsAfter installation, the used Python environment has a new setuptools command calledpyecore.From Source Code> git clone https://github.com/pyecore/setuptools-pyecore.git
> cd setuptools-pyecore
> pip install .From PyPI> pip install setuptools-pyecoreFrom GitHub Releases> pip install <setuptools-pyecore_wheel>UsageIntegrationFor a smooth user experience it’s recommended to passsetuptools-pyecoreusing thesetup_requiresargument of setup function. Additionally the generated Python code depends on thepyecorelibrary which should be added toinstall_requiresargument:setup(...setup_requires=['setuptools-pyecore'],install_requires=['pyecore']...)Before generating Python code from a given Ecore modelsetuptoolswill automatically check the Python environment and downloadsetuptools-pyecorefromPyPIif it’s missing. During the installation of the project packagepipwill installpyecoreinto the Python environment.Configurationsetuptools-pyecoreprovides two possibilities to configure the pyecore generator.All options can be passed on the command line after thepyecorecommand:> python setup.py pyecore --auto-register-packageIt’s also possible to pass several options topyecoregenor execute multiple commands at once:> python setup.py pyecore --auto-register-package --output "default=gen" bdist_wheelSeepython setup.py pyecore--helpfor available command line options:> python setup.py pyecore --help
...
Options for 'PyEcoreCommand' command:
  --ecore-models (-e)      specify Ecore models to generate code for
  --output (-o)            specify directories where output is generated
  --user-modules           dotted names of modules with user-provided mixins
                           to import from generated classes
  --auto-register-package  Generate package auto-registration for the PyEcore
                           'global_registry'
...Thepyecoregendocumentation explains allcommand line optionsin detail.Apart from passing options on the command line it’s also possible to add a dedicated[pyecore]section tosetup.cfg. The following example section contains all available options:[pyecore]# Specify Ecore models to generate code for; default: None#ecore-models = <ecore-model> [<ecore-model> ...]# Specify directories where output is generated; default: ./output=default=gen# Dotted names of modules with user-provided mixins to import from generated classes; default: None#user-modules = [<model>=<user module>]#               [<model>=<user module> ...]# Generate package auto-registration for the PyEcore 'global_registry' (yes|no); default: noauto-register-package=yesA reference configuration is provided in theresourcesdirectory.pyecoregeninherits the log level globally configured forsetuptools. To set the verbosity to a certain log level pass the global optionsverboseorquietstraight before thepyecorecommand on the command line:> python setup.py --verbose pyecoreAlternatively, you can add these options to the[global]section of yoursetup.cfg:[global]# Run verbosely (yes|no); default: yes#verbose = yes# Run quietly and turns verbosity off (yes|no); default: noquiet=yesSampleBesides thesetuptools-pyecoresource code a sample project calledlibraryis provided in thesamplesdirectory. This sample consists of the Ecore modellibraryand a setup script. During the execution ofsetuptools-pyecorea Python package will be generated into thelibrarypackage directory representing the classes from thelibraryEcore model.To generate code out of the Ecore model and build alibrarywheel package execute the following command:> python setup.py pyecore bdist_wheel