Skip to content

Commit 86b9d98

Browse files
authored
get rid of setup.py (#4466)
* avoid direct setup.py invocation in Python tools fixes #4429
1 parent 48354bc commit 86b9d98

File tree

12 files changed

+522
-111
lines changed

12 files changed

+522
-111
lines changed

Diff for: .github/workflows/docker.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
python-version: '3.10'
1414
- name: Install dependencies
1515
run: python3 -m pip install -r docker/requirements.txt
16-
- name: Install opengrok-tools
17-
run: python3 setup.py install
16+
- name: Install opengrok-tools so that pylint can perform the checks
17+
run: python3 -m pip install .
1818
working-directory: tools
1919
- name: Install checkers
2020
run: python3 -m pip install pylint flake8 black isort

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ pmd.bat
5959
*/bin/
6060
.classpath
6161
.checkstyle
62-
62+
.tox

Diff for: tools/LICENSE

+387
Large diffs are not rendered by default.

Diff for: tools/MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include README-dist.txt
1+
include README.txt

Diff for: tools/README.md

+9-10
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33

44
Set of scripts to facilitate project synchronization and mirroring
55

6-
The scripts require Python 3 and they rely on a binary/symlink `python3` to be
6+
The scripts require Python 3, and they rely on a binary/symlink `python3` to be
77
present that points to the latest Python 3.x version present on the system.
88

9-
Currently it is assumed that Python 3.6 and greater is used.
9+
Currently, it is assumed that Python 3.9 and greater is used.
1010

11-
See https://github.com/oracle/opengrok/wiki/Repository-synchronization
12-
for more details.
11+
See https://github.com/oracle/opengrok/wiki/Repository-synchronization for more details.
1312

1413
# Content
1514

@@ -44,7 +43,7 @@ python3 -m venv env
4443
When you start developing, install the package in a development mode.
4544

4645
```bash
47-
python setup.py develop
46+
python -m pip install -e .
4847
```
4948

5049
This installs the package however keeping the links directly to your source,
@@ -61,7 +60,7 @@ opengrok-sync
6160
It is necessary to set the python path as the python interpreter is not able to find the packages
6261
in our provided structure on its own.
6362

64-
Also you call the opengrok tools scripts by the entry points then (`opengrok-groups`, ...).
63+
Also, you call the opengrok tools scripts by the entry points then (`opengrok-groups`, ...).
6564
Calling directly the python script `groups.py` would lead to error related to relative imports.
6665

6766
Note that on macOS, you will need to install libgit2 library for the tests
@@ -72,7 +71,7 @@ to pass.
7271
Test installing your package into the local environment
7372

7473
```bash
75-
python setup.py install
74+
python -m pip install .
7675
# now you can try console scripts
7776
opengrok-groups
7877
opengrok-sync
@@ -81,10 +80,12 @@ opengrok-sync
8180
or make a distribution tarball.
8281

8382
```bash
84-
python setup.py sdist
83+
python -m build
8584
ls -l dist/
8685
```
8786

87+
Note that when run outside of Maven, this will use the 0.0.1 version for the package.
88+
8889
### Installation on the target system
8990

9091
Use the distribution tarball and run `pip`.
@@ -124,7 +125,6 @@ python3 -m pip uninstall opengrok_tools
124125
## Testing
125126

126127
```bash
127-
python setup.py install test
128128
./mvnw test
129129
```
130130

@@ -136,4 +136,3 @@ deactivate
136136
# optionally
137137
# rm -r env
138138
```
139-

Diff for: tools/pom.xml

+37-22
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
4343
<python.environment>${project.build.directory}/env/bin</python.environment>
4444
<project.python.package.version>${project.version}</project.python.package.version>
4545
<python.checkstyle.line-length>119</python.checkstyle.line-length>
46+
<outputDirectory>${project.build.directory}/dist</outputDirectory>
4647
</properties>
4748

4849
<profiles>
@@ -152,8 +153,8 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
152153
<includes>
153154
<include>MANIFEST.in</include>
154155
<include>README-dist.txt</include>
155-
<include>setup.py</include>
156-
<include>setup.cfg</include>
156+
<include>pyproject.toml</include>
157+
<include>LICENSE</include>
157158
</includes>
158159
</resource>
159160
</resources>
@@ -166,7 +167,7 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
166167
<goal>copy-resources</goal>
167168
</goals>
168169
<configuration>
169-
<outputDirectory>${project.build.directory}/dist</outputDirectory>
170+
<outputDirectory>${outputDirectory}</outputDirectory>
170171
<resources>
171172
<resource>
172173
<directory>${basedir}</directory>
@@ -179,10 +180,28 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
179180
</execution>
180181
</executions>
181182
</plugin>
183+
<plugin>
184+
<groupId>com.coderplus.maven.plugins</groupId>
185+
<artifactId>copy-rename-maven-plugin</artifactId>
186+
<version>1.0.1</version>
187+
<executions>
188+
<execution>
189+
<id>rename-file</id>
190+
<phase>compile</phase>
191+
<goals>
192+
<goal>rename</goal>
193+
</goals>
194+
<configuration>
195+
<sourceFile>${project.build.directory}/README-dist.txt</sourceFile>
196+
<destinationFile>${project.build.directory}/README.txt</destinationFile>
197+
</configuration>
198+
</execution>
199+
</executions>
200+
</plugin>
182201
<plugin>
183202
<groupId>org.codehaus.mojo</groupId>
184203
<artifactId>exec-maven-plugin</artifactId>
185-
<version>1.6.0</version>
204+
<version>3.1.0</version>
186205
<executions>
187206
<execution>
188207
<id>Generate python env</id>
@@ -201,7 +220,7 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
201220
</goals>
202221
</execution>
203222
<execution>
204-
<!-- needed for 'pip install pylint' to work -->
223+
<!-- needed for the subsequent steps to work -->
205224
<id>Upgrade pip and install/upgrade other packages</id>
206225
<configuration>
207226
<executable>${python.environment}/python</executable>
@@ -215,6 +234,8 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
215234
<argument>setuptools</argument>
216235
<argument>certifi</argument>
217236
<argument>wheel</argument>
237+
<argument>build</argument>
238+
<argument>tox</argument>
218239
</arguments>
219240
</configuration>
220241
<phase>test</phase>
@@ -224,29 +245,29 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
224245
</execution>
225246
<execution>
226247
<id>Generate python package</id>
227-
<goals>
228-
<goal>exec</goal>
229-
</goals>
230248
<configuration>
231249
<executable>${python.environment}/python</executable>
232250
<workingDirectory>${project.build.directory}</workingDirectory>
233251
<arguments>
234-
<argument>setup.py</argument>
235-
<argument>sdist</argument>
236-
<argument>--formats</argument>
237-
<argument>gztar</argument>
252+
<argument>-m</argument>
253+
<argument>build</argument>
238254
</arguments>
239255
</configuration>
240-
<phase>package</phase>
256+
<phase>test</phase>
257+
<goals>
258+
<goal>exec</goal>
259+
</goals>
241260
</execution>
242261
<execution>
243-
<id>Install python package for tests/pylint</id>
262+
<id>Install the built python package for tests/pylint</id>
244263
<configuration>
245264
<executable>${python.environment}/python</executable>
246265
<workingDirectory>${project.build.directory}</workingDirectory>
247266
<arguments>
248-
<argument>setup.py</argument>
267+
<argument>-m</argument>
268+
<argument>pip</argument>
249269
<argument>install</argument>
270+
<argument>${outputDirectory}/opengrok-tools-${project.version}.tar.gz</argument>
250271
</arguments>
251272
<skip>${skipPythonTests}</skip>
252273
</configuration>
@@ -285,7 +306,6 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
285306
<argument>${python.checkstyle.line-length}</argument>
286307
<argument>-E</argument>
287308
<argument>${project.build.sourceDirectory}/opengrok_tools</argument>
288-
<argument>${project.build.directory}/setup.py</argument>
289309
</arguments>
290310
<skip>${skipPythonTests}</skip>
291311
</configuration>
@@ -307,7 +327,6 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
307327
<argument>-v</argument>
308328
<argument>${project.build.sourceDirectory}</argument>
309329
<argument>${project.build.testSourceDirectory}</argument>
310-
<argument>setup.py</argument>
311330
</arguments>
312331
</configuration>
313332
<phase>verify</phase>
@@ -318,15 +337,11 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire <[email protected]>.
318337
<execution>
319338
<id>Test python package</id>
320339
<configuration>
321-
<executable>${python.environment}/python</executable>
340+
<executable>${python.environment}/tox</executable>
322341
<workingDirectory>${project.build.directory}</workingDirectory>
323342
<environmentVariables>
324343
<PATH>${python.environment}:${env.PATH}</PATH>
325344
</environmentVariables>
326-
<arguments>
327-
<argument>setup.py</argument>
328-
<argument>test</argument>
329-
</arguments>
330345
<skip>${skipPythonTests}</skip>
331346
</configuration>
332347
<phase>test</phase>

Diff for: tools/pyproject.toml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = ["setuptools >=61.2"]
4+
5+
[project]
6+
name = "opengrok-tools"
7+
description = "Tools for managing OpenGrok instance"
8+
readme = "README.txt"
9+
dynamic = ["version"]
10+
requires-python = ">=3.9"
11+
classifiers = [
12+
"Development Status :: 5 - Production/Stable",
13+
"License :: OSI Approved :: CDDL",
14+
"Natural Language :: English",
15+
"Operating System :: OS Independent",
16+
"Programming Language :: Python",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
]
20+
dependencies = [
21+
'jsonschema==2.6.0', # to avoid Rust
22+
'pyyaml',
23+
'requests>=2.20.0',
24+
'resource',
25+
'filelock',
26+
]
27+
28+
[tool.setuptools]
29+
packages = ["opengrok_tools", "opengrok_tools.utils", "opengrok_tools.scm"]
30+
31+
[tool.setuptools.package-dir]
32+
"opengrok_tools" = "src/main/python/opengrok_tools"
33+
"opengrok_tools.scm" = "src/main/python/opengrok_tools/scm"
34+
"opengrok_tools.utils" = "src/main/python/opengrok_tools/utils"
35+
36+
[project.scripts]
37+
opengrok-config-merge = "opengrok_tools.config_merge:main"
38+
opengrok-deploy = "opengrok_tools.deploy:main"
39+
opengrok-groups = "opengrok_tools.groups:main"
40+
opengrok = "opengrok_tools.indexer:main"
41+
opengrok-indexer = "opengrok_tools.indexer:main"
42+
opengrok-java = "opengrok_tools.java:main"
43+
opengrok-mirror = "opengrok_tools.mirror:main"
44+
opengrok-projadm = "opengrok_tools.projadm:main"
45+
opengrok-reindex-project = "opengrok_tools.reindex_project:main"
46+
opengrok-sync = "opengrok_tools.sync:main"
47+
48+
[project.urls]
49+
"Homepage" = "https://github.com/oracle/opengrok"
50+
"Bug tracker" = "https://github.com/oracle/opengrok/issues"
51+
52+
[tool.setuptools.dynamic]
53+
version = {attr = "opengrok_tools.version.__version__" }

Diff for: tools/setup.cfg

-6
This file was deleted.

Diff for: tools/setup.py

-65
This file was deleted.

0 commit comments

Comments
 (0)