Skip to content

Commit

Permalink
fix: Conda release #2227 (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Feb 6, 2024
1 parent 8cd6f84 commit ca27772
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
token: ${{ secrets.GIT_TOKEN }}

- name: Publish to Conda
uses: amauryval/publish_conda_package_action@2.0.3
uses: marek-mihok/publish_conda_package_action@v1.0.1
with:
CondaDir: 'py/h2o_wave/conda'
Platforms: 'noarch'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-wave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to Conda
uses: amauryval/publish_conda_package_action@2.0.3
uses: marek-mihok/publish_conda_package_action@v1.0.1
with:
CondaDir: 'py/h2o_wave/conda'
Platforms: 'noarch'
Expand Down
1 change: 1 addition & 0 deletions py/h2o_wave/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ build: purge
../venv/bin/python3 -m build --wheel

purge: ## Purge previous build
rm -f h2o_wave/metadata.py
rm -rf build dist h2o_wave.egg-info
19 changes: 12 additions & 7 deletions py/h2o_wave/hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
from hatchling.metadata.plugin.interface import MetadataHookInterface


# Creates a metadata file to get easy access to platform/OS arch when needed.
def create_metadata_file(platform: str, arch: str):
with open(os.path.join('h2o_wave', 'metadata.py'), 'w') as f:
f.write(f'''
# Generated in hatch_build.py.
__platform__ = "{platform}"
__arch__ = "{arch}"
''')

class CustomMetadataHook(MetadataHookInterface):
def update(self, metadata: dict) -> None:
metadata['version'] = os.environ.get('VERSION', metadata['version'])
Expand All @@ -15,6 +24,8 @@ class CustomBuildHook(BuildHookInterface):
def initialize(self, _version, build_data):
platform = os.environ.get('H2O_WAVE_PLATFORM')
if not platform:
# Create a default metadata file in case of noarch builds.
create_metadata_file('linux', 'amd64')
return

build_data['tag'] = f'py3-none-{platform}'
Expand All @@ -38,13 +49,7 @@ def initialize(self, _version, build_data):
self.copy_files(binaries_path, 'tmp', ['demo', 'examples', 'test'])
self.copy_files('project_templates', 'tmp', [], True)

# Create a metadata file to get easy access to platform/OS arch when needed.
with open(os.path.join('h2o_wave', 'metadata.py'), 'w') as f:
f.write(f'''
# Generated in hatch_build.py.
__platform__ = "{operating_system}"
__arch__ = "{arch}"
''')
create_metadata_file(operating_system, arch)

def copy_files(self, src, dst, ignore, keep_dir=False) -> None:
for file_name in os.listdir(src):
Expand Down

0 comments on commit ca27772

Please sign in to comment.