Skip to content

Commit d226664

Browse files
authored
Merge pull request #313 from open-craft/agrendalath/fix_requirements_regexp
fix: include static files in Python package
2 parents e6efffc + a70b9e0 commit d226664

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

drag_and_drop_v2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
""" Drag and Drop v2 XBlock """
22
from .drag_and_drop_v2 import DragAndDropBlock
33

4-
__version__ = "3.1.1"
4+
__version__ = "3.1.2"

setup.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def load_requirements(*requirements_paths):
2020
constraint_files = set()
2121

2222
# groups "pkg<=x.y.z,..." into ("pkg", "<=x.y.z,...")
23-
requirement_line_regex = re.compile(r"([a-zA-Z0-9-_.]+)([<>=][^#\s]+)?")
23+
requirement_line_regex = re.compile(r"([a-zA-Z0-9-_.\[\]]+)([<>=][^#\s]+)?")
2424

2525
def add_version_constraint_or_raise(current_line, current_requirements, add_if_not_present):
2626
regex_match = requirement_line_regex.match(current_line)
@@ -87,6 +87,17 @@ def get_version(*file_paths):
8787
raise RuntimeError('Unable to find version string.')
8888

8989

90+
def package_data(pkg, root_list):
91+
"""Generic function to find package_data for `pkg` under `root`."""
92+
data = []
93+
for root in root_list:
94+
for dirname, _, files in os.walk(os.path.join(pkg, root)):
95+
for fname in files:
96+
data.append(os.path.relpath(os.path.join(dirname, fname), pkg))
97+
98+
return {pkg: data}
99+
100+
90101
VERSION = get_version('drag_and_drop_v2', '__init__.py')
91102

92103
if sys.argv[-1] == 'tag':
@@ -108,10 +119,7 @@ def get_version(*file_paths):
108119
entry_points={
109120
'xblock.v1': 'drag-and-drop-v2 = drag_and_drop_v2:DragAndDropBlock',
110121
},
111-
include_package_data=True,
112-
packages=find_packages(
113-
include=['drag_and_drop_v2', 'drag_and_drop_v2.*'],
114-
exclude=["*tests"],
115-
),
122+
packages=['drag_and_drop_v2'],
123+
package_data=package_data("drag_and_drop_v2", ["static", "templates", "public", "translations", "locale"]),
116124
python_requires=">=3.8",
117125
)

0 commit comments

Comments
 (0)