Skip to content

Commit 6949cf9

Browse files
committed
Fixed
1 parent c30d8bd commit 6949cf9

1 file changed

Lines changed: 23 additions & 77 deletions

File tree

.github/workflows/generate-vicutils-docs.yml

Lines changed: 23 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -62,84 +62,30 @@ jobs:
6262
if [ -f requirements.txt ]; then
6363
echo "Updating install_requires in setup.py from requirements.txt"
6464
65-
# Read requirements and format as Python list
66-
reqs=$(grep -v '^#' requirements.txt | grep -v '^
67-
68-
- name: Generate __init__.py files automatically
69-
run: |
70-
echo "Generating __init__.py files..."
71-
find vicutils -type d | while read dir; do
72-
init_file="$dir/__init__.py"
73-
if [ ! -f "$init_file" ]; then
74-
touch "$init_file"
75-
fi
76-
echo "" > "$init_file"
77-
for py in "$dir"/*.py; do
78-
[ -f "$py" ] || continue
79-
base=$(basename "$py" .py)
80-
if [ "$base" != "__init__" ]; then
81-
echo "from .${base} import *" >> "$init_file"
82-
fi
83-
done
84-
done
85-
86-
- name: Check vicutils directory
87-
run: |
88-
echo "=== Contents of vicutils directory ==="
89-
ls -la vicutils/
90-
echo "=== Python files found ==="
91-
find vicutils/ -name "*.py" -not -name "__init__.py"
92-
93-
- name: Generate documentation
94-
run: |
95-
echo "=== Generating documentation ==="
96-
find vicutils/ -mindepth 2 -name "*.py" -not -name "__init__.py" | while read file; do
97-
dir=$(dirname "$file")
98-
basename=$(basename "$file" .py)
99-
cd "$dir"
100-
python -m pdoc --html --force --output-dir . "$basename"
101-
if [ -d "$basename" ]; then
102-
mv "$basename"/index.html "$basename.html"
103-
rm -rf "$basename"
104-
fi
105-
cd - > /dev/null
106-
done
107-
echo "=== Final vicutils contents ==="
108-
find vicutils/ -type f
109-
110-
- name: Build package
111-
run: |
112-
echo "=== Building package ==="
113-
python -m build
114-
echo "=== Build artifacts ==="
115-
ls -la dist/
116-
117-
- name: Publish to PyPI
118-
env:
119-
TWINE_USERNAME: __token__
120-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
121-
run: |
122-
python -m twine upload dist/* --skip-existing
123-
124-
- name: Commit and push if changes
125-
run: |
126-
git config --local user.name "Vic-Nas"
127-
git config --local user.email "github-actions@github.com"
128-
git add .version setup.py
129-
git add vicutils/**/*.html || echo "No HTML files to add"
130-
git add vicutils/**/*.py || echo "No Python files to add"
131-
132-
if git diff --staged --quiet; then
133-
echo "No changes to commit"
134-
else
135-
git commit -m "Auto-generate docs and bump version $NEW_VERSION"
136-
git push
137-
fi | sed 's/.*/"&"/' | paste -sd ',' -)
138-
139-
# Update install_requires in setup.py
140-
sed -i "s/install_requires=\[.*\]/install_requires=[$reqs]/" setup.py
65+
python3 << 'EOF'
66+
import re
67+
68+
# Read requirements
69+
with open('requirements.txt', 'r') as f:
70+
reqs = [line.strip() for line in f if line.strip() and not line.startswith('#')]
71+
72+
# Format as Python list string
73+
reqs_str = '[' + ', '.join(f'"{req}"' for req in reqs) + ']'
74+
75+
# Read setup.py
76+
with open('setup.py', 'r') as f:
77+
content = f.read()
78+
79+
# Replace install_requires
80+
content = re.sub(r'install_requires=\[.*?\]', f'install_requires={reqs_str}', content, flags=re.DOTALL)
81+
82+
# Write back
83+
with open('setup.py', 'w') as f:
84+
f.write(content)
85+
86+
print(f"Updated install_requires: {reqs_str}")
87+
EOF
14188
142-
echo "Updated install_requires: [$reqs]"
14389
else
14490
echo "No requirements.txt found, skipping setup.py update"
14591
fi

0 commit comments

Comments
 (0)