indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.32k stars 227 forks source link

How to create a configuration that does not depend on the absolute path? #699

Closed maBarabas closed 11 months ago

maBarabas commented 1 year ago

I'm trying to use glob to add some files to my output, but it seems to require knowing the absolute path of the project root as an argument to strip_prefix.

error[TUGGER_FILE_RESOURCE]: path cannot be absolute: C:/Users/barabas/Documents/project-name/./binaries/app.bin
       --> .\pyoxidizer.bzl:289:16
        |
    289 |     binaries = glob(["binaries/*"])
        |                ^^^^^^^^^^^^^^^^^^^^ glob()

How can this error be resolved without hardcoding strip_prefix to C:/Users/barabas/Documents/project-name/ which will only work on my machine.

This is the same issue as #410, which was closed without a real solution.

alisher-amantay commented 11 months ago

Why does the solution given in #410 to use glob(["binaries/*"], strip_prefix=CWD) not work for you? The behavior could be argued to be intended as how would a glob know where to chop off the paths otherwise.

maBarabas commented 11 months ago

I had assumed they meant the actual current working directory rather than the magic CWD constant. This should work.