Wouldn't work: the copyright lawsuit against Anthropic ruled that while copyright infringement (AKA piracy) to get the training data for training an AI is still copyright infringement, actually doing the training once you have the data is not itself a copyright violation.
Simply making the code available, regardless of the licence, allows present and future AI to train on them.