Skip to content

Commit f27d761

Browse files
committed
Build with pyproject.toml
1 parent 8abf69b commit f27d761

12 files changed

Lines changed: 91 additions & 66 deletions
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
# You should have received a copy of the GNU General Public License
2121
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2222

23-
import asyncio
23+
from lsst.ts.scriptqueue import command_script_queue
2424

25-
from lsst.ts.idl.enums.ScriptQueue import SalIndex
26-
from lsst.ts.scriptqueue import ScriptQueue
2725

28-
asyncio.run(ScriptQueue.amain(index=SalIndex))
26+
command_script_queue()
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
# You should have received a copy of the GNU General Public License
2121
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2222

23-
import asyncio
23+
from lsst.ts.scriptqueue.ui import run_one_script_cli
2424

25-
from lsst.ts.idl.enums.ScriptQueue import SalIndex
26-
from lsst.ts.scriptqueue.ui import ScriptQueueCommander
2725

28-
asyncio.run(ScriptQueueCommander.amain(index=SalIndex))
26+
run_one_script_cli()
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@
2020
# You should have received a copy of the GNU General Public License
2121
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2222

23-
import asyncio
23+
from lsst.ts.scriptqueue import run_script_queue
2424

25-
from lsst.ts.scriptqueue import ui
2625

27-
28-
async def main():
29-
cmd = ui.parse_run_one_script_cmd()
30-
await ui.run_one_script(
31-
index=cmd.index, script=cmd.script, config=cmd.config, loglevel=cmd.loglevel
32-
)
33-
34-
35-
asyncio.run(main())
26+
run_script_queue()

‎conda/meta.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ source:
88

99
build:
1010
script: python -m pip install --no-deps --ignore-installed .
11+
entry_points:
12+
- command_script_queue = lsst.ts.scriptqueue:command_script_queue
13+
- run_one_script = lsst.ts.scriptqueue:run_one_script_cli
14+
- run_script_queue = lsst.ts.scriptqueue:run_script_queue
1115

1216
test:
1317
requires:
@@ -19,6 +23,7 @@ test:
1923
- bin
2024
- tests
2125
- setup.cfg
26+
- pyproject.toml
2227
commands:
2328
- py.test
2429

‎pyproject.toml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[build-system]
2+
requires = [ "setuptools", "setuptools_scm" ]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "ts_scriptqueue"
7+
description = "A CSC to run SAL scripts at Vera C. Rubin Observatory."
8+
license = { text = "GPL" }
9+
classifiers = [ "Programming Language :: Python :: 3" ]
10+
urls = { documentation = "https://ts-scriptqueue.lsst.io", repository = "https://github.com/lsst-ts/ts_scriptqueue" }
11+
dynamic = [ "version" ]
12+
13+
[tool.setuptools.dynamic]
14+
version = { attr = "setuptools_scm.get_version" }
15+
16+
[tool.setuptools.packages.find]
17+
where = [ "python" ]
18+
19+
[project.scripts]
20+
command_script_queue = "lsst.ts.scriptqueue:command_script_queue"
21+
run_one_script = "lsst.ts.scriptqueue:run_one_script_cli"
22+
run_script_queue = "lsst.ts.scriptqueue:run_script_queue"
23+
24+
[tool.setuptools_scm]
25+
write_to = "python/lsst/ts/scriptqueue/version.py"
26+
write_to_template = """
27+
# Generated by setuptools_scm
28+
__all__ = ["__version__"]
29+
__version__ = "{version}"
30+
"""
31+
32+
[tool.pytest.ini_options]
33+
addopts = "--black --flake8 --ignore-glob=*/version.py"
34+
flake8-ignore = ["E133", "E203", "E226", "E228", "N802", "N803", "N806", "N812", "N813", "N815", "N816", "W503"]
35+
flake8-max-line-length = 110
36+
flake8-max-doc-length = 79
37+
asyncio_mode = "auto"
38+
39+
[project.optional-dependencies]
40+
dev = ["documenteer[pipelines]"]

‎python/lsst/ts/scriptqueue/script_queue.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2121

22-
__all__ = ["ScriptQueue"]
22+
__all__ = ["ScriptQueue", "run_script_queue"]
2323

2424
import asyncio
2525
import os
@@ -28,6 +28,7 @@
2828
import numpy as np
2929

