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

feat: Include waved binary in Conda distributions #2266 #2303

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 32 additions & 7 deletions .github/workflows/publish-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
required: true

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: "${{ github.event.inputs.version }}"

jobs:
Expand All @@ -20,13 +19,39 @@ jobs:
with:
token: ${{ secrets.GIT_TOKEN }}

- name: Publish to Conda
uses: marek-mihok/[email protected]
- uses: actions/setup-go@v1
with:
CondaDir: 'py/h2o_wave/conda'
Platforms: 'noarch'
CondaUsername: ${{ secrets.CONDA_USERNAME }}
CondaPassword: ${{ secrets.CONDA_PASSWORD }}
go-version: '1.19.4'

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Setup
run: make setup

- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
working-directory: ./r

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
activate-environment: ""
conda-build-version: '24.3.0'

- name: Build Release
run: make release
env:
# VERSION clashes with conda build. Use PKG_VERSION instead.
PKG_VERSION: ${{ env.VERSION }}
NODE_OPTIONS: '--max-old-space-size=8192'

- name: Publish to Conda
uses: marek-mihok/[email protected]
mturoci marked this conversation as resolved.
Show resolved Hide resolved
with:
PackagesDir: 'py/h2o_wave/sdist'
CondaUsername: ${{ secrets.CONDA_USERNAME }}
CondaPassword: ${{ secrets.CONDA_PASSWORD }}
17 changes: 11 additions & 6 deletions .github/workflows/release-wave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ jobs:
with:
working-directory: ./r

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
activate-environment: ""
conda-build-version: '24.3.0'

- name: Build Release
run: make release
env:
# VERSION clashes with conda build. Use PKG_VERSION instead.
PKG_VERSION: ${{ env.VERSION }}
NODE_OPTIONS: '--max-old-space-size=8192'

