Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre- and post-build script to work around Poetry bug #868

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 5 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 Expand Up @@ -75,6 +75,9 @@ vertex = ["docker", "kfp", "google-cloud-aiplatform"]
sagemaker = ["sagemaker", "boto3"]
docker = ["docker"]

all = ["dask", "dask-cuda", "s3fs", "adlfs", "gcsfs", "docker", "kfp", "google-cloud-aiplatform",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess this is useful for local development in case you want to install all dependencies. Should we adjust the readme?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For local development, this can still be done with poetry install --all-extras. I just needed this to install all extras when installing from the wheel, which I think is only needed in our CI/CD.

"sagemaker", "boto3"]

[tool.poetry.group.test]
optional = true

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
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ allowlist_externals=
/bin/bash
/usr/bin/bash
commands_pre=
poetry lock
poetry install --all-extras
poetry show
bash ./scripts/pre-build.sh
poetry build
poetry run pip install dist/fondant-0.1.dev0-py3-none-any.whl[all]
poetry run pip list
bash ./scripts/post-build.sh
commands=
poetry run python -m pytest tests -vv --cov fondant --cov-report term-missing --ignore=tests/integration_tests
Loading