From 7e758943017b4e4473a476aea1a4e8f1638cd7ee Mon Sep 17 00:00:00 2001 From: Tycho Hob Date: Fri, 30 Jan 2026 09:31:35 -0500 Subject: [PATCH 1/3] build: Fix builds by updating action to use Python 3.11 Also removes the incorrect Python 3.8 classifier and fixes quotes in setup.py --- .github/workflows/pypi-publish.yml | 6 +- setup.py | 95 ++++++++++++++++++------------ 2 files changed, 58 insertions(+), 43 deletions(-) diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index b01a40a..a2f4aef 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -3,10 +3,9 @@ name: Publish package to PyPi on: push: tags: - - '*' + - "*" jobs: - push: runs-on: ubuntu-latest @@ -16,7 +15,7 @@ jobs: - name: setup python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.11 - name: Install pip run: pip install -r requirements/pip.txt @@ -32,4 +31,3 @@ jobs: with: user: __token__ password: ${{ secrets.PYPI_UPLOAD_TOKEN }} - diff --git a/setup.py b/setup.py index c9ee009..fdbea3f 100644 --- a/setup.py +++ b/setup.py @@ -19,12 +19,11 @@ def get_version(*file_paths): Extract the version string from the file at the given relative path fragments. """ filename = os.path.join(os.path.dirname(__file__), *file_paths) - version_file = open(filename, encoding='utf-8').read() - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) + version_file = open(filename, encoding="utf-8").read() + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) if version_match: return version_match.group(1) - raise RuntimeError('Unable to find version string.') + raise RuntimeError("Unable to find version string.") def load_requirements(*requirements_paths): @@ -49,14 +48,14 @@ def check_name_consistent(package): with extras we don't constrain it without mentioning the extras (since that too would interfere with matching constraints.) """ - canonical = package.lower().replace('_', '-').split('[')[0] + canonical = package.lower().replace("_", "-").split("[")[0] seen_spelling = by_canonical_name.get(canonical) if seen_spelling is None: by_canonical_name[canonical] = package elif seen_spelling != package: raise RuntimeError( f'Encountered both "{seen_spelling}" and "{package}" in requirements ' - 'and constraints files; please use just one or the other.' + "and constraints files; please use just one or the other." ) requirements = {} @@ -70,7 +69,9 @@ def check_name_consistent(package): % (re_package_name_base_chars, re_package_name_base_chars) ) - def add_version_constraint_or_raise(current_line, current_requirements, add_if_not_present): + def add_version_constraint_or_raise( + current_line, current_requirements, add_if_not_present + ): regex_match = requirement_line_regex.match(current_line) if regex_match: package = regex_match.group(1) @@ -79,11 +80,16 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n existing_version_constraints = current_requirements.get(package, None) # It's fine to add constraints to an unconstrained package, # but raise an error if there are already constraints in place. - if existing_version_constraints and existing_version_constraints != version_constraints: - raise BaseException(f'Multiple constraint definitions found for {package}:' - f' "{existing_version_constraints}" and "{version_constraints}".' - f'Combine constraints into one location with {package}' - f'{existing_version_constraints},{version_constraints}.') + if ( + existing_version_constraints + and existing_version_constraints != version_constraints + ): + raise BaseException( + f"Multiple constraint definitions found for {package}:" + f' "{existing_version_constraints}" and "{version_constraints}".' + f"Combine constraints into one location with {package}" + f"{existing_version_constraints},{version_constraints}." + ) if add_if_not_present or package in current_requirements: current_requirements[package] = version_constraints @@ -94,8 +100,12 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n for line in reqs: if is_requirement(line): add_version_constraint_or_raise(line, requirements, True) - if line and line.startswith('-c') and not line.startswith('-c http'): - constraint_files.add(os.path.dirname(path) + '/' + line.split('#')[0].replace('-c', '').strip()) + if line and line.startswith("-c") and not line.startswith("-c http"): + constraint_files.add( + os.path.dirname(path) + + "/" + + line.split("#")[0].replace("-c", "").strip() + ) # process constraint files: add constraints to existing requirements for constraint_file in constraint_files: @@ -105,7 +115,9 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n add_version_constraint_or_raise(line, requirements, False) # process back into list of pkg><=constraints strings - constrained_requirements = [f'{pkg}{version or ""}' for (pkg, version) in sorted(requirements.items())] + constrained_requirements = [ + f"{pkg}{version or ''}" for (pkg, version) in sorted(requirements.items()) + ] return constrained_requirements @@ -119,48 +131,53 @@ def is_requirement(line): """ # UPDATED VIA SEMGREP - if you need to remove/modify this method remove this line and add a comment specifying why - return line and line.strip() and not line.startswith(('-r', '#', '-e', 'git+', '-c')) + return ( + line and line.strip() and not line.startswith(("-r", "#", "-e", "git+", "-c")) + ) -VERSION = get_version('edx_api_doc_tools', '__init__.py') +VERSION = get_version("edx_api_doc_tools", "__init__.py") -if sys.argv[-1] == 'tag': +if sys.argv[-1] == "tag": print("Tagging the version on github:") os.system("git tag -a %s -m 'version %s'" % (VERSION, VERSION)) os.system("git push --tags") sys.exit() -README = open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8').read() -CHANGELOG = open(os.path.join(os.path.dirname(__file__), 'CHANGELOG.rst'), encoding='utf-8').read() +README = open( + os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8" +).read() +CHANGELOG = open( + os.path.join(os.path.dirname(__file__), "CHANGELOG.rst"), encoding="utf-8" +).read() setup( - name='edx-api-doc-tools', + name="edx-api-doc-tools", version=VERSION, description="Tools for writing and generating API documentation for edX REST APIs", - long_description=README + '\n\n' + CHANGELOG, + long_description=README + "\n\n" + CHANGELOG, long_description_content_type="text/x-rst", - author='Open edX Project', - author_email='oscm@openedx.org', - url='https://github.com/openedx/api-doc-tools', + author="Open edX Project", + author_email="oscm@openedx.org", + url="https://github.com/openedx/api-doc-tools", packages=[ - 'edx_api_doc_tools', + "edx_api_doc_tools", ], include_package_data=True, - install_requires=load_requirements('requirements/base.in'), + install_requires=load_requirements("requirements/base.in"), license="Apache Software License 2.0", zip_safe=False, - keywords='Django edx', + keywords="Django edx", classifiers=[ - 'Development Status :: 3 - Alpha', - 'Framework :: Django', - 'Framework :: Django :: 4.2', - 'Framework :: Django :: 5.2', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', + "Development Status :: 3 - Alpha", + "Framework :: Django", + "Framework :: Django :: 4.2", + "Framework :: Django :: 5.2", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], ) From 5e9752b0a7ccf3528bba8afd504fc23336124384 Mon Sep 17 00:00:00 2001 From: Tycho Hob Date: Fri, 30 Jan 2026 09:43:05 -0500 Subject: [PATCH 2/3] test: Remove Python 3.8 and Django 4.2 from test matrix --- .github/workflows/ci.yml | 5 +---- tox.ini | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 795d068..3992161 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,7 @@ jobs: matrix: os: [ubuntu-latest] python-version: ["3.11", "3.12"] - toxenv: - [ - django42-drflatest,django52-drflatest,quality - ] + toxenv: [django52-drflatest, quality] steps: - uses: actions/checkout@v4 diff --git a/tox.ini b/tox.ini index 1a29332..5eae9e2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{38,311,312}-django{42,52}-drf{latest} # Django 4.2 is not supported by DRF < 3.14 + py{311,312}-django{52}-drf{latest} quality [pytest] @@ -10,7 +10,6 @@ norecursedirs = .* docs requirements [testenv] deps = - django42: Django>=4.2,<4.3 django52: Django>=5.2,<5.3 drflatest: djangorestframework -r{toxinidir}/requirements/test.txt @@ -40,4 +39,3 @@ deps = -r{toxinidir}/requirements/quality.txt commands = make quality - From 2076fb18bb971b01323f5dcc262c187bf5f518c6 Mon Sep 17 00:00:00 2001 From: Tycho Hob Date: Fri, 30 Jan 2026 09:51:38 -0500 Subject: [PATCH 3/3] chore: Bump version and changelog --- CHANGELOG.rst | 4 ++++ edx_api_doc_tools/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f3dc33b..f4ed461 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,10 @@ Change Log Unreleased ---------- +2.1.2 - 2026-01-39 +------------------ +* Fix builds to PyPI + 2.1.1 - 2026-01-39 ------------------ * Fix make upgrade, update dependencies diff --git a/edx_api_doc_tools/__init__.py b/edx_api_doc_tools/__init__.py index ab2395f..edd0b3a 100644 --- a/edx_api_doc_tools/__init__.py +++ b/edx_api_doc_tools/__init__.py @@ -46,4 +46,4 @@ ) -__version__ = "2.1.1" +__version__ = "2.1.2"