3030
from lsst.ts import salobj
31+
from lsst.ts.idl.enums.ScriptQueue import SalIndex
3132
from . import __version__
3233
from . import utils
3334
from .script_info import ScriptInfo
@@ -478,3 +479,8 @@ def add_kwargs_from_args(cls, args, kwargs):
478479
kwargs["standardpath"] = args.standard
479480
kwargs["externalpath"] = args.external
480481
kwargs["verbose"] = args.verbose
482+
483+
484+
def run_script_queue():
485+
"""Run the ScriptQueue CSC."""
486+
asyncio.run(ScriptQueue.amain(index=SalIndex))

‎python/lsst/ts/scriptqueue/ui/run_one_script.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2121

22-
__all__ = ["parse_run_one_script_cmd", "run_one_script"]
22+
__all__ = ["parse_run_one_script_cmd", "run_one_script", "run_one_script_cli"]
2323

2424
import argparse
25+
import asyncio
2526
import datetime
2627
import logging
2728
import pathlib
@@ -206,3 +207,16 @@ def log_callback(data):
206207
# make sure the background process is terminated
207208
await script_info.terminate()
208209
raise
210+
211+
212+
async def _run_one_script_cli_impl():
213+
"""Implementation for run_one_script_cli."""
214+
cmd = parse_run_one_script_cmd()
215+
await run_one_script(
216+
index=cmd.index, script=cmd.script, config=cmd.config, loglevel=cmd.loglevel
217+
)
218+
219+
220+
def run_one_script_cli():
221+
"""Use the command line to run one script."""
222+
asyncio.run(_run_one_script_cli_impl())

‎python/lsst/ts/scriptqueue/ui/script_queue_commander.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import string
2828

2929
from lsst.ts import salobj
30-
from lsst.ts.idl.enums.ScriptQueue import Location
30+
from lsst.ts.idl.enums.ScriptQueue import Location, SalIndex
3131
from lsst.ts.idl.enums.Script import ScriptState
3232
from lsst.ts.utils import make_done_future
3333

@@ -297,3 +297,11 @@ def add_arguments(cls, parser):
297297
@classmethod
298298
def add_kwargs_from_args(cls, args, kwargs):
299299
kwargs["script_log_level"] = args.loglevel
300+
301+
302+
def command_script_queue():
303+
"""Run a command-line interface to command a ScriptQueue.
304+
305+
Intended for engineering use.
306+
"""
307+
ScriptQueueCommander.amain(index=SalIndex)

‎setup.cfg‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[aliases]
2-
test=pytest
3-
41
[flake8]
52
max-line-length = 110
63
max-doc-length = 79
@@ -9,11 +6,3 @@ exclude =
96
doc,
107
__init__.py,
118
tests/.tests
12-
13-
[tool:pytest]
14-
addopts = --black --flake8 --ignore-glob=*/version.py
15-
flake8-ignore = E133 E203 E226 E228 N802 N803 N806 N812 N813 N815 N816 W503
16-
asyncio_mode = auto
17-
18-
[metadata]
19-
version = attr: setuptools_scm.get_version

‎setup.py‎

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
1-
from setuptools import setup, find_namespace_packages
1+
from setuptools import setup
2+
import setuptools_scm
23

3-
scm_version_template = """# Generated by setuptools_scm
4-
__all__ = ["__version__"]
5-
6-
__version__ = "{version}"
7-
"""
8-
9-
setup(
10-
name="ts_scriptqueue",
11-
description="A Commandable SAL Component (CSC) that runs Python scripts..",
12-
use_scm_version={
13-
"write_to": "python/lsst/ts/scriptqueue/version.py",
14-
"write_to_template": scm_version_template,
15-
},
16-
package_dir={"": "python"},
17-
packages=find_namespace_packages(where="python"),
18-
scripts=[
19-
"bin/command_script_queue.py",
20-
"bin/run_one_script.py",
21-
"bin/run_script_queue.py",
22-
],
23-
license="GPL",
24-
project_urls={
25-
"Bug Tracker": "https://jira.lsstcorp.org/secure/Dashboard.jspa",
26-
"Source Code": "https://github.com/lsst-ts/ts_observatory_control",
27-
},
28-
)
4+
setup(version=setuptools_scm.get_version())

0 commit comments

Comments
 (0)