Skip to content

Commit 5845ac2

Browse files
ctruedenclaude
andcommitted
Fix project metadata and document usage
The name, description and inception year were inherited from scripting-python. License headers are regenerated accordingly. The README now explains how to write scripts, how environments are managed, and how inputs and outputs are passed to and from Python. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent aa2c488 commit 5845ac2

13 files changed

Lines changed: 128 additions & 51 deletions

File tree

‎LICENSE.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2021 - 2025, SciJava developers.
1+
Copyright (c) 2026, SciJava developers.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,

‎README.md‎

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,69 @@
22

33
# Python Scripting with Appose
44

5-
This library provides a
6-
[JSR-223-compliant](https://en.wikipedia.org/wiki/Scripting_for_the_Java_Platform)
7-
scripting plugin for the [Python](https://python.org/) language, built on
8-
the [appose](https://github.com/apposed/appose-python) Python package.
9-
10-
It is implemented as a `ScriptLanguage` plugin for the [SciJava
11-
Common](https://github.com/scijava/scijava-common) platform, which means that
12-
in addition to being usable directly as a `javax.script.ScriptEngineFactory`,
13-
it also provides some functionality on top.
14-
15-
For a complete list of scripting languages available as part of the SciJava
16-
platform, see the
17-
[Scripting](https://github.com/scijava/scijava-common/wiki/Scripting) page on
18-
the SciJava Common wiki.
19-
20-
See also:
21-
* [Python Scripting](https://imagej.net/scripting/python) on the ImageJ wiki.
5+
This library provides a `ScriptLanguage` plugin for the
6+
[SciJava Common](https://github.com/scijava/scijava-common) platform that runs
7+
scripts in [CPython](https://python.org/) (not Jython!), each in its own
8+
Python environment, using [Appose](https://github.com/apposed/appose).
9+
10+
Scripts are ordinary SciJava scripts: they declare
11+
[script parameters](https://imagej.net/scripting/parameters) and can be run
12+
from the Script Editor or menus of ImageJ2/Fiji like any other script.
13+
14+
## Writing a script
15+
16+
```python
17+
#!appose-python
18+
#@script(env="myenv.toml")
19+
20+
#@ Img image
21+
#@ double sigma
22+
#@output Img blurred
23+
24+
from scipy.ndimage import gaussian_filter
25+
26+
print(f"Blurring image of shape {image.shape}")
27+
blurred = gaussian_filter(image, sigma)
28+
```
29+
30+
* The `#!appose-python` line selects this script language, rather than
31+
another language handling `.py` files, such as Jython.
32+
* The `env` attribute points to an environment configuration file, resolved
33+
relative to the script's location. Any format Appose supports works:
34+
`pixi.toml`, `environment.yml`, `requirements.txt` or `pyproject.toml`.
35+
An optional `scheme` attribute (e.g. `scheme="pixi.toml"`) sets the format
36+
explicitly, which is useful when the file name does not reveal it.
37+
* The environment must include the `appose` Python package, plus `numpy` if
38+
the script uses images.
39+
40+
See the `StarDist_cellcast.py` template for a complete example.
41+
42+
## Environments
43+
44+
The environment is built the first time a script needs it, which may take a
45+
while. Afterward, it is reused, both within the running application and across
46+
restarts. Environments are stored in the Appose environments directory
47+
(`~/.local/share/appose` by default), named after the configuration file.
48+
Scripts that share a configuration file share an environment. Editing the file
49+
causes the environment to be updated on the next run.
50+
51+
Each script run starts a fresh Python process.
52+
53+
## Inputs and outputs
54+
55+
* Images (anything convertible to an Appose `NDArray`, such as an ImgLib2
56+
`Img`) are passed via shared memory and appear in Python as
57+
NumPy arrays. Axes are in NumPy's usual order, which is the reverse of
58+
ImgLib2's: an image with X×Y dimensions `512×384` has NumPy shape
59+
`(384, 512)`.
60+
* Numbers, strings, booleans, lists and maps are passed as the corresponding
61+
Python values; files are passed as path strings.
62+
* Outputs are read from the Python variables of the same names after the
63+
script finishes. NumPy arrays are converted back to images; NumPy scalars
64+
become plain numbers. Outputs the script never assigns are left empty.
65+
* If the script declares no outputs and ends with an expression, its value
66+
becomes the script's result.
67+
68+
Text printed to stdout and stderr appears in the Script Editor's output
69+
panes. Errors are reported with a Python traceback that refers to the
70+
script's own line numbers.

‎pom.xml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<artifactId>scripting-appose-python</artifactId>
1313
<version>0.1.0-SNAPSHOT</version>
1414

15-
<name>SciJava Scripting: Python</name>
16-
<description>Python scripting language plugin to be used via scyjava.</description>
15+
<name>SciJava Scripting: Appose Python</name>
16+
<description>Python scripting language plugin backed by Appose.</description>
1717
<url>https://github.com/scijava/scripting-appose-python</url>
18-
<inceptionYear>2021</inceptionYear>
18+
<inceptionYear>2026</inceptionYear>
1919
<organization>
2020
<name>SciJava</name>
2121
<url>https://scijava.org/</url>

‎src/main/java/org/scijava/plugins/scripting/appose/python/ApposePythonScriptEngine.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* #%L
3-
* Python scripting language plugin to be used via scyjava.
3+
* Python scripting language plugin backed by Appose.
44
* %%
5-
* Copyright (C) 2021 - 2025 SciJava developers.
5+
* Copyright (C) 2026 SciJava developers.
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

‎src/main/java/org/scijava/plugins/scripting/appose/python/ApposePythonScriptLanguage.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* #%L
3-
* Python scripting language plugin to be used via scyjava.
3+
* Python scripting language plugin backed by Appose.
44
* %%
5-
* Copyright (C) 2021 - 2025 SciJava developers.
5+
* Copyright (C) 2026 SciJava developers.
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:

‎src/main/java/org/scijava/plugins/scripting/appose/python/ApposePythonScriptSyntaxHighlighter.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* #%L
3-
* Python scripting language plugin to be used via scyjava.
3+
* Python scripting language plugin backed by Appose.
44
* %%
5-
* Copyright (C) 2021 - 2025 SciJava developers.
5+
* Copyright (C) 2026 SciJava developers.
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:

‎src/main/java/org/scijava/plugins/scripting/appose/python/NDArrayToImgConverter.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* #%L
3-
* Python scripting language plugin to be used via scyjava.
3+
* Python scripting language plugin backed by Appose.
44
* %%
5-
* Copyright (C) 2021 - 2025 SciJava developers.
5+
* Copyright (C) 2026 SciJava developers.
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

‎src/main/java/org/scijava/plugins/scripting/appose/python/RAIToNDArrayConverter.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* #%L
3-
* Python scripting language plugin to be used via scyjava.
3+
* Python scripting language plugin backed by Appose.
44
* %%
5-
* Copyright (C) 2021 - 2025 SciJava developers.
5+
* Copyright (C) 2026 SciJava developers.
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

‎src/main/resources/org/scijava/plugins/scripting/appose/python/wrapper.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
###
2+
# #%L
3+
# Python scripting language plugin backed by Appose.
4+
# %%
5+
# Copyright (C) 2026 SciJava developers.
6+
# %%
7+
# Redistribution and use in source and binary forms, with or without
8+
# modification, are permitted provided that the following conditions are met:
9+
#
10+
# 1. Redistributions of source code must retain the above copyright notice,
11+
# this list of conditions and the following disclaimer.
12+
# 2. Redistributions in binary form must reproduce the above copyright notice,
13+
# this list of conditions and the following disclaimer in the documentation
14+
# and/or other materials provided with the distribution.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
# POSSIBILITY OF SUCH DAMAGE.
27+
# #L%
28+
###
129
# Appose task script that runs a SciJava appose-python script.
230
#
331
# The Java side passes the following task inputs, alongside the script's own

‎src/test/java/org/scijava/plugins/scripting/appose/python/ApposePythonIntegrationTest.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* #%L
3-
* Python scripting language plugin to be used via scyjava.
3+
* Python scripting language plugin backed by Appose.
44
* %%
5-
* Copyright (C) 2021 - 2025 SciJava developers.
5+
* Copyright (C) 2026 SciJava developers.
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

0 commit comments

Comments
 (0)