Skip to content

Commit c1a12a1

Browse files
author
Tycho Hob
committed
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
1 parent 073590a commit c1a12a1

2 files changed

Lines changed: 58 additions & 44 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ name: Publish package to PyPi
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
77

88
jobs:
9-
109
push:
1110
runs-on: ubuntu-latest
1211

@@ -16,7 +15,7 @@ jobs:
1615
- name: setup python
1716
uses: actions/setup-python@v5
1817
with:
19-
python-version: 3.8
18+
python-version: 3.11
2019

2120
- name: Install pip
2221
run: pip install -r requirements/pip.txt
@@ -32,4 +31,3 @@ jobs:
3231
with:
3332
user: __token__
3433
password: ${{ secrets.PYPI_UPLOAD_TOKEN }}
35-

setup.py

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from setuptools import setup
1111

12-
1312
# We open files with one-line shorthands, it's ok.
1413
# pylint: disable=consider-using-with
1514

@@ -19,12 +18,11 @@ def get_version(*file_paths):
1918
Extract the version string from the file at the given relative path fragments.
2019
"""
2120
filename = os.path.join(os.path.dirname(__file__), *file_paths)
22-
version_file = open(filename, encoding='utf-8').read()
23-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
24-
version_file, re.M)
21+
version_file = open(filename, encoding="utf-8").read()
22+
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
2523
if version_match:
2624
return version_match.group(1)
27-
raise RuntimeError('Unable to find version string.')
25+
raise RuntimeError("Unable to find version string.")
2826

2927

3028
def load_requirements(*requirements_paths):
@@ -49,14 +47,14 @@ def check_name_consistent(package):
4947
with extras we don't constrain it without mentioning the extras (since
5048
that too would interfere with matching constraints.)
5149
"""
52-
canonical = package.lower().replace('_', '-').split('[')[0]
50+
canonical = package.lower().replace("_", "-").split("[")[0]
5351
seen_spelling = by_canonical_name.get(canonical)
5452
if seen_spelling is None:
5553
by_canonical_name[canonical] = package
5654
elif seen_spelling != package:
5755
raise RuntimeError(
5856
f'Encountered both "{seen_spelling}" and "{package}" in requirements '
59-
'and constraints files; please use just one or the other.'
57+
"and constraints files; please use just one or the other."
6058
)
6159

6260
requirements = {}
@@ -70,7 +68,9 @@ def check_name_consistent(package):
7068
% (re_package_name_base_chars, re_package_name_base_chars)
7169
)
7270

73-
def add_version_constraint_or_raise(current_line, current_requirements, add_if_not_present):
71+
def add_version_constraint_or_raise(
72+
current_line, current_requirements, add_if_not_present
73+
):
7474
regex_match = requirement_line_regex.match(current_line)
7575
if regex_match:
7676
package = regex_match.group(1)
@@ -79,11 +79,16 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n
7979
existing_version_constraints = current_requirements.get(package, None)
8080
# It's fine to add constraints to an unconstrained package,
8181
# but raise an error if there are already constraints in place.
82-
if existing_version_constraints and existing_version_constraints != version_constraints:
83-
raise BaseException(f'Multiple constraint definitions found for {package}:'
84-
f' "{existing_version_constraints}" and "{version_constraints}".'
85-
f'Combine constraints into one location with {package}'
86-
f'{existing_version_constraints},{version_constraints}.')
82+
if (
83+
existing_version_constraints
84+
and existing_version_constraints != version_constraints
85+
):
86+
raise BaseException(
87+
f"Multiple constraint definitions found for {package}:"
88+
f' "{existing_version_constraints}" and "{version_constraints}".'
89+
f"Combine constraints into one location with {package}"
90+
f"{existing_version_constraints},{version_constraints}."
91+
)
8792
if add_if_not_present or package in current_requirements:
8893
current_requirements[package] = version_constraints
8994

@@ -94,8 +99,12 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n
9499
for line in reqs:
95100
if is_requirement(line):
96101
add_version_constraint_or_raise(line, requirements, True)
97-
if line and line.startswith('-c') and not line.startswith('-c http'):
98-
constraint_files.add(os.path.dirname(path) + '/' + line.split('#')[0].replace('-c', '').strip())
102+
if line and line.startswith("-c") and not line.startswith("-c http"):
103+
constraint_files.add(
104+
os.path.dirname(path)
105+
+ "/"
106+
+ line.split("#")[0].replace("-c", "").strip()
107+
)
99108

