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

Don't scaffold pycache or pyc #168

Merged
merged 2 commits into from
May 2, 2024
Merged

Conversation

cidrblock
Copy link
Collaborator

@cidrblock cidrblock commented May 2, 2024

Related #164

When ansible-creator is installed by pip, some pycache and pyc files are created in the collection unit test directory:

(venv) m910x ➜  test tree venv/lib/python3.12/site-packages/ansible_creator/resources/new_collection/tests/unit/                                   
venv/lib/python3.12/site-packages/ansible_creator/resources/new_collection/tests/unit/
├── __pycache__
│   └── test_basic.cpython-312.pyc
└── test_basic.py

These cause a traceback when scaffolding:

test ansible-creator init --project collection collection=a.b --init-path /tmp/foo --force      
 Warning: re-initializing existing directory /tmp/foo
Traceback (most recent call last):
  File "/tmp/test/venv/bin/ansible-creator", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/cli.py", line 211, in main
    cli.run()
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/cli.py", line 199, in run
    subcommand(config=Config(**self.args, output=self.output)).run()
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/subcommands/init.py", line 114, in run
    copier.copy_containers()
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/utils.py", line 199, in copy_containers
    self._per_container()
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/utils.py", line 185, in _per_container
    self._recursive_copy(
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/utils.py", line 111, in _recursive_copy
    self._recursive_copy(
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/utils.py", line 111, in _recursive_copy
    self._recursive_copy(
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/utils.py", line 111, in _recursive_copy
    self._recursive_copy(
  File "/tmp/test/venv/lib64/python3.12/site-packages/ansible_creator/utils.py", line 128, in _recursive_copy
    content = obj.read_text(encoding="utf-8")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/pathlib.py", line 1028, in read_text
    return f.read()
           ^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position 0: invalid continuation byte

Not caught in our tests because it's not run from an installed package.

Found during adt tests for server b/c the server was throwing a 500

https://github.com/ansible/ansible-dev-tools/actions/runs/8929768888

@cidrblock cidrblock requested review from NilashishC and a team as code owners May 2, 2024 21:58
@cidrblock cidrblock requested review from ssbarnea and Qalthos and removed request for a team May 2, 2024 21:58
@github-actions github-actions bot added the bug Something isn't working label May 2, 2024
@cidrblock
Copy link
Collaborator Author

merging, last release had a fatal bug

@cidrblock cidrblock merged commit 97db4a5 into ansible:main May 2, 2024
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant