Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch spin via a setuptools script/entrypoint #66

Merged
merged 4 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,32 @@ jobs:
PYTHONPATH: "."
run: |
pytest --pyargs spin
- name: Functional tests (linux)
if: matrix.os == 'ubuntu-latest'
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
TERM: xterm-256color
run: |
cd example_pkg
./spin build
./spin test
./spin sdist
- name: Patch Windows runner
if: matrix.os == 'windows-latest'
run: |
Remove-Item -Path C:\Strawberry -Recurse
Remove-Item -Path C:\ProgramData\Chocolatey\bin\gcc.exe
Remove-Item -Path C:\msys64 -Recurse -Force
Remove-Item -Path "C:\Program Files\LLVM" -Recurse
- name: Functional tests (linux)
if: matrix.os == 'ubuntu-latest'
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
TERM: xterm-256color
run: |
set -x
cd example_pkg
spin build
spin test
spin sdist
spin example
- name: Functional tests (other)
if: matrix.os != 'ubuntu-latest'
shell: bash
run: |
set -x
cd example_pkg
python spin build
python spin test
python spin sdist
spin build
spin test
spin sdist
spin example
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ When many of the build and installation commands changed, it made sense to abstr

## Installation

`spin` is not yet available via PyPi (but soon!).

Meanwhile, please install it directly from GitHub:

```
pip install git+https://github.com/scientific-python/spin
pip install spin
```

## Configuration
Expand Down Expand Up @@ -75,13 +71,13 @@ Environments:
## Running

```
python -m spin
spin
```

On Unix-like systems, you can also copy the [`dev.py` script](https://github.com/scientific-python/spin/blob/main/example_pkg/dev.py) to the root of your project directory, and launch it as:
or

```
./dev.py
python -m spin
```

## Built-in commands
Expand Down
File renamed without changes.
19 changes: 0 additions & 19 deletions example_pkg/spin

This file was deleted.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ dependencies = [
"colorama; platform_system == 'Windows'"
]

[project.scripts]
spin = "spin.__main__:main"

[project.optional-dependencies]
lint = ["pre-commit >= 3.1"]

Expand Down
25 changes: 14 additions & 11 deletions spin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import click
import toml

from . import cmds
from .cmds import util
from .cmds import *
from .sectioned_help import SectionedHelpGroup
from .color_format import ColorHelpFormatter
from spin import cmds as _cmds
from spin.cmds import util
from spin.sectioned_help import SectionedHelpGroup
from spin.color_format import ColorHelpFormatter


click.Context.formatter_class = ColorHelpFormatter
Expand All @@ -28,7 +27,7 @@ def __getitem__(self, key):
return subitem


if __name__ == "__main__":
def main():
if not os.path.exists("pyproject.toml"):
print("Error: cannot find [pyproject.toml]")
sys.exit(1)
Expand Down Expand Up @@ -67,11 +66,11 @@ def group(ctx):
# Originally, you could specify any of these commands as `spin.cmd`
# and we'd fetch it from util
commands = {
"spin.build": cmds.meson.build,
"spin.test": cmds.meson.test,
"spin.ipython": cmds.meson.ipython,
"spin.python": cmds.meson.python,
"spin.shell": cmds.meson.shell,
"spin.build": _cmds.meson.build,
"spin.test": _cmds.meson.test,
"spin.ipython": _cmds.meson.ipython,
"spin.python": _cmds.meson.python,
"spin.shell": _cmds.meson.shell,
}

for section, cmds in config_cmds.items():
Expand Down Expand Up @@ -121,3 +120,7 @@ def group(ctx):
except Exception as e:
print(f"{e}; aborting.")
sys.exit(1)


if __name__ == "__main__":
main()