Skip to content

Commit

Permalink
Add pre- and post-build script to work around Poetry bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeSneyders committed Feb 20, 2024
1 parent f7c7e10 commit dd7c464
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/prep-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
- name: Build a binary wheel and a source tarball
run: |
pip install poetry
./scripts/pre-build.sh
poetry build
- name: Publish distribution 📦 to Test PyPI
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ maintainers = [
"Niels Rogge <[email protected]>",
]
repository = "https://github.com/ml6team/fondant"
include = ["*.txt", "*.rst", "*.md", "src/fondant/components/**/*.yaml"]
exclude = ["src/fondant/components"] # Exclude everything except for component specs
include = ["*.txt", "*.rst", "*.md", "fondant/components/**/*.yaml"]
exclude = ["fondant/components"] # Exclude everything except for component specs
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
Expand Down
14 changes: 14 additions & 0 deletions scripts/post-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# This script reverts the `scripts/pre-build.sh` script by moving the package code back into a
# `src` directory.
# It should be run after running scripts/pre-build.sh and building the fondant package
set -e

scripts_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
root_path=$(dirname "$scripts_path")

pushd "$root_path"
mkdir -p src/fondant
mv fondant/* src/fondant
rm -rf fondant
popd
17 changes: 17 additions & 0 deletions scripts/pre-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# This script unpacks the src folder before building to make the poetry `include` and `exclude`
# sections work correctly for both sdist and wheel
# (https://github.com/python-poetry/poetry/issues/8994)
# Building without running this script also works, but includes the full code for the components.
# This script makes changes to the local files, which should not be committed to git. Run
# scripts/post-build.sh to clean them up.
set -e

scripts_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
root_path=$(dirname "$scripts_path")

pushd "$root_path"
mkdir fondant
mv src/fondant/* fondant
rm -rf src
popd
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ allowlist_externals=
/bin/bash
/usr/bin/bash
commands_pre=
bash ./scripts/pre-build.sh
poetry lock
poetry install --all-extras
poetry show
commands=
poetry run python -m pytest tests -vv --cov fondant --cov-report term-missing --ignore=tests/integration_tests
commands_post=
bash ./scripts/post-build.sh

0 comments on commit dd7c464

Please sign in to comment.