100109
# process constraint files: add constraints to existing requirements
101110
for constraint_file in constraint_files:
@@ -105,7 +114,9 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n
105114
add_version_constraint_or_raise(line, requirements, False)
106115

107116
# process back into list of pkg><=constraints strings
108-
constrained_requirements = [f'{pkg}{version or ""}' for (pkg, version) in sorted(requirements.items())]
117+
constrained_requirements = [
118+
f"{pkg}{version or ''}" for (pkg, version) in sorted(requirements.items())
119+
]
109120
return constrained_requirements
110121

111122

@@ -119,48 +130,53 @@ def is_requirement(line):
119130
"""
120131
# UPDATED VIA SEMGREP - if you need to remove/modify this method remove this line and add a comment specifying why
121132

122-
return line and line.strip() and not line.startswith(('-r', '#', '-e', 'git+', '-c'))
133+
return (
134+
line and line.strip() and not line.startswith(("-r", "#", "-e", "git+", "-c"))
135+
)
123136

124137

125-
VERSION = get_version('edx_api_doc_tools', '__init__.py')
138+
VERSION = get_version("edx_api_doc_tools", "__init__.py")
126139

127-
if sys.argv[-1] == 'tag':
140+
if sys.argv[-1] == "tag":
128141
print("Tagging the version on github:")
129142
os.system("git tag -a %s -m 'version %s'" % (VERSION, VERSION))
130143
os.system("git push --tags")
131144
sys.exit()
132145

133-
README = open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8').read()
134-
CHANGELOG = open(os.path.join(os.path.dirname(__file__), 'CHANGELOG.rst'), encoding='utf-8').read()
146+
README = open(
147+
os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8"
148+
).read()
149+
CHANGELOG = open(
150+
os.path.join(os.path.dirname(__file__), "CHANGELOG.rst"), encoding="utf-8"
151+
).read()
135152

136153
setup(
137-
name='edx-api-doc-tools',
154+
name="edx-api-doc-tools",
138155
version=VERSION,
139156
description="Tools for writing and generating API documentation for edX REST APIs",
140-
long_description=README + '\n\n' + CHANGELOG,
157+
long_description=README + "\n\n" + CHANGELOG,
141158
long_description_content_type="text/x-rst",
142-
author='Open edX Project',
143-
author_email='oscm@openedx.org',
144-
url='https://github.com/openedx/api-doc-tools',
159+
author="Open edX Project",
160+
author_email="oscm@openedx.org",
161+
url="https://github.com/openedx/api-doc-tools",
145162
packages=[
146-
'edx_api_doc_tools',
163+
"edx_api_doc_tools",
147164
],
148165
include_package_data=True,
149-
install_requires=load_requirements('requirements/base.in'),
166+
install_requires=load_requirements("requirements/base.in"),
150167
license="Apache Software License 2.0",
151168
zip_safe=False,
152-
keywords='Django edx',
169+
keywords="Django edx",
153170
classifiers=[
154-
'Development Status :: 3 - Alpha',
155-
'Framework :: Django',
156-
'Framework :: Django :: 4.2',
157-
'Framework :: Django :: 5.2',
158-
'Intended Audience :: Developers',
159-
'License :: OSI Approved :: Apache Software License',
160-
'Natural Language :: English',
161-
'Programming Language :: Python :: 3',
162-
'Programming Language :: Python :: 3.8',
163-
'Programming Language :: Python :: 3.11',
164-
'Programming Language :: Python :: 3.12',
171+
"Development Status :: 3 - Alpha",
172+
"Framework :: Django",
173+
"Framework :: Django :: 4.2",
174+
"Framework :: Django :: 5.2",
175+
"Intended Audience :: Developers",
176+
"License :: OSI Approved :: Apache Software License",
177+
"Natural Language :: English",
178+
"Programming Language :: Python :: 3",
179+
"Programming Language :: Python :: 3.11",
180+
"Programming Language :: Python :: 3.12",
165181
],
166182
)

0 commit comments

Comments
 (0)