How to run mpfmc from source code

55 views
Skip to first unread message

Marc Rechté

unread,
Aug 25, 2023, 11:25:52 AM8/25/23
to MPF Users
Needing to do some adjustments to mpf code, I forked it and managed to start it from the source code like that:

$ export PYTHONPATH=path_to_mpf_clone
$ cd path_to_mpf_clone/..
$ python -m mpf -b

But know I need to start the mpfmc, but I get this error
$ python -m mpf mc
AssertionError: Error: Could not find machine in folder: '.../fastdraw_mpf/mc'. Either start MPF from within your machine root folder or provide the path after the command.

Is it possible to allow mpf discover the mpfmc module from the source code ?

Thanks

Anthony van Winkle

unread,
Aug 25, 2023, 2:30:13 PM8/25/23
to MPF Users
Hello!

It's certainly possible to run MPF and MC both from source, provided they can see each other in the environment. A virtual environment is strongly recommended for this case (when using pip; when using pipx one will be created automatically).

You can see which packages you have installed by running pip list while in your environment. In a proper configuration you'll see both MPF and MPF-MC listed there, along with the path to the local folder it runs from. Packages installed from published versions will not have a path. Here's an example snippet from my pip list:

...
Kivy                              2.0.0
Kivy-Garden                       0.1.4
lazy-object-proxy                 1.4.3
MarkupSafe                        2.0.1
mccabe                            0.6.1
mpf                               0.56.0.dev20           /Users/Anthony/git/mpf
mpf-mc                            0.56.0.dev33           /Users/Anthony/git/mpf-mc
nodeenv                           1.6.0
numpy                             1.21.2
packaging                         21.3
...

When that works, you can open python and type import mpf and import mpfmc to verify that the packages are found in the path. Hope that helps!

Marc Rechté

unread,
Aug 25, 2023, 3:32:20 PM8/25/23
to Abridged recipients
Thanks. I do not want to install the packages from pip, because I wish the latest git version and the possibility to amend the source code. Therefore "pip list" will not list mpf nor mpf-mc.

Is thre a way to start the mc from the source code ?

Télécharger TypeApp pour Android

Anthony van Winkle

unread,
Aug 25, 2023, 4:07:43 PM8/25/23
to MPF Users
You can do both, fortunately. When you use pip, the -e argument instructs pip to "install" at the specified folder rather than download the published package. The module is not built or compiled in any way, it runs straight from the source code so you can make any changes to the files and see the effects immediately.

The syntax is pip install -e <path_to_repo_root>

Marc Rechté

unread,
Aug 26, 2023, 10:27:21 AM8/26/23
to MPF Users
Thanks a lot Anthony. Pip installing with -e option was the clue. I did learn something.
Reply all
Reply to author
Forward
0 new messages