Modernize python tooling#136
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the pull request, @salman2013! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
uv sync creates a local .venv directory; pycodestyle was scanning installed packages inside it and failing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| self.compile_translations() | ||
|
|
||
| def compile_translations(self): | ||
| """ | ||
| Compiles textual translations files(.po) to binary(.mo) files. | ||
| """ | ||
| self.announce('Compiling translations') | ||
| try: | ||
| for dirname, _, files in os.walk(os.path.join('recommender', 'translations')): | ||
| for fname in files: | ||
| if os.path.splitext(fname)[1] == '.po': | ||
| po_path = os.path.join(dirname, fname) | ||
| mo_path = os.path.splitext(po_path)[0] + '.mo' | ||
| self.announce('Compiling translation at %s' % po_path) | ||
| subprocess.check_call(['msgfmt', po_path, '-o', mo_path], cwd=self.install_lib) | ||
| except Exception as ex: | ||
| self.announce('Translations compilation failed: %s' % getattr(ex, 'message', str(ex))) |
There was a problem hiding this comment.
setup.py was compiling translations from .po to .mo files but now this is lost.
Is it still required?
There was a problem hiding this comment.
I think we can remove this method—it's a legacy addition from about 10 years ago.
I verified the following references across the relevant repositories, and they appear to be sufficient to support translations for openedx:
- https://github.com/openedx/RecommenderXBlock/blob/master/Makefile#L21
- https://github.com/openedx/openedx-translations/blob/main/transifex.yml#L341
- https://github.com/openedx/openedx-translations/blob/main/.github/workflows/extract-translation-source-files.yml#L49
@brian-smith-tcril, could you please confirm whether there are any other usages of this method that we should be aware of?
There was a problem hiding this comment.
The flow I understand is:
make extract_translationstakes source strings and creates an english.pofile- GH workflows in the
openedx-translationsrepo pull that.pofile in - Translations happen on transifex, as translations are done
.pofiles for other languages make it into theopenedx-translationsrepo atlasis used to pull.pofiles from theopenedx-translationsrepo- Translations work
My first thought after seeing this was "doesn't compiling happen after pulling the xblock translations in platform?"
I asked Claude to dig into this a bit and got the following response (which makes sense to me)
What I found
There are two different things both called "compile_translations":
- The setup.py method being removed (XBlockInstall.compile_translations, setup.py:23). This was a custom setuptools install command that ran at pip install time, walking recommender/translations/ for .po files and running msgfmt on each to produce .mo. It's only referenced via cmdclass={'install': XBlockInstall} (setup.py:86) — no other usages in the repo. This is the "legacy addition from ~10 years ago."
- The make compile_translations target (Makefile) — i18n_tool generate + compilejsi18n. This is not removed by the PR and is unrelated to the install hook.
Compilation happens on the consuming platform's side at deploy time, not in this package. From edx-platform's Makefile:
pull_xblock_translations: ## pull xblock translations via atlas
python manage.py lms pull_xblock_translations --verbose $(ATLAS_OPTIONS)
python manage.py lms compile_xblock_translations
python manage.py cms compile_xblock_translationsSo edx-platform runs atlas pull to fetch the translated .po files, then compile_xblock_translations produces the .mo. At runtime the XBlock just asks the platform's i18n service for them (recommender.py: self.runtime.service(self, 'i18n') → ugettext, and get_javascript_i18n_catalog_url for the JS catalog). The XBlock never compiles its own .mo.
Two things confirm the setup.py hook is dead weight: (a) no .po/.mo files are committed to this repo, so even at install time that os.walk found nothing to compile, and (b) in the atlas model translated files never ship inside the wheel anyway — they're pulled and compiled downstream.
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| ref: ${{ github.ref_name }} |
There was a problem hiding this comment.
| ref: ${{ github.ref_name }} | |
| ref: ${{ github.ref_name }} | |
| fetch-depth: 0 |
Suggested by GPT 5.6-Sol
Checkout is shallow (fetch-depth: 1 by default), so semantic-release may not see tags or commit history and can fail/version incorrectly.
|
👋 Reviewed this against the same checklist we've been applying across the modernization effort. Nothing blocking — CI is green. One shared issue worth fixing:
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6ccf112 to
90f7145
Compare
Modernizes the Python tooling for this repo in three phases, aligning with the Open edX org standard established in openedx/sample-plugin.
Ticket: openedx/public-engineering#511
Parent ticket: openedx/public-engineering#506
Changes generated by Claude Sonnet 4.6 using the modernize-python-tooling skill, reviewed by a human.