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

Fix Conan Build - Consistent Repo Hash IDs #52

Merged
merged 2 commits into from
Dec 20, 2023
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ To build the Conan2 package for binary distribution of `slm`:
2. Confirm: `conan profile show -pr default`
1. This will show the default configuration.
3. Run the conan build:
1. `conan create . -s os="Macos" -s arch="x86_64"`
2. You can replace os with `Windows` or `Linux`
3. No Promises on `Windows` build working yet.
1. Mac/Linux: `build_conan.sh`
2. Windows: `build_conan.ps1`
4. Publish the package:
1. `conan remote add <NAME> <URL>`
1. You should only have to do this once.
Expand Down
2 changes: 2 additions & 0 deletions build_conan.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$env:SLM_ROOT_DIR = Get-Location
conan create .
16 changes: 16 additions & 0 deletions build_conan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# Script to run the conan build and generate the required packages
#
# Current usage of Conan is kind of a hack. We're not having conan
# to run the `stanza build`. This means I have to get the binary
# to the package some how and Conan makes this more difficult than
# just copying it to a file. I don't get access to the `recipe_folder`
# after the `export_sources` function. But I can't copy the binary in
# `export_sources_folder` because anything in that directory gets hashed
# as part of the repository id.
#
# I must pass this directory as an environment variable
# so that each run of `conanfile.py` gets the same directory.
export SLM_ROOT_DIR=$(pwd)
conan create .
13 changes: 10 additions & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from conan.tools.files import copy
import tomllib

SLM_FOLDER = None

def get_slm_config(fp = "./slm.toml"):
with open(fp, "rb") as f:
data = tomllib.load(f)
Expand Down Expand Up @@ -73,11 +75,16 @@ def copy_dist_files(self, src_dir, dst_dir):
if len(success) != len(self.dist_files()):
raise RuntimeError("Export: Failed to Copy Distribution Files")

def export_sources(self):
self.copy_dist_files(self.recipe_folder, self.export_sources_folder)
# def export_sources(self):
# # Anything copied to the export sources folder will
# # get hashed to create the repository id. We want this
# # to be consistent from OS to OS.
# TODO - When we get the `stanza build` running through conan
# We would copy sources here and then run the build.

def build(self):
self.copy_dist_files(self.export_sources_folder, self.build_folder)
SLM_FOLDER = os.environ["SLM_ROOT_DIR"]
self.copy_dist_files(SLM_FOLDER, self.build_folder)

def package(self):
# Slight deviation here - I want the binary in the `bin`
Expand Down
2 changes: 1 addition & 1 deletion slm.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "slm"
version = "0.4.0"
version = "0.4.1"

[dependencies]
stanza-toml = { git = "StanzaOrg/stanza-toml", version = "0.3.4" }
Expand Down
Loading