Skip to content

Commit 8bc5fc9

Browse files
committed
setting up pypi build
1 parent ab03c9b commit 8bc5fc9

File tree

6 files changed

+83
-12
lines changed

6 files changed

+83
-12
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ tests/.logs
88
tests/.tmp
99
bashdb-5.0-1.1.2
1010
changes.0.2.0.sh
11-
dist/npm/

build/build.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#! /bin/bash
22

3-
BUILD_TEMP=$(mktemp -d)
4-
DIST_DIR="./dist"
3+
mkdir -p .tmp
4+
BUILD_TEMP=$(mktemp -d -p .tmp)
55
VERSION=$(sed -n 's/^__VERSION="\([^"]*\)"/\1/p' ../giv/src/giv.sh)
6+
DIST_DIR="./dist/${VERSION}"
7+
68
printf "Building GIV CLI version %s...\n" "${VERSION}"
7-
# npm build section
8-
mkdir -p "${BUILD_TEMP}/npm"
9-
cp -r src templates "${BUILD_TEMP}/npm/"
10-
sed "s/{{VERSION}}/${VERSION}/g" build/npm/package.json.template > "${BUILD_TEMP}/npm/package.json"
11-
cp README.md "${BUILD_TEMP}/npm/" # Optional, but recommended
12-
# Copy BUILD_TEMP to DIST_DIR
13-
mkdir -p "${DIST_DIR}/npm"
14-
cp -r "${BUILD_TEMP}/npm"/* "${DIST_DIR}/npm/"
159

10+
./build/npm/build.sh "${VERSION}" "${BUILD_TEMP}"
11+
./build/pypi/build.sh "${VERSION}" "${BUILD_TEMP}"
1612

17-
printf "Build completed. Files are in %s\n" "${DIST_DIR}"
13+
rm -rf "${BUILD_TEMP}"
14+
printf "Build completed. Files are in %s\n" "${DIST_DIR}/pypi"

build/npm/build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! /bin/bash
2+
3+
VERSION="$1"
4+
NPM_DIST_DIR="./dist/${VERSION}"
5+
NPM_BUILD_TEMP="$2/npm/"
6+
7+
# npm build section
8+
mkdir -p "${NPM_BUILD_TEMP}"
9+
cp -r src templates "${NPM_BUILD_TEMP}/"
10+
sed "s/{{VERSION}}/${VERSION}/g" build/npm/package.json > "${NPM_BUILD_TEMP}/package.json"
11+
cp README.md "${NPM_BUILD_TEMP}/"
12+
13+
# Copy BUILD_TEMP to DIST_DIR
14+
mkdir -p "${NPM_DIST_DIR}"
15+
rm -rf "${NPM_DIST_DIR}/npm"
16+
mv -f "${NPM_BUILD_TEMP}" "${NPM_DIST_DIR}/"
17+
18+
printf "npm build completed. Files are in %s\n" "${NPM_DIST_DIR}/npm"

build/pypi/build.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
5+
VERSION="$1"
6+
PIP_DIST_DIR="./dist/${VERSION}"
7+
PIP_BUILD_TEMP="$2/pypi"
8+
9+
TEMP_SRC="${PIP_BUILD_TEMP}/src"
10+
TEMP_TEMPLATES="${PIP_BUILD_TEMP}/templates"
11+
12+
# Create temporary directories for source and templates
13+
mkdir -p "${TEMP_SRC}" "${TEMP_TEMPLATES}"
14+
15+
# Copy all .sh sources to src/ (rename giv.sh to giv)
16+
cp src/giv.sh "${TEMP_SRC}/giv"
17+
chmod +x "${TEMP_SRC}/giv"
18+
find src -type f -name '*.sh' ! -name 'giv.sh' -exec cp {} "${TEMP_SRC}/" \;
19+
20+
# Copy templates folder
21+
cp -r templates/* "${TEMP_TEMPLATES}/"
22+
23+
# Collect file lists for setup.py
24+
SH_FILES=$(find "${TEMP_SRC}" -type f -name '*.sh' -print0 | xargs -0 -I{} bash -c 'printf "src/%s " "$(basename "{}")"')
25+
TEMPLATE_FILES=$(find "${TEMP_TEMPLATES}" -type f -print0 | xargs -0 -I{} bash -c 'printf "templates/%s " "$(basename "{}")"')
26+
27+
# Fill in the setup.py template
28+
sed -e "s|{{VERSION}}|${VERSION}|g" \
29+
-e "s|{{SH_FILES}}|${SH_FILES}|g" \
30+
-e "s|{{TEMPLATE_FILES}}|${TEMPLATE_FILES}|g" \
31+
build/pypi/setup.py > "${PIP_BUILD_TEMP}/setup.py"
32+
33+
# Copy README if present
34+
[ -f README.md ] && cp README.md "${PIP_BUILD_TEMP}/"
35+
36+
# Create the output directory
37+
mkdir -p "${PIP_DIST_DIR}"
38+
# Copy built files to output directory
39+
rm -rf "${PIP_DIST_DIR}/pypi"
40+
mv -f "${PIP_BUILD_TEMP}" "${PIP_DIST_DIR}/"
41+
42+
43+
printf "PyPi build completed. Files are in %s\n" "${PIP_DIST_DIR}"

build/pypi/setup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name="giv",
5+
version="{{VERSION}}",
6+
description="Git history AI assistant CLI tool",
7+
author="itlackey",
8+
author_email="noreply@github.com",
9+
scripts=["src/giv"],
10+
data_files=[
11+
("src", ["{{SH_FILES}}"]),
12+
("templates", ["templates/{{TEMPLATE_FILES}}"]),
13+
],
14+
)

0 commit comments

Comments
 (0)