Skip to content

Commit 018db2e

Browse files
adam2392stefanv
andauthored
Add pip install with editable mode (#139)
* Add pip install Signed-off-by: Adam Li <adam2392@gmail.com> * Fix `spin install` logic --------- Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
1 parent 8e653c8 commit 018db2e

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

.github/workflows/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ prun spin example
4848
pip install sphinx
4949
prun spin docs
5050

51+
5152
## Platform specialized tests
5253

5354
if [[ $PLATFORM == linux ]]; then
@@ -57,3 +58,8 @@ fi
5758
# if [[ $PLATFORM == darwin ]]; then
5859

5960
# if [[ $PLATFORM =~ ^win.* ]]; then
61+
62+
63+
prun spin install
64+
cd /tmp
65+
python -c 'import example_pkg; print(example_pkg.__version__)'

example_pkg/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ package = 'example_pkg'
2828
"Build" = [
2929
"spin.cmds.meson.build",
3030
"spin.cmds.meson.test",
31-
"spin.cmds.build.sdist"
31+
"spin.cmds.build.sdist",
32+
"spin.cmds.pip.install",
3233
]
3334
"Documentation" = [
3435
"spin.cmds.meson.docs"
@@ -44,3 +45,6 @@ package = 'example_pkg'
4445
"spin.cmds.meson.lldb"
4546
]
4647
"Extensions" = [".spin/cmds.py:example"]
48+
"Install" = [
49+
"spin.cmds.pip.install"
50+
]

spin/cmds/pip.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import click
2+
3+
from .util import run as _run
4+
5+
6+
@click.command()
7+
@click.option(
8+
"-v",
9+
"--verbose",
10+
is_flag=True,
11+
default=False,
12+
help="Print detailed build and installation output",
13+
)
14+
@click.option(
15+
"--editable/--no-editable",
16+
is_flag=True,
17+
default=True,
18+
help="Install in editable mode",
19+
)
20+
@click.argument("pip_args", nargs=-1)
21+
def install(pip_args, verbose, editable):
22+
"""💽 Build and install package using pip.
23+
24+
By default, the package is installed in editable mode.
25+
26+
Arguments after `--` are passed through to pip, e.g.:
27+
28+
spin install -- --no-clean
29+
30+
would translated to:
31+
32+
pip install . --no-build-isolation --editable --no-clean
33+
"""
34+
pip_args = list(pip_args)
35+
pip_cmd = ["pip", "install"]
36+
pip_args += ["--no-build-isolation"]
37+
if editable:
38+
pip_args += ["--editable"]
39+
40+
pip_args = (["-v"] if verbose else []) + pip_args
41+
42+
_run(pip_cmd + pip_args + ["."], sys_exit=False, replace=True)

0 commit comments

Comments
 (0)