nextstrain / conda-base

Conda package build for nextstrain-base
https://anaconda.org/Nextstrain/nextstrain-base
1 stars 1 forks source link

Add coreutils to dev packages for macOS compatibility #15

Closed corneliusroemer closed 1 year ago

corneliusroemer commented 1 year ago

macOS uses BSD date and other utilities in place of GNU versions This can cause issues, like #9, where BSD date does not accept --utc but only -u

Adding (GNU) coreutils to the development environment prevents these errors in the future and also resolves #9 resolves #11

Supersedes #12

tsibley commented 1 year ago

@corneliusroemer wrote in https://github.com/nextstrain/conda-base/pull/12#issuecomment-1340232986:

I'm not sure how the whole PATH situation works though - it's a bit opaque to me where you decided which date to run.

PATH is set to prioritize things in the managed development environment (e.g. the thing created by ./devel/setup) in each ./devel/… program that needs access to the environment. For example, in ./devel/build:

https://github.com/nextstrain/conda-base/blob/4a5ac81ca7fe2c7bf0339180ae761e2629ff0e1b/devel/build#L5-L10

$env comes from sourcing ./devel/_common:

https://github.com/nextstrain/conda-base/blob/4a5ac81ca7fe2c7bf0339180ae761e2629ff0e1b/devel/_common#L1-L2

In order for this PR to actually work on macOS, I do think we need to flip the order of setting PATH and VERSION in ./devel/build:

diff --git a/devel/build b/devel/build
index a434e82..75a0c43 100755
--- a/devel/build
+++ b/devel/build
@@ -6,8 +6,8 @@ source "$(dirname "$0")/_common"
 cd "$repo"

 main() {
-    export VERSION="${VERSION:-$(./devel/generate-version)}"
     export PATH="$env/bin:$PATH"
+    export VERSION="${VERSION:-$(./devel/generate-version)}"

     clean
     build src

so that ./devel/generate-version sees the change.

./devel/generate-version itself also gets used in CI outside of a development environment, so that's why it doesn't itself set PATH. Though, I guess it could and it just wouldn't find anything there in CI...

diff --git a/devel/generate-version b/devel/generate-version
index c857a0a..444ac14 100755
--- a/devel/generate-version
+++ b/devel/generate-version
@@ -1,3 +1,7 @@
 #!/bin/bash
 set -euo pipefail
+
+source "$(dirname "$0")/_common"
+export PATH="$env/bin:$PATH"
+
 date --utc +%Y%m%dT%H%M%SZ