Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package_dir option to setup.py #521

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/python/pybuilder/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def __init__(self, basedir, version="1.0.dev0", name=None):
self._requires_python = ""
self._obsoletes = []
self._explicit_namespaces = []
self._package_dir = {}
self._properties = {"verbose": False}
self._install_dependencies = set()
self._build_dependencies = set()
Expand Down Expand Up @@ -374,6 +375,14 @@ def explicit_namespaces(self):
def explicit_namespaces(self, value):
self._explicit_namespaces = as_list(value)

@property
def package_dir(self):
return self._package_dir

@package_dir.setter
def package_dir(self, value):
self._package_dir = dict(value)

@property
def dist_version(self):
return self._dist_version
Expand Down
8 changes: 8 additions & 0 deletions src/main/python/pybuilder/plugins/python/distutils_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def run(self):
url = $url,
scripts = $scripts,
packages = $packages,
package_dir = $package_dir,
namespace_packages = $namespace_packages,
py_modules = $modules,
classifiers = $classifiers,
Expand Down Expand Up @@ -175,6 +176,7 @@ def render_setup_script(project):
"url": as_str(default(project.url)),
"scripts": build_scripts_string(project),
"packages": build_packages_string(project),
"package_dir": build_package_dir_string(project),
"namespace_packages": build_namespace_packages_string(project),
"modules": build_modules_string(project),
"classifiers": build_classifiers_string(project),
Expand Down Expand Up @@ -493,6 +495,10 @@ def build_namespace_packages_string(project):
return build_string_from_array([pkg for pkg in project.explicit_namespaces])


def build_package_dir_string(project):
return build_string_from_dict(project.package_dir)


def build_packages_string(project):
return build_string_from_array([pkg for pkg in project.list_packages()])

Expand Down Expand Up @@ -577,6 +583,8 @@ def build_string_from_array(arr, indent=12):


def build_string_from_dict(d, indent=12):
if not d:
return "{}"
element_separator = ",\n"
element_separator += " " * indent
map_elements = []
Expand Down
1 change: 1 addition & 0 deletions src/main/python/pybuilder/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def apply_project_attributes(self):
self.propagate_property("license")
self.propagate_property("url")
self.propagate_property("explicit_namespaces")
self.propagate_property("package_dir")
self.propagate_property("requires_python")
self.propagate_property("obsoletes")

Expand Down
2 changes: 2 additions & 0 deletions src/unittest/python/plugins/python/distutils_plugin_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def run(self):
'spam',
'eggs'
],
package_dir = {},
namespace_packages = [
'foo.bar',
'quick.brown.fox'
Expand Down Expand Up @@ -491,6 +492,7 @@ def run(self):
'spam',
'eggs'
],
package_dir = {},
namespace_packages = [
'foo.bar',
'quick.brown.fox'
Expand Down