Skip to content

Commit cfd73c6

Browse files
authored
Modernize setuptools configuration (#1341)
* modernize setuptools configuration slightly * Add a pyproject.toml, which specifies the build-time dependency on babel. This is required for `pip install` to work in some cases * Don't use deprecated direct setup.py invocations in Dockerfile * Fix option names in setup.cfg (I'm not even sure why the old ones used to work...) * Replace the build_py override hack in setup.py with a slightly nicer hack (arguably still a hack, but at least it doesn't require calling private methods manually) * Update some setup() metadata fields in setup.py (classifiers had outdated python version; download_url doesn't seem to be used for anything at all and the link is outdated anyways; use license expression instead of plain name) * docs: replace references to `setup.py install` with `pip install`
1 parent e81a01c commit cfd73c6

File tree

7 files changed

+22
-27
lines changed

7 files changed

+22
-27
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ RUN sudo pip3 install --break-system-packages -r dev-requirements.txt
4545

4646
COPY --chown=cmsuser:cmsuser . /home/cmsuser/cms
4747

48-
RUN sudo python3 setup.py install
48+
RUN sudo pip3 install --break-system-packages .
4949

5050
RUN sudo python3 prerequisites.py --yes --cmsuser=cmsuser install
5151

docs/Docker image.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ similar to:
9797
The command will build a fresh CMS image when necessary, and drop you into a
9898
bash prompt where the repository is mounted on ``~/cms`` for ease of
9999
development. You can edit the code from the host (i.e. outside the container)
100-
and then reinstall CMS (``python3 setup.py install``) directly from inside the
100+
and then reinstall CMS (``pip install .``) directly from inside the
101101
container, without having to rebuild the image every time.
102102

103103
Upon running ``cms-dev.sh`` for the first time, the database will initially be

docs/Installation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ version. So, you can install python dependencies by issuing:
166166

167167
.. sourcecode:: bash
168168

169-
pip3 install -r requirements.txt
170-
python3 setup.py install
169+
pip install -r requirements.txt
170+
pip install .
171171

172172
.. note::
173173

@@ -199,14 +199,14 @@ Assuming you have ``pip`` installed, you can do this:
199199
.. sourcecode:: bash
200200

201201
sudo pip3 install -r requirements.txt
202-
sudo python3 setup.py install
202+
sudo pip3 install .
203203

204204
This command installs python dependencies globally. Note that on some distros, like Arch Linux, this might interfere with the system package manager. If you want to perform the installation in your home folder instead, then you can do this instead:
205205

206206
.. sourcecode:: bash
207207

208208
pip3 install --user -r requirements.txt
209-
python3 setup.py install --user
209+
pip3 install --user .
210210

211211
Method 4: Using your distribution's system packages
212212
---------------------------------------------------

docs/Task types.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ Once that is done, install the distribution by executing
194194

195195
.. sourcecode:: bash
196196

197-
python3 setup.py install
197+
pip3 install .
198198

199199
CMS needs to be restarted for it to pick up the new task type.
200200

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "babel == 2.12.1"]
3+
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# This file provides default options for setup.py commands.
22

33
[extract_messages]
4-
mapping-file: babel_mapping.cfg
4+
mapping_file: babel_mapping.cfg
55
keywords: n_:1,2 Nn_:1,2
6-
output-file: cms/locale/cms.pot
7-
no-location: 1
6+
output_file: cms/locale/cms.pot
7+
no_location: 1
88
width: 79
99
project: Contest Management System
10-
copyright-holder: CMS development group
11-
msgid-bugs-address: [email protected]
10+
copyright_holder: CMS development group
11+
msgid_bugs_address: [email protected]
1212

1313
[init_catalog]
1414
domain: cms
15-
input-file: cms/locale/cms.pot
16-
output-dir: cms/locale
15+
input_file: cms/locale/cms.pot
16+
output_dir: cms/locale
1717
width: 79
1818

1919
[update_catalog]
2020
domain: cms
21-
input-file: cms/locale/cms.pot
22-
output-dir: cms/locale
21+
input_file: cms/locale/cms.pot
22+
output_dir: cms/locale
2323
width: 79
2424

2525
[compile_catalog]

setup.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,7 @@ def find_version():
106106
# the po and mofiles will be part of the package data for cms.locale,
107107
# which is collected at this stage.
108108
class build_py_and_l10n(build_py):
109-
def run(self):
110-
self.run_command("compile_catalog")
111-
# The build command of distutils/setuptools searches the tree
112-
# and compiles a list of data files before run() is called and
113-
# then stores that value. Hence we need to refresh it.
114-
self.data_files = self._get_data_files()
115-
super().run()
109+
sub_commands = [('compile_catalog', None)] + build_py.sub_commands
116110

117111

118112
setup(
@@ -121,7 +115,6 @@ def run(self):
121115
author="The CMS development team",
122116
author_email="[email protected]",
123117
url="https://github.com/cms-dev/cms",
124-
download_url="https://github.com/cms-dev/cms/archive/master.tar.gz",
125118
description="A contest management system and grader for IOI-like programming competitions",
126119
packages=find_packages(),
127120
package_data=PACKAGE_DATA,
@@ -201,12 +194,11 @@ def run(self):
201194
],
202195
},
203196
keywords="ioi programming contest grader management system",
204-
license="Affero General Public License v3",
197+
license_expression="AGPL-3.0-only",
205198
classifiers=[
206199
"Development Status :: 5 - Production/Stable",
207200
"Natural Language :: English",
208201
"Operating System :: POSIX :: Linux",
209-
"Programming Language :: Python :: 3.9",
210-
"License :: OSI Approved :: GNU Affero General Public License v3",
202+
"Programming Language :: Python :: 3.12",
211203
],
212204
)

0 commit comments

Comments
 (0)