Haterind
Haterind

Reputation: 1445

Pass variables from one makefile to another

Let's say I have a makefile like this:

build:
    # output will be something like dist/foo-1.2.3-py3-none-any.whl
    poetry build

upload: build
    aws s3 cp ${WHEEL_NAME} s3://some-bucket/

The name of the wheel is obviously always changing and so it will somehow need to be recorded at the end of build and read at upload. What is the correct way of implementing this?

Upvotes: 0

Views: 128

Answers (1)

Beta
Beta

Reputation: 99094

Here's one simple approach. Instead of dist/, use a directory whose sole purpose is to contain the latest wheel:

WHEELDIR := latest-wheel

build:
    @rm -fr $(WHEELDIR)
    @mkdir $(WHEELDIR)
    # output will be something like $(WHEELDIR)/foo-1.2.3-py3-none-any.whl
    # I don't know what "poetry build" does

upload: build
    aws s3 cp $(WHEELDIR)/* s3://some-bucket/

If you like, you can add a line or two to store a copy of the wheel in dist/, or some other archive.

Upvotes: 1

Related Questions