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

Preliminary python 3.6 port - development #2564 #2567

Merged

Conversation

phillxnet
Copy link
Member

As part of our move to Python 3 we must first establish our
initial python 3 dependencies via Poetry.

Fixes #2564

Includes:

  • Update pyproject.toml and poetry.lock for python 3.6.
  • Remove int long designator from settings.py: Python 3
    no longer uses the "L" suffix.
  • Use full path in initial import conversions. Python 3
    has more stringent import path requirements.
  • Update imports for 3.6 email module. These differ in Python 3.
  • Encode unicode line for system.osi.md5sum.
    TypeError: Unicode-objects must be encoded before hashing
  • Tidy/update init_sftp_config() re Python 3.
    There was a subtle file pointer behaviour change
    between 2.7 and 3.6 which broke this mechanism.
  • Address TODO re custom opener re Python 3.
  • Services page & Users page - Python 3 style sorted():
    "cmp" sorted parameter and buildin function dropped
    in Python 3.
  • init fix of groups page by adaptation to str type.
  • Replace chardet dependency with charset-normalizer:
    also used by requests.
  • Removes redundant encoding on already encoded groupname.
  • Init dashboard fix via gevent/websocket update.
    Thanks to @FroggyFlox for investigations here.
  • Init fix of get_users() - non admin users did not show.
    Move to more modern - time limited subprocess.run().
  • fix samba, disk partition, rockon, re iteritems()
    In Python 3 we use iter(d.items()) instead:
    https://peps.python.org/pep-0469/
  • Address TODO re ascii to utf-8 on SMART custom options.
  • Untested bytecast in smart.py:
    custom options autodev related byte assertion.

Independent commits for attribution from @FroggyFlox

  • Move UDEVADM and SHUTDOWN definitions to runtime constants.
    Removes now redundant and incompatible mechanism.
  • Move passwd to str and use crypt.mksalt() to generate salt.
    Updates this mechanism re Python 3 capabilities.

phillxnet and others added 3 commits June 6, 2023 12:49
As part of our move to Python 3 we must first establish our
initial python 3 dependencies via Poetry.

## Includes:
- Update pyproject.toml and poetry.lock for python 3.6.
- Remove int long designator from settings.py: Python 3
no longer uses the "L" suffix.
- Use full path in initial import conversions. Python 3
has more stringent import path requirements.
- Update imports for 3.6 email module. These differ in Python 3.
- Encode unicode line for system.osi.md5sum.
TypeError: Unicode-objects must be encoded before hashing
- Tidy/update init_sftp_config() re Python 3.
There was a subtle file pointer behaviour change
between 2.7 and 3.6 which broke this mechanism.
- Address TODO re custom opener re Python 3.
- Services page & Users page - Python 3 style sorted():
"cmp" sorted parameter and buildin function dropped
in Python 3.
- init fix of groups page by adaptation to str type.
- Replace chardet dependency with charset-normalizer:
also used by requests.
- Removes redundant encoding on already encoded groupname.
- Init dashboard fix via gevent/websocket update.
Thanks to @FroggyFlox for investigations here.
- Init fix of get_users() - non admin users did not show.
Move to more modern - time limited subprocess.run().
- fix samba, disk partition, rockon, re iteritems()
In Python 3 we use iter(d.items()) instead:
https://peps.python.org/pep-0469/
- Address TODO re ascii to utf-8 on SMART custom options.
- Untested bytecast in smart.py:
custom options autodev related byte assertion.
@phillxnet phillxnet marked this pull request as ready for review June 6, 2023 12:09
@phillxnet
Copy link
Member Author

N.B. Although these changes enable most functionality within a far newer Python 3.6 local .venv, they break rpmbuild as we require all tests to pass there. However the key purpose of this pull request is to enable spin-off issues to focus developer efforts on ease parallel tasks on fixing the following:

Ran 252 tests in 20.288s

FAILED (failures=12, errors=6)

Via clearly defined tasks to restore our testing channel to a build-able and thus release capable status.

@phillxnet
Copy link
Member Author

@FroggyFlox & @Hooverdan96

Given this PR gets us to a source build state under python 3.6 (but not rpm buildable due to unit test failure) I propose that we merge it into testing and address the unit test failures as a matter of priority. As many of the tests fail due to Python 3.6 differences re unicode / string / byte i.e. u"some text" etc we likely need a dedicated test issue/s. However we also need to avoid stepping on each others toes. Some tests will of course reflect tested code changes regarding the underlying Python changes we have introduced here.

@phillxnet phillxnet changed the title Preliminary python 3.6 port - development Preliminary python 3.6 port - development #2564 Jun 6, 2023
@FroggyFlox
Copy link
Member

Agreed on merging this; that's already in an excellent state, relatively speaking of course. I was going to say "starting point" but that's actually much better than that.

@Hooverdan96
Copy link
Member

Hooverdan96 commented Jun 6, 2023

I know, this is a very minor detail and I don't know where to put this, but since you were moving some of the paths from the settings.py to constants.py, I noticed the shutdown path. In the spirit of simplification, would it make sense to use systemctl poweroff/systemctl reboot instead of the shutdown command/path to get rid of another setting/path?

@phillxnet
Copy link
Member Author

@Hooverdan96 Re:

In the spirit of simplification, would it make sense to use systemctl poweroff instead of the shutdown command/path to get rid of another setting/path?

If you could create an issue for this I think it would be a viable 'upgrade' as you say simplification is good and that may be the way to go, handing off yet more to systemd.

As for this pr I think I'll pop it in as we have much to do by way of follow-up and the sooner it's in the better.

N.B. we would normally be reluctant to merge any pr that breaks testing - as it in-turn breaks our rpmbuild (see %checks):

https://github.com/rockstor/rockstor-rpmbuild/blob/211ed89b89910afbf767459dc5933a52b1073038/rockstor.spec#L249-L251

But this is literally the first pr in our new testing run and we have changed our base language version (where that is significant in Python 2 to 3) so its merge assists with dividing up the remaining conversion work, some of which likely relates to why all tests are no passing.

@phillxnet phillxnet merged commit e8c98b6 into rockstor:testing Jun 6, 2023
@phillxnet phillxnet deleted the 2564_Preliminary_python_3.6_port branch June 6, 2023 15:08
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

Successfully merging this pull request may close these issues.

3 participants