Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
77609652
Commit
77609652
authored
Jun 27, 2018
by
Alexander Duryagin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
always process module.__path__ for namespace packages, fixes #1321
parent
5c816483
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
5 deletions
+37
-5
pkg_resources/__init__.py
pkg_resources/__init__.py
+6
-5
setuptools/tests/test_namespaces.py
setuptools/tests/test_namespaces.py
+31
-0
No files found.
pkg_resources/__init__.py
View file @
77609652
...
...
@@ -2135,12 +2135,13 @@ def _rebuild_mod_path(orig_path, package_name, module):
parts = path_parts[:-module_parts]
return safe_sys_path_index(_normalize_cached(os.sep.join(parts)))
if not isinstance(orig_path, list):
# Is this behavior useful when module.__path__ is not a list?
return
new_path = sorted(orig_path, key=position_in_sys_path)
new_path = [_normalize_cached(p) for p in new_path]
orig_path.sort(key=position_in_sys_path)
module.__path__[:] = [_normalize_cached(p) for p in orig_path]
if isinstance(module.__path__, list):
module.__path__[:] = new_path
else:
module.__path__ = new_path
def declare_namespace(packageName):
...
...
setuptools/tests/test_namespaces.py
View file @
77609652
...
...
@@ -109,3 +109,34 @@ class TestNamespaces:
]
with
test
.
test
.
paths_on_pythonpath
([
str
(
target
)]):
subprocess
.
check_call
(
pkg_resources_imp
,
cwd
=
str
(
pkg_A
))
@
pytest
.
mark
.
skipif
(
bool
(
os
.
environ
.
get
(
"APPVEYOR"
)),
reason
=
"https://github.com/pypa/setuptools/issues/851"
)
def
test_packages_in_the_sampe_namespace_installed_and_cwd
(
self
,
tmpdir
):
"""
Installing one namespace package and also have another in the same
namespace in the current working directory, both of them must be
importable.
"""
pkg_A
=
namespaces
.
build_namespace_package
(
tmpdir
,
'myns.pkgA'
)
pkg_B
=
namespaces
.
build_namespace_package
(
tmpdir
,
'myns.pkgB'
)
target
=
tmpdir
/
'packages'
# use pip to install to the target directory
install_cmd
=
[
sys
.
executable
,
'-m'
,
'pip.__main__'
,
'install'
,
str
(
pkg_A
),
'-t'
,
str
(
target
),
]
subprocess
.
check_call
(
install_cmd
)
namespaces
.
make_site_dir
(
target
)
# ensure that all packages import and pkg_resources imports
pkg_resources_imp
=
[
sys
.
executable
,
'-c'
,
'import pkg_resources; import myns.pkgA; import myns.pkgB'
,
]
with
test
.
test
.
paths_on_pythonpath
([
str
(
target
)]):
subprocess
.
check_call
(
pkg_resources_imp
,
cwd
=
str
(
pkg_B
))
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