Skip to content

Commit c36a45b

Browse files
committed
Merge branch 'poetry-packaging'
2 parents ad27c84 + 9e80907 commit c36a45b

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

poetry-build.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")"
6+
7+
STATUS=$(git status --porcelain)
8+
9+
if [ -n "$STATUS" ]; then
10+
echo "===================================================================="
11+
echo "=============== ERROR: repository unclean, stopping! ==============="
12+
echo "===================================================================="
13+
echo
14+
git status
15+
echo
16+
echo "===================================================================="
17+
echo "=============== ERROR: repository unclean, stopping! ==============="
18+
echo "===================================================================="
19+
exit 1
20+
fi
21+
22+
### clean up old poetry artifacts:
23+
rm -rf dist/
24+
### clean up potential leftovers from previous runs of this script:
25+
rm -rf sjlogging/
26+
27+
# move the source tree to the project root, so poetry will pick it up
28+
# automatically from there (without explicit configuration):
29+
mv src/main/resources/sjlogging .
30+
31+
### parse the version from 'pom.xml':
32+
PACKAGE_VERSION=$(xmlstarlet sel --template -m _:project -v _:version pom.xml)
33+
34+
### make sure to have a valid Python package version:
35+
case $PACKAGE_VERSION in
36+
*-SNAPSHOT*)
37+
echo "POM version [$PACKAGE_VERSION] is a snapshot!"
38+
PACKAGE_VERSION=${PACKAGE_VERSION/-SNAPSHOT/}
39+
### calculate the distance to the last release tag:
40+
LAST_TAG=$(git tag --list 'jython-scijava-logging-*' | sort | tail -n1)
41+
# echo "Last git tag: '$LAST_TAG'"
42+
COMMITS_SINCE=$(git rev-list "${LAST_TAG}..HEAD" | wc -l)
43+
# echo "Nr of commits since last tag: $COMMITS_SINCE"
44+
HEAD_ID=$(git rev-parse --short HEAD)
45+
# echo "HEAD commit hash: $HEAD_ID"
46+
PACKAGE_VERSION="${PACKAGE_VERSION}.dev${COMMITS_SINCE}+${HEAD_ID}"
47+
;;
48+
esac
49+
50+
echo "Using package version: [$PACKAGE_VERSION]"
51+
52+
### put the version into the project file and the package source:
53+
sed -i "s/\${project.version}/${PACKAGE_VERSION}/" pyproject.toml
54+
sed -i "s/\${project.version}/${PACKAGE_VERSION}/" sjlogging/__init__.py
55+
56+
### let poetry build wheel and tar.gz:
57+
poetry build -vv
58+
59+
### clean up the moved source tree and restore the previous state:
60+
rm -rf sjlogging/
61+
git restore pyproject.toml
62+
git restore src/main/resources/sjlogging/

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ authors = ["Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>"]
66
description = "Jython package for using SciJava's LogService for logging."
77
name = "sjlogging"
88
readme = "README.md"
9-
version = "0.5.2"
9+
version = '${project.version}'
1010

1111
[tool.poetry.dependencies]
12-
python = "^3.10"
12+
python = ">=2.7"
1313

1414
[build-system]
1515
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)