Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
06a2bd17
Unverified
Commit
06a2bd17
authored
May 21, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge run and script
parent
1dd12f7d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
10 deletions
+45
-10
CHANGELOG.md
+1
-0
docs/docs/cli.md
+2
-6
poetry/console/commands/run.py
+36
-0
poetry/console/commands/script.py
+6
-4
No files found.
CHANGELOG.md
View file @
06a2bd17
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
### Changed
### Changed
-
Improved the
`show`
command to make it easier to check if packages are properly installed.
-
Improved the
`show`
command to make it easier to check if packages are properly installed.
-
The
`script`
command has been deprecated, use
`run`
instead.
-
Expanded version constraints now keep the original version's precision.
-
Expanded version constraints now keep the original version's precision.
### Fixed
### Fixed
...
...
docs/docs/cli.md
View file @
06a2bd17
...
@@ -289,11 +289,7 @@ The `run` command executes the given command inside the project's virtualenv.
...
@@ -289,11 +289,7 @@ The `run` command executes the given command inside the project's virtualenv.
poetry run python -V
poetry run python -V
```
```
Note that this command has no option.
It can also executes one of the scripts defined in `
pyproject.toml
`.
## script
The `
script
` executes one of the scripts defined in `
pyproject.toml
`.
So, if you have a script defined like this:
So, if you have a script defined like this:
...
@@ -305,7 +301,7 @@ my-script = "my_module:main"
...
@@ -305,7 +301,7 @@ my-script = "my_module:main"
You can execute it like so:
You can execute it like so:
```bash
```bash
poetry
script
my-script
poetry
run
my-script
```
```
Note that this command has no option.
Note that this command has no option.
...
...
poetry/console/commands/run.py
View file @
06a2bd17
...
@@ -11,11 +11,47 @@ class RunCommand(VenvCommand):
...
@@ -11,11 +11,47 @@ class RunCommand(VenvCommand):
def
handle
(
self
):
def
handle
(
self
):
args
=
self
.
argument
(
'args'
)
args
=
self
.
argument
(
'args'
)
script
=
args
[
0
]
scripts
=
self
.
poetry
.
local_config
.
get
(
'scripts'
)
if
scripts
and
script
in
scripts
:
return
self
.
run_script
(
scripts
[
script
],
args
)
venv
=
self
.
venv
venv
=
self
.
venv
return
venv
.
execute
(
*
args
)
return
venv
.
execute
(
*
args
)
def
run_script
(
self
,
script
,
args
):
module
,
callable_
=
script
.
split
(
':'
)
src_in_sys_path
=
'sys.path.append(
\'
src
\'
); '
\
if
self
.
_module
.
is_in_src
()
else
''
cmd
=
[
'python'
,
'-c'
]
cmd
+=
[
'"import sys; '
'from importlib import import_module; '
'sys.argv = {!r}; {}'
'import_module(
\'
{}
\'
).{}()"'
.
format
(
args
,
src_in_sys_path
,
module
,
callable_
)
]
return
self
.
venv
.
run
(
*
cmd
,
shell
=
True
,
call
=
True
)
@property
def
_module
(
self
):
from
...masonry.utils.module
import
Module
poetry
=
self
.
poetry
package
=
poetry
.
package
path
=
poetry
.
file
.
parent
module
=
Module
(
package
.
name
,
path
.
as_posix
()
)
return
module
def
merge_application_definition
(
self
,
merge_args
=
True
):
def
merge_application_definition
(
self
,
merge_args
=
True
):
if
self
.
_application
is
None
\
if
self
.
_application
is
None
\
or
(
self
.
_application_definition_merged
or
(
self
.
_application_definition_merged
...
...
poetry/console/commands/script.py
View file @
06a2bd17
import
sys
from
...masonry.utils.module
import
Module
from
.venv_command
import
VenvCommand
from
.venv_command
import
VenvCommand
class
ScriptCommand
(
VenvCommand
):
class
ScriptCommand
(
VenvCommand
):
"""
"""
Executes a script defined in <comment>pyproject.toml</comment>
Executes a script defined in <comment>pyproject.toml</comment>
. (<error>Deprecated</error>)
script
script
{ script-name : The name of the script to execute }
{ script-name : The name of the script to execute }
...
@@ -14,6 +11,9 @@ class ScriptCommand(VenvCommand):
...
@@ -14,6 +11,9 @@ class ScriptCommand(VenvCommand):
"""
"""
def
handle
(
self
):
def
handle
(
self
):
self
.
line
(
'<warning>script is deprecated use run instead.</warning>'
)
self
.
line
(
''
)
script
=
self
.
argument
(
'script-name'
)
script
=
self
.
argument
(
'script-name'
)
argv
=
[
script
]
+
self
.
argument
(
'args'
)
argv
=
[
script
]
+
self
.
argument
(
'args'
)
...
@@ -44,6 +44,8 @@ class ScriptCommand(VenvCommand):
...
@@ -44,6 +44,8 @@ class ScriptCommand(VenvCommand):
@property
@property
def
_module
(
self
):
def
_module
(
self
):
from
...masonry.utils.module
import
Module
poetry
=
self
.
poetry
poetry
=
self
.
poetry
package
=
poetry
.
package
package
=
poetry
.
package
path
=
poetry
.
file
.
parent
path
=
poetry
.
file
.
parent
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment