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

python 3.9 ? #2

Closed
cidrblock opened this issue Aug 14, 2023 · 3 comments · Fixed by #3
Closed

python 3.9 ? #2

cidrblock opened this issue Aug 14, 2023 · 3 comments · Fixed by #3

Comments

@cidrblock
Copy link
Collaborator

https://github.com/NilashishC/ansible-creator/blob/8e39a85e71a22c6607095a6cc890247ece55c2fc/pyproject.toml#L9

I was hoping to make the ansible-cdk python 3.9, can you drop this down?

https://github.com/ansible-community/ansible-cdk/blob/main/pyproject.toml#L29

@NilashishC
Copy link
Collaborator

I think most of it is >=3.9 compatible except for this portion which I'm trying to figure out. The importlib.resources.files method doesn't seem to behave the same way with py3.9 and throws a traceback. Not sure what changed between 3.9 and 3.11, not much in the docs.

Traceback (most recent call last):
  File "/home/nchakrab/.virtualenvs/creator/bin/ansible-creator", line 8, in <module>
    sys.exit(main())
  File "/home/nchakrab/ansible-creator/src/ansible_creator/cli.py", line 128, in main
    cli.run()
  File "/home/nchakrab/ansible-creator/src/ansible_creator/cli.py", line 117, in run
    action_class(**args).run()
  File "/home/nchakrab/ansible-creator/src/ansible_creator/actions/init.py", line 61, in run
    copy_container(
  File "/home/nchakrab/ansible-creator/src/ansible_creator/utils.py", line 114, in copy_container
    _root = resources.files(f"ansible_creator.resources.{source}")
  File "/home/nchakrab/.pyenv/versions/3.9.17/lib/python3.9/importlib/resources.py", line 147, in files
    return _common.from_package(_get_package(package))
  File "/home/nchakrab/.pyenv/versions/3.9.17/lib/python3.9/importlib/_common.py", line 14, in from_package
    return fallback_resources(package.__spec__)
  File "/home/nchakrab/.pyenv/versions/3.9.17/lib/python3.9/importlib/_common.py", line 18, in fallback_resources
    package_directory = pathlib.Path(spec.origin).parent
  File "/home/nchakrab/.pyenv/versions/3.9.17/lib/python3.9/pathlib.py", line 1082, in __new__
    self = cls._from_parts(args, init=False)
  File "/home/nchakrab/.pyenv/versions/3.9.17/lib/python3.9/pathlib.py", line 707, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/home/nchakrab/.pyenv/versions/3.9.17/lib/python3.9/pathlib.py", line 691, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

@cidrblock
Copy link
Collaborator Author

The one thing you might try here is a dependency on this https://pypi.org/project/importlib-resources if python < 3.10. It sometimes behaves better than the version baked in. You'll have to have a conditional import in the file, something like this https://github.com/ansible/ansible-navigator/blob/main/src/ansible_navigator/utils/compatibility.py#L18

@NilashishC
Copy link
Collaborator

@cidrblock That worked!

NilashishC added a commit to NilashishC/ansible-creator that referenced this issue Apr 2, 2024
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
NilashishC added a commit that referenced this issue Apr 3, 2024
* update init-path behaviour

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* debug

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* update init-path behaviour

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* maybe a fix

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* maybe a fix - 2

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* maybe a fix - 2

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* maybe a fix - 3

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* maybe a fix - 4

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* maybe a fix - 5

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* check stderr

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* hopefully works

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* hopefully works #2

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* hopefully works #3

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* hopefully works #4

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* add a comment on what was done

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* Bump mkdocs-material to 9.5.17

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

---------

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
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 a pull request may close this issue.

2 participants