Skip to content

Compatiability issue with newer CPython in setup.py #57

@nevercodecorrect

Description

@nevercodecorrect

Hi,
Thanks for the nice and interesting project.
I am encountering an issue when trying to install Fusil on the latest CPython.
I execute the python setup.py install
But it throws the error that

Traceback (most recent call last):
  File "/lafleur-working-dir/fusil/setup.py", line 91, in <module>
    main()
    ~~~~^^
  File "/lafleur-working-dir/fusil/setup.py", line 61, in main
    fusil = SourceFileLoader("version", path.join("fusil", "version.py")).load_module()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SourceFileLoader' object has no attribute 'load_module'. Did you mean: 'exec_module'?

It looks like a new feature was introduced in 3.12+.
I currently change the setup.py line of code
fusil = SourceFileLoader("version", path.join("fusil", "version.py")).load_module()
to

version_path = path.join("fusil", "version.py")
try:
      fusil = SourceFileLoader("version", version_path).load_module()
except AttributeError:
      fusil_spec = spec_from_file_location("version", version_path)
      fusil = module_from_spec(spec)
      spec.loader.exec_module(fusil)

to support both older and newer versions to make it work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions