Skip to content

Commit

Permalink
Problem: c extension uses namespace without directories
Browse files Browse the repository at this point in the history
Solution: check for existence of namespace directories
  • Loading branch information
gotcha committed Nov 29, 2021
1 parent b2ee66d commit 2bf8ee0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/589.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix when c extension implements namespace packages without the corresponding directories.
14 changes: 9 additions & 5 deletions src/zc/buildout/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,11 +1728,15 @@ def make_egg_after_pip_install(dest, distinfo_dir):
]

for namespace_package in namespace_packages:
init_py_file = os.path.join(dest, namespace_package, '__init__.py')
with open(init_py_file, 'w') as f:
f.write(
"__import__('pkg_resources').declare_namespace(__name__)"
)
namespace_package_dir = os.path.join(dest, namespace_package)
if os.path.isdir(namespace_package_dir):
init_py_file = os.path.join(
namespace_package_dir, '__init__.py')
with open(init_py_file, 'w') as f:
f.write(
"__import__('pkg_resources')."
"declare_namespace(__name__)"
)

# Remove `bin` directory if needed
# as there is no way to avoid script installation
Expand Down

0 comments on commit 2bf8ee0

Please sign in to comment.