summaryrefslogtreecommitdiff
path: root/scripts/build/build_sdist.sh
blob: 42c46db597f279e51cf5f38cdecc0dd87bd943c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

set -euo pipefail
set -x

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
prjdir="$( cd "${dir}/../.." && pwd )"

# Find psycopg version
version=$(grep -e ^PSYCOPG_VERSION setup.py | sed "s/.*'\(.*\)'/\1/")
# A gratuitous comment to fix broken vim syntax file: '")
distdir="${prjdir}/dist"

# Replace the package name
if [[ "${PACKAGE_NAME:-}" ]]; then
    sed -i "s/^setup(name=\"psycopg2\"/setup(name=\"${PACKAGE_NAME}\"/" \
        "${prjdir}/setup.py"
fi

# Build the source package
python setup.py sdist -d "$distdir"

# install and test
pip install "${distdir}"/*.tar.gz

python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')"