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
ebadf8a1
Unverified
Commit
ebadf8a1
authored
May 21, 2023
by
David Hotham
Committed by
GitHub
May 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preserve relative-path at `poetry run` (#7963)
parent
c5d2c6bd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
src/poetry/utils/env.py
+10
-10
tests/utils/test_env.py
+7
-0
No files found.
src/poetry/utils/env.py
View file @
ebadf8a1
...
...
@@ -1243,7 +1243,7 @@ class Env:
"""
Path to current python executable
"""
return
self
.
_bin
(
self
.
_executable
)
return
Path
(
self
.
_bin
(
self
.
_executable
)
)
@property
def
marker_env
(
self
)
->
dict
[
str
,
Any
]:
...
...
@@ -1311,7 +1311,7 @@ class Env:
"""
# we do not use as_posix() here due to issues with windows pathlib2
# implementation
path
=
self
.
_bin
(
self
.
_pip_executable
)
path
=
Path
(
self
.
_bin
(
self
.
_pip_executable
)
)
if
not
path
.
exists
():
return
self
.
pip_embedded
return
path
...
...
@@ -1431,7 +1431,7 @@ class Env:
raise
NotImplementedError
()
def
get_pip_command
(
self
,
embedded
:
bool
=
False
)
->
list
[
str
]:
if
embedded
or
not
self
.
_bin
(
self
.
_pip_executable
)
.
exists
():
if
embedded
or
not
Path
(
self
.
_bin
(
self
.
_pip_executable
)
)
.
exists
():
return
[
str
(
self
.
python
),
str
(
self
.
pip_embedded
)]
# run as module so that pip can update itself on Windows
return
[
str
(
self
.
python
),
"-m"
,
"pip"
]
...
...
@@ -1461,7 +1461,7 @@ class Env:
# embedded pip when pip is not available in the environment
return
self
.
get_pip_command
()
return
[
s
tr
(
self
.
_bin
(
bin
)
)]
return
[
s
elf
.
_bin
(
bin
)]
def
run
(
self
,
bin
:
str
,
*
args
:
str
,
**
kwargs
:
Any
)
->
str
:
cmd
=
self
.
get_command_from_bin
(
bin
)
+
list
(
args
)
...
...
@@ -1541,7 +1541,7 @@ class Env:
self
.
_script_dirs
.
append
(
self
.
userbase
/
self
.
_script_dirs
[
0
]
.
name
)
return
self
.
_script_dirs
def
_bin
(
self
,
bin
:
str
)
->
Path
:
def
_bin
(
self
,
bin
:
str
)
->
str
:
"""
Return path to the given executable.
"""
...
...
@@ -1562,11 +1562,11 @@ class Env:
bin_path
=
self
.
_path
/
bin
if
bin_path
.
exists
():
return
bin_path
return
str
(
bin_path
)
return
Path
(
bin
)
return
bin
return
bin_path
return
str
(
bin_path
)
def
__eq__
(
self
,
other
:
object
)
->
bool
:
if
not
isinstance
(
other
,
Env
):
...
...
@@ -1880,8 +1880,8 @@ class NullEnv(SystemEnv):
return
super
()
.
execute
(
bin
,
*
args
,
**
kwargs
)
return
0
def
_bin
(
self
,
bin
:
str
)
->
Path
:
return
Path
(
bin
)
def
_bin
(
self
,
bin
:
str
)
->
str
:
return
bin
@contextmanager
...
...
tests/utils/test_env.py
View file @
ebadf8a1
...
...
@@ -1827,3 +1827,10 @@ def test_detect_active_python_with_bat(poetry: Poetry, tmp_path: Path) -> None:
active_python
=
EnvManager
(
poetry
)
.
_detect_active_python
()
assert
active_python
==
wrapped_python
def
test_command_from_bin_preserves_relative_path
(
manager
:
EnvManager
)
->
None
:
# https://github.com/python-poetry/poetry/issues/7959
env
=
manager
.
get
()
command
=
env
.
get_command_from_bin
(
"./foo.py"
)
assert
command
==
[
"./foo.py"
]
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