Background: the gregor date and time library depends on another
library called tzinfo to provide information from the systems zoneinfo
database. However, not all systems have a zoneinfo database installed
(notably, Windows systems, but also some minimal UNIX ones used in
Docker containers, for example). So there's another package called
tzdata which provides the zoneinfo database. On Windows, but not on
other platforms, tzdata is a dependency of tzinfo.

When you create a standalone executable with `raco exe` and `raco
distribute` what I want is for tzinfo to use the files from tzdata, if
the latter package is installed when the executable is built. The code
I'm using looks like this:
=====
;; If the tzdata package is installed, put its zoneinfo directory at
;; the head of the search path.
(define-runtime-path-list tzdata-paths
  (match (find-relevant-directories '(tzdata-zoneinfo-module-path))
    [(cons info-dir _)
     (define path ((get-info/full info-dir) 'tzdata-zoneinfo-module-path))
     (list path)]
    [_
     null]))

(match tzdata-paths
  [(cons dir _)
   (current-zoneinfo-search-path
    (cons dir (current-zoneinfo-search-path)))]
  [_
   (void)])
=====

That is, the tzdata package defines, in an info.rkt file, a key named
`tzdata-zoneinfo-module-path`. I use that to determine if the package
is installed, and, if so, I create a runtime path for it and add that
path to the head of a list of paths to search for zoneinfo files.

The problem is that if a create a bundle for distribution with `raco
distribute` and try to use that bundle on a system where `tzdata` is
not installed, it doesn't work, since the conditional code to find the
`tzdata-zoneinfo-module-path` key fails, of course. So even though the
files are available in the bundle, they aren't used.

Is there a way around this problem? Maybe using `getinfo` is just a
bad approach, but I'm not sure what a good one would be.

- Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxywbSX-vBE2VQewQ3RM4qv%3D3wfdEESiWn-JSaU9kSQkZg%40mail.gmail.com.

Reply via email to