- name: Unit Test
Expand Down Expand Up @@ -79,15 +88,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to Conda
uses: marek-mihok/publish_conda_package_action@v1.0.1
uses: marek-mihok/upload_to_anaconda_cloud_action@v1.0.0
with:
CondaDir: 'py/h2o_wave/conda'
Platforms: 'noarch'
PackagesDir: 'py/h2o_wave/sdist'
CondaUsername: ${{ secrets.CONDA_USERNAME }}
CondaPassword: ${{ secrets.CONDA_PASSWORD }}
env:
# VERSION clashes with conda build. Use PKG_VERSION instead.
PKG_VERSION: ${{ env.VERSION }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
Expand Down
24 changes: 22 additions & 2 deletions py/h2o_wave/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
build_conda_package = \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to create 2 separate make targets (conda-noarch and conda-arch) instead? And maybe a 3rd one for moving stuff around (the last section of the function)

if [ "$(1)" != "noarch" ]; then \
mkdir -p conda/temp; \
cp -a ../../build/wave-$(VERSION)-$(1)/. conda/temp; \
NO_ARCH=0 conda build --output-folder temp_build/ conda; \
find temp_build/ -name *.tar.bz2 | while read -r file; do \
conda convert --force --platform $(2) "$$file" -o temp_build/; \
done \
fi && \
if [ "$(1)" == "noarch" ]; then \
NO_ARCH=1 conda build --output-folder temp_build/ conda; \
fi && \
mkdir -p sdist/$(2) && \
mv temp_build/$(2)/*.tar.bz2 sdist/$(2) && \
rm -rf temp_build conda/temp

.PHONY: build
build: purge
H2O_WAVE_PLATFORM=win_amd64 ../venv/bin/python3 -m build --wheel
Expand All @@ -6,7 +22,11 @@ build: purge
H2O_WAVE_PLATFORM=macosx_11_0_arm64 ../venv/bin/python3 -m build --wheel
H2O_WAVE_PLATFORM=macosx_12_0_arm64 ../venv/bin/python3 -m build --wheel
../venv/bin/python3 -m build --wheel
$(call build_conda_package,darwin-arm64,osx-arm64)
$(call build_conda_package,darwin-amd64,osx-64)
$(call build_conda_package,linux-amd64,linux-64)
$(call build_conda_package,windows-amd64,win-64)
$(call build_conda_package,noarch,noarch)

purge: ## Purge previous build
rm -f h2o_wave/metadata.py
rm -rf build dist h2o_wave.egg-info
rm -rf build dist sdist h2o_wave.egg-info temp_build conda/temp h2o_wave/metadata.py
8 changes: 8 additions & 0 deletions py/h2o_wave/conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TODO: Build a single package for all python versions once this is resolved: https://github.com/conda/conda-build/issues/2611#issuecomment-1239338538
python_version:
- 3.8
- 3.9
- 3.10
- 3.11
- 3.12

17 changes: 15 additions & 2 deletions py/h2o_wave/conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,33 @@ about:

requirements:
build:
{% if NO_ARCH == "0" %}
- python={{ python_version }}
{% endif %}
{% for dep in pyproject['build-system']['requires'] %}
- {{ dep.lower() }}
{% endfor %}
run:
{% if NO_ARCH == "0" %}
- python={{ python_version }}
{% endif %}
{% for dep in project['dependencies'] %}
- {{ dep.lower() }}
{% endfor %}
source:
path: ..

build:
noarch: python
script: python -m pip install . -vv
string: py{{ python_version | replace(".", "") }}
entry_points:
{% for module, entrypoints in project['scripts'].items() %}
- {{ module }} = {{ entrypoints }}
{% endfor %}
{% endfor %}
include_recipe: False
script_env:
- NO_ARCH
{% if NO_ARCH == "1" %}
noarch: python
mturoci marked this conversation as resolved.
Show resolved Hide resolved
string: "0"
{% endif %}
19 changes: 13 additions & 6 deletions py/h2o_wave/hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def initialize(self, _version, build_data):
if not platform:
# Create a default metadata file in case of noarch builds.
create_metadata_file('linux', 'amd64')
# If conda build, copy binaries into package.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I though conda has its own build pipeline and doesn't use hatch. How does this work?

binaries_path = os.path.join('conda', 'temp')
if os.environ.get('CONDA_BUILD') and os.path.exists(binaries_path):
self.copy_binaries_into_package(binaries_path)
return

build_data['tag'] = f'py3-none-{platform}'
Expand All @@ -42,12 +46,7 @@ def initialize(self, _version, build_data):
elif platform == 'manylinux1_x86_64':
operating_system = 'linux'

binaries_path = os.path.join('..', '..', 'build', f'wave-{version}-{operating_system}-{arch}')
if not os.path.exists(binaries_path):
raise Exception(f'{binaries_path} does not exist. Run make release first to generate server binaries.')

self.copy_files(binaries_path, 'tmp', ['demo', 'examples', 'test'])
self.copy_files('project_templates', 'tmp', [], True)
self.copy_binaries_into_package(os.path.join('..', '..', 'build', f'wave-{version}-{operating_system}-{arch}'))

create_metadata_file(operating_system, arch)

Expand All @@ -61,5 +60,13 @@ def copy_files(self, src, dst, ignore, keep_dir=False) -> None:
elif os.path.isdir(src_file) and file_name not in ignore:
self.copy_files(src_file, dst_file, ignore)

def copy_binaries_into_package(self, binaries_path):
if not os.path.exists(binaries_path):
raise Exception(f'{binaries_path} does not exist. Run make release first to generate server binaries.')

self.copy_files(binaries_path, 'tmp', ['demo', 'examples', 'test'])
self.copy_files('project_templates', 'tmp', [], True)

def finalize(self, version: str, build_data: Dict[str, Any], artifact_path: str) -> None:
shutil.rmtree('tmp', ignore_errors=True)

6 changes: 0 additions & 6 deletions website/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ pip install h2o-wave
conda config --append channels conda-forge
conda install -c h2oai h2o-wave
```
:::info
Conda packaging does not contain Wave server which means, you will still need to run the wave server (waved) [separately](/docs/tutorial-hello#step-1-start-the-wave-server).
:::

</TabItem>

Expand Down Expand Up @@ -64,9 +61,6 @@ conda config --append channels conda-forge
conda install -c h2oai h2o-wave
```

:::info
Conda packaging does not contain Wave server which means, you will still need to run the wave server (waved) [separately](/docs/tutorial-hello#step-1-start-the-wave-server).
:::

</TabItem>
</Tabs>
Expand Down