facebook / facebook-python-business-sdk

Python SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
1.28k stars 631 forks source link

Only install enum34 in python < 3.4 #566

Closed oakhan3 closed 4 years ago

oakhan3 commented 4 years ago

Hi guys,

I am running into a problem where installing this sdk in a python version above 3.3 results in the following error:

    ERROR: Command errored out with exit status 1:
     command: /home/********/project/.venv/bin/python /home/********/project/.venv/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-zy0jipsb/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel
         cwd: None
    Complete output (14 lines):
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/home/********/project/.venv/lib/python3.7/site-packages/pip/__main__.py", line 23, in <module>
        from pip._internal.cli.main import main as _main  # isort:skip # noqa
      File "/home/********/project/.venv/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 5, in <module>
        import locale
      File "/home/********/project/.venv/lib/python3.7/locale.py", line 16, in <module>
        import re
      File "/home/********/project/.venv/lib/python3.7/re.py", line 143, in <module>
        class RegexFlag(enum.IntFlag):
    AttributeError: module 'enum' has no attribute 'IntFlag'
    ----------------------------------------
  ERROR: Command errored out with exit status 1: /home/********/project/.venv/bin/python /home/********/project/.venv/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-zy0jipsb/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.

This is because facebook-python-business-sdk requires you to install enum34 regardless of your python version.

enum34 is a package that override the enum namespace in the python standard library in python versions 3.4 and above. This package has a slightly different api from the standard library version and if your code or the code in any of your other dependencies calls on enum, it can trigger a traceback like above.

It is a necessary package for python versions below 3.4 since enums did not exist in those versions.

This PR should alleviate this issue.

facebook-github-bot commented 4 years ago

Hi @oakhan3!

Thank you for your pull request and welcome to our community.We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

facebook-github-bot commented 4 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

oakhan3 commented 4 years ago

Link to issue: https://developers.facebook.com/support/bugs/2905833072805310/

facebook-github-bot commented 4 years ago

@jingping2015 merged this pull request in facebook/facebook-python-business-sdk@1c04d9e19e81000363e4608874499bce736fd58a.

litan1106 commented 7 months ago

@stcheng we still see this issue happen in python3.11

this needs to be fixed in main branch.

requirements.txt enum34; python_version < '3.4'