Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3 support #350

Closed
geissonator opened this issue Apr 13, 2020 · 9 comments
Closed

python3 support #350

geissonator opened this issue Apr 13, 2020 · 9 comments

Comments

@geissonator
Copy link
Member

More of a feature request. OpenBMC builds the croserver into it's image. OpenBMC uses the upstream yocto distribution as it's base and they have removed all support for python2 and now only support python3. We'll need tools like eCMD that we pull in to move as well.

Any chance this is on the list for things like config.py? Sometimes it's as easy as just changing the first line to "#!/usr/bin/env python3"

@thejta
Copy link
Contributor

thejta commented Apr 13, 2020

Does yocto not have a python->python3 link? We hit a similar issue when fedora made python3 the default. We updated the script to be compatible for both so the current #!/usr/bin/env python will work regardless of the python install.

@geissonator
Copy link
Member Author

The direction I've seen is to not do that because you may end up with some weird undefined behavior. In general, python scripts are supposed to explicitly move to python3 to show they support it (and have tested it). I'm def not the expert though. Are you thinking eCMD is going to have to support both for a while? With python2 susnet (https://www.python.org/doc/sunset-python-2/), yocto just put the big hammer down and removed it completely.

We could probably put a little workaround in our croserver recipe and just replace the python with python3 in the config.py script if you feel like the support is there for it.

@geissonator
Copy link
Member Author

Ahh, shoot, I ran into an issue with my workaround. config.py is using a deprecated python2 only option with platform:

| Establishing eCMD build variables..
| Determining host and distro..
| Traceback (most recent call last):
|   File "/home/andrewg/Code/openbmc/build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/croserver/git-r0/git/config.py", line 373, in <module>
|     dtuple = platform.linux_distribution()
| AttributeError: module 'platform' has no attribute 'linux_distribution'

See https://docs.python.org/2/library/platform.html

@thejta
Copy link
Contributor

thejta commented Apr 14, 2020

eCMD still supports building on el6, which barely has python3 support. So it's been a balancing act. While the env python method isn't ideal, it has provided the most compatibility for users.

That said, you could try pulling this branch: https://github.com/thejta/eCMD/tree/update-config

That has both a hardcoded python3 call and updated logic to handle linux_distribution being pulled from python3.8. The specific changeset is: https://github.com/thejta/eCMD/commit/28e306fb777681ffb9cfd6de293e3b29a174448a

It does require the distro module be available in the build environment, since that is the replacement for the deprecated function.

Adding @mklight and @kahnevan as they ultimately decide what goes in. I just had a chance to hack this together.

@geissonator
Copy link
Member Author

Thanks for the patch @thejta . Looks like yocto does not have a recipe for distro yet :( I'll see what it takes to get one done.

@geissonator
Copy link
Member Author

ok, I put a upstream recipe in via openembedded/meta-openembedded#213 to get the Distro package.

@mklight or @kahnevan can we get the code from @thejta into master?

@thejta
Copy link
Contributor

thejta commented Apr 27, 2020

I put it up the branch a PR#361 for @mklight and @kahnevan to review/test

@klauskiwi
Copy link

Can we close this based on #361 merge?

@geissonator
Copy link
Member Author

Yep, thanks for all the help guys, looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants