Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Added task to copier to warn that template is deprecated and updated … #76

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

lempira
Copy link
Contributor

@lempira lempira commented Nov 14, 2024

Proposed Changes

  • Updated the README
  • Added a task before the init finalizes to print the deprecation warning and fail the init

@lempira lempira requested a review from aorumbayev November 14, 2024 00:25
copier.yaml Outdated
@@ -1,6 +1,10 @@
_subdirectory: template_content
_templates_suffix: ".jinja"

_tasks:
- "python -c \"print('WARNING: This template has been deprecated. Beaker for Algorand Smart Contract development is no longer supported.\\nPlease use Algorand Python instead. The Algorand Python template can be found at https://github.com/algorandfoundation/algokit-python-template')\""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tasks runs before the init finishes but the files are still copied. Is there a way to run the tasks before prompting for the questions?

Copy link
Contributor

@aorumbayev aorumbayev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre approving, please see my slightly different approach here first #77

@lempira lempira force-pushed the deprecate-template branch 2 times, most recently from 845e90e to 0618237 Compare November 22, 2024 19:32
@lempira
Copy link
Contributor Author

lempira commented Nov 22, 2024

Pre approving, please see my slightly different approach here first #77

@aorumbayev I saw your comment about testing it with the windows binary and I was finding that it wasn't deleting the template dir if you chose not to proceed after the deprecation warning. I added additional error logging and I am getting this error Failed to clean up C:\Users\lempi\Documents\algokit-init-test\asdf: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\lempi\\Documents\\algokit-init-test\\asdf\\projects\\asdf' It looks like another file is open so it fails on deleting asdf template. I thought it could have been due somehow the template being the workdir so I changed the dir before deleting but I got the same error. I was then think about using something like psutil to force delete files that might be open but was wondering if you had any ideas before I go down that route.

@aorumbayev
Copy link
Contributor

@lempira i see, yeah so this seems to be caused by the fact that the script running the deletion of the folder is located within that folder. There are several workarounds for this depending on whether you want to go an extra mile for this edge case or not:

  • Recursively delete the contents of project folder instead of of running rmtree, the script can be self removed at the very end of script execution (if windows is the running platform) -> user will be left with an empty folder but would still need to cleanup the folder OR you can then run an extra platform specific task https://copier.readthedocs.io/en/stable/configuring/#tasks to cleanup that folder separately.
  • Keeping the post_init.py script execution as a unix specific command (by leveraging platform specific tasks https://copier.readthedocs.io/en/stable/configuring/#tasks) and writing a windows specific inline bash script to remove the directory
  • Handling the exception and printing out the instruction to user to manually remove the folder

@lempira
Copy link
Contributor Author

lempira commented Nov 26, 2024

I went with the third options of just handling the exception and telling the user to manually delete the folder

image

@lempira lempira merged commit 435a1a2 into main Nov 26, 2024
1 check passed
@aorumbayev
Copy link
Contributor

@lempira yeah makes sense, thats probably the most pragmatic, the windows binary is a fairly specific edge case not worth going overboard 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants