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
cdd7c77e
Commit
cdd7c77e
authored
Mar 28, 2020
by
Arun Babu Neelicattu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pip: remove orphaned nspkg.pth files manually
Relates-to: #2238
parent
a0904f95
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
0 deletions
+63
-0
poetry/installation/pip_installer.py
+5
-0
tests/fixtures/git/github.com/demo/namespace-package-one/namespace_package/__init__.py
+1
-0
tests/fixtures/git/github.com/demo/namespace-package-one/namespace_package/one/__init__.py
+1
-0
tests/fixtures/git/github.com/demo/namespace-package-one/setup.py
+15
-0
tests/installation/test_pip_installer.py
+41
-0
No files found.
poetry/installation/pip_installer.py
View file @
cdd7c77e
...
@@ -113,6 +113,11 @@ class PipInstaller(BaseInstaller):
...
@@ -113,6 +113,11 @@ class PipInstaller(BaseInstaller):
raise
raise
# This is a workaround for https://github.com/pypa/pip/issues/4176
nspkg_pth_file
=
self
.
_env
.
site_packages
/
"{}-nspkg.pth"
.
format
(
package
.
name
)
if
nspkg_pth_file
.
exists
():
nspkg_pth_file
.
unlink
()
# If we have a VCS package, remove its source directory
# If we have a VCS package, remove its source directory
if
package
.
source_type
==
"git"
:
if
package
.
source_type
==
"git"
:
src_dir
=
self
.
_env
.
path
/
"src"
/
package
.
name
src_dir
=
self
.
_env
.
path
/
"src"
/
package
.
name
...
...
tests/fixtures/git/github.com/demo/namespace-package-one/namespace_package/__init__.py
0 → 100644
View file @
cdd7c77e
__import__
(
"pkg_resources"
)
.
declare_namespace
(
__name__
)
tests/fixtures/git/github.com/demo/namespace-package-one/namespace_package/one/__init__.py
0 → 100644
View file @
cdd7c77e
name
=
"one"
tests/fixtures/git/github.com/demo/namespace-package-one/setup.py
0 → 100644
View file @
cdd7c77e
from
setuptools
import
setup
,
find_packages
setup
(
name
=
"namespace_package_one"
,
version
=
"1.0.0"
,
description
=
""
,
long_description
=
""
,
author
=
"Python Poetry"
,
author_email
=
"noreply@python-poetry.org"
,
license
=
"MIT"
,
packages
=
find_packages
(),
namespace_packages
=
[
"namespace_package"
],
zip_safe
=
False
,
)
tests/installation/test_pip_installer.py
View file @
cdd7c77e
import
shutil
import
pytest
import
pytest
from
poetry.installation.pip_installer
import
PipInstaller
from
poetry.installation.pip_installer
import
PipInstaller
...
@@ -152,3 +154,42 @@ def test_requirement_git_develop_true(installer, package_git):
...
@@ -152,3 +154,42 @@ def test_requirement_git_develop_true(installer, package_git):
expected
=
[
"-e"
,
"git+git@github.com:demo/demo.git@master#egg=demo"
]
expected
=
[
"-e"
,
"git+git@github.com:demo/demo.git@master#egg=demo"
]
assert
expected
==
result
assert
expected
==
result
def
test_uninstall_git_package_nspkg_pth_cleanup
(
mocker
,
tmp_venv
,
pool
):
# this test scenario requires a real installation using the pip installer
installer
=
PipInstaller
(
tmp_venv
,
NullIO
(),
pool
)
# use a namepspace package
package
=
Package
(
"namespace-package-one"
,
"1.0.0"
)
package
.
source_type
=
"git"
package
.
source_url
=
"https://github.com/demo/namespace-package-one.git"
package
.
source_reference
=
"master"
package
.
develop
=
True
# we do this here because the virtual env might not be usable if failure case is triggered
pth_file_candidate
=
tmp_venv
.
site_packages
/
"{}-nspkg.pth"
.
format
(
package
.
name
)
# in order to reproduce the scenario where the git source is removed prior to proper
# clean up of nspkg.pth file, we need to make sure the fixture is copied and not
# symlinked into the git src directory
def
copy_only
(
source
,
dest
):
if
dest
.
exists
():
dest
.
unlink
()
if
source
.
is_dir
():
shutil
.
copytree
(
str
(
source
),
str
(
dest
))
else
:
shutil
.
copyfile
(
str
(
source
),
str
(
dest
))
mocker
.
patch
(
"tests.helpers.copy_or_symlink"
,
new
=
copy_only
)
# install package and then remove it
installer
.
install
(
package
)
installer
.
remove
(
package
)
assert
not
Path
(
pth_file_candidate
)
.
exists
()
# any command in the virtual environment should trigger the error message
output
=
tmp_venv
.
run
(
"python"
,
"-m"
,
"site"
)
assert
"Error processing line 1 of {}"
.
format
(
pth_file_candidate
)
not
in
output
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