Skip to content

Commit

Permalink
Support __init__.py in packaging [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed Aug 30, 2018
1 parent 930047d commit ec4622f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion azure-sdk-tools/packaging_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,23 @@ def build_packaging(package_name: str, output_folder: str, build_conf: bool = Fa
template = env.get_template(template_name)
result = template.render(**conf)

with open(Path(output_folder) / package_name / template_name, "w") as fd:
# __init__.py is a weird one
if template_name == "__init__.py":
split_package_name = package_name.split("-")
for i in range(len(split_package_name)):
init_path = Path(output_folder).joinpath(
package_name,
*split_package_name[:i+1],
template_name
)
if init_path.exists():
break
with open(init_path, "w") as fd:
fd.write(result)

continue

with open(future_filepath, "w") as fd:
fd.write(result)

_LOGGER.info("Template done %s", package_name)
1 change: 1 addition & 0 deletions azure-sdk-tools/packaging_tools/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

0 comments on commit ec4622f

Please sign in to comment.