Python3 project without setup.py


John Klug
 

I am using Dunfell.

What should I do in a recipe if a python project has no setup.py?

Specifically:
https://github.com/pyhys/minimalmodbus  

I tried adding a trivial setup.py:

from setuptools import setup
if __name__ == '__main__':
    setup()
This results in the recipe failing while trying to "import serial" from the python code in the project:

Log data follows:
| DEBUG: Executing shell function do_compile
| Traceback (most recent call last):
|   File "setup.py", line 4, in <module>
|     setup()

   ...

|   File "/home/jklug/mlinux/build/tmp/work/arm926ejste-mlinux-linux-gnueabi/python3-minimalmodbus/2.0.1-r0/git/minimalmodbus.py", line 38, in <module>
|     import serial
| ModuleNotFoundError: No module named 'serial'



John Klug


Alexander Kanavin
 

This is probably not available in dunfel, but in master there are
bbclasses that handle this:

inherit pypi python_setuptools_build_meta

So try with master, and then consider your options.

Alex

On Fri, 4 Nov 2022 at 00:03, John Klug <john.klug@...> wrote:

I am using Dunfell.

What should I do in a recipe if a python project has no setup.py?

Specifically:
https://github.com/pyhys/minimalmodbus

I tried adding a trivial setup.py:

from setuptools import setup
if __name__ == '__main__':
setup()
This results in the recipe failing while trying to "import serial" from the python code in the project:

Log data follows:
| DEBUG: Executing shell function do_compile
| Traceback (most recent call last):
| File "setup.py", line 4, in <module>
| setup()

...

| File "/home/jklug/mlinux/build/tmp/work/arm926ejste-mlinux-linux-gnueabi/python3-minimalmodbus/2.0.1-r0/git/minimalmodbus.py", line 38, in <module>
| import serial
| ModuleNotFoundError: No module named 'serial'



John Klug


Ross Burton
 

On 3 Nov 2022, at 23:03, John Klug via lists.yoctoproject.org <john.klug=multitech.com@...> wrote:

I am using Dunfell.

What should I do in a recipe if a python project has no setup.py?

Specifically:
https://github.com/pyhys/minimalmodbus
That project uses [buildsystem] attributes in pyproject.toml, for more details I spoke about what this means and how it impacts Yocto at the Yocto Summit earlier this year:

https://www.youtube.com/watch?v=To9TSBaIg2Q&list=PLD4M5FoHz-Twd-JGczxzYQ01DJ_4_sAHg&index=15

However, this all landed in kirkstone and nobody has backported it to dunfell as far as I’m aware.

Adding the stub setup.py likely did the right thing, and albeit outside of Yocto it worked for me:

$ python3 ./setup.py build
running build
running build_py
creating build
creating build/lib
copying minimalmodbus.py -> build/lib
running egg_info
creating minimalmodbus.egg-info
writing minimalmodbus.egg-info/PKG-INFO
writing dependency_links to minimalmodbus.egg-info/dependency_links.txt
writing requirements to minimalmodbus.egg-info/requires.txt
writing top-level names to minimalmodbus.egg-info/top_level.txt
writing manifest file 'minimalmodbus.egg-info/SOURCES.txt'
reading manifest file 'minimalmodbus.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
adding license file 'LICENSE'
adding license file 'AUTHORS.rst'
writing manifest file 'minimalmodbus.egg-info/SOURCES.txt’

Maybe share the recipe or at least the full logs?

Ross