fecgov / fec-eregs

The Federal Election Commission's web-based application that makes regulations easier to find, read and understand.
https://www.fec.gov/regulations/
Other
33 stars 13 forks source link

upgrade python to 3.9.13 #710

Closed cnlucas closed 2 years ago

cnlucas commented 2 years ago

Summary (required)

Upgrades python version to 3.9 to stay consistent with CMS and API. We needed to upgrade CMS due to vulnerability within pyJWT https://github.com/fecgov/fec-cms/pull/5401

Required reviewers

1-2 devs

Related PRs

https://github.com/fecgov/fec-cms/pull/5401 https://github.com/fecgov/openFEC/pull/5233

How to test

Terminal - 1

# regparser -e git+https://github.com/fecgov/regulations-parser.git@upgrade-python#egg=regparser

# regcore -e git+https://github.com/fecgov/regulations-core@upgrade-python#egg=regcore

  • open requirements-parsing.txt and do the same thing (lines 72-79):

# regparser -e git+https://github.com/fecgov/regulations-parser.git@upgrade-python#egg=regparser

# regcore -e git+https://github.com/fecgov/regulations-core@upgrade-python#egg=regcore

Terminal - 2

pkfec commented 2 years ago

@cnlucas Tried parsing 2022 regs on local python 3.9.13 environment, on feature branch, got the following error:


Traceback (most recent call last):
  File "/Users/pkasireddy/.pyenv/versions/venv-parser3913/bin/eregs", line 33, in <module>
    sys.exit(load_entry_point('regparser', 'console_scripts', 'eregs')())
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/web/management/runner.py", line 22, in eregs
    runner(args)
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/web/management/runner.py", line 14, in runner
    execute_from_command_line(argv)
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/lib/python3.9/site-packages/djclick/adapter.py", line 68, in run_from_argv
    exit_code = self.main(
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/lib/python3.9/site-packages/djclick/adapter.py", line 50, in invoke
    return super(DjangoCommandMixin, self).invoke(ctx)
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/commands/retry.py", line 45, in invoke
    run_or_resolve(
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/commands/retry.py", line 57, in run_or_resolve
    cmd()
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/commands/retry.py", line 47, in <lambda>
    lambda: super(RetryingCommand, self).invoke(deepcopy(ctx)))
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/lib/python3.9/site-packages/click/core.py", line 1653, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/lib/python3.9/site-packages/click/core.py", line 1700, in resolve_command
    cmd = self.get_command(ctx, cmd_name)
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/commands/retry.py", line 40, in get_command
    for command in sub_commands():
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/commands/retry.py", line 25, in sub_commands
    module = import_module('regparser.commands.{0}'.format(command_name))
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/commands/annual_editions.py", line 6, in <module>
    from regparser.history import annual
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/history/annual.py", line 12, in <module>
    from regparser.tree.xml_parser.xml_wrapper import XMLWrapper
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/tree/xml_parser/xml_wrapper.py", line 7, in <module>
    from regparser.tree.xml_parser.preprocessors import replace_html_entities
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/tree/xml_parser/preprocessors.py", line 18, in <module>
    from regparser.notice.amdparser import parse_amdpar
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/notice/amdparser.py", line 8, in <module>
    from regparser.grammar import amdpar, tokens
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/grammar/amdpar.py", line 12, in <module>
    from regparser.grammar import atomic, tokens, unified
  File "/Users/pkasireddy/.pyenv/versions/3.9.13/envs/venv-parser3913/src/regparser/regparser/grammar/atomic.py", line 13, in <module>
    HTMLParser().unescape('&ensp;&emsp;&thinsp;&zwnj;&zwj;&lrm;&rlm;'))
AttributeError: 'HTMLParser' object has no attribute 'unescape'

If you suspect this is an IPython 7.16.3 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True
pkfec commented 2 years ago

@cnlucas I am able to parse 2022 regs on python 3.8.13 environment on your feature branch.

Here is the screenshot for reference:

Screen Shot 2022-09-07 at 9 19 25 PM
cnlucas commented 2 years ago

@pkfec, I re-created your issue. It seems like there's an issue with certain versions of setuptools and distlib with python 3.9. Instead of pinning, I put in PR's to reg-core and reg-parser to remove the code that was deprecated in python 3.4 that seems to be causing that issue.

pkfec commented 2 years ago

@cnlucas Thanks for removing deprecated code from regulations-parser and [regulations-core] (https://github.com/fecgov/regulations-core/pull/8) repos.

Finally, I am able to parse 2022 regs on my local python 3.9.13 virtual environment. Thanks!