Giter VIP home page Giter VIP logo

Comments (4)

sio avatar sio commented on May 24, 2024

Thank you for reporting this issue! I was not familiar with pip-compile before and I have not anticipated such use case while creating Makefile.venv.

The task you're trying to do is twofold:

  1. You want to be able to automatically generate 'requirements.txt' with a Makefile recipe
  2. You want to use a tool from the virtual environment before virtual environment is finalized by Makefile.venv

First part was not possible (at least not easily doable) with Makefile.venv (v2020.05.07) because it allowed for REQUIREMENTS_TXT to reference non-existent files. No errors would be raised and no Makefile recipes would be checked to try to create the missing files, Makefile.venv would just move along happily. I've changed that today, the code is currently in a feature branch: issue8

Second part was and is doable but undocumented. I do not yet see how to describe it in generic terms, may be you will help?

Here is how it can be done for your case:

# Makefile

### This part was not possible with v2020.05.07

# You need to explicitly specify this value because by default it's ok for
# requirements.txt to be missing. This statement MUST come before `include
# Makefile.venv`
REQUIREMENTS_TXT=requirements.txt


### Everything below relies on features existing in v2020.05.07

include Makefile.venv


# Save pip-compile path to variable for brevity
# You may omit $(EXE) suffix if you're ok with Windows builds being broken
PIP_COMPILE=$(VENV)/pip-compile$(EXE)


# This and the next recipe MUST be defined after include statement.
# You need to inject pip-compile into virtual environment
# before Makefile.venv finishes working on it, but after venv is created.
# There already exists a target you can add as dependency for this case:
$(PIP_COMPILE): | $(VENV)
	$(VENV)/pip install pip-tools  # or whatever method you prefer
	touch $@


# Your requirements file directly depends upon *.in file and also requires
# pip-compile to be available
requirements.txt: requirements.in | $(PIP_COMPILE)
	$(PIP_COMPILE) --output-file $@ $<

And that's all. The rest of your Makefile should be written as usual when working with Makefile.venv: depend on venv, call $(VENV)/binaries, etc. The trick is to use $(VENV) as dependency for $(PIP_COMPILE) - that way we can avoid circular dependnecy and pip-compile will be installed after bare venv is created but before Makefile.venv attempts to fill it with packages from 'requirements.txt'. I've added a full working example to the test suite.

If nothing is broken and there is no new feedback in a couple of days I will merge the changes to master and will publish a new release.

PS: may I ask what project are you using Makefile.venv for?

from makefile.venv.

belm0 avatar belm0 commented on May 24, 2024

Thank you, we'll try it next week.

We're evaluating Makefile.venv for some internal GROOVE X projects.

from makefile.venv.

belm0 avatar belm0 commented on May 24, 2024

Thank you for the enhancement and detailed instructions-- it seems to be working!

from makefile.venv.

sio avatar sio commented on May 24, 2024

Good :) I've just pushed a new release, v2020.08.04, which includes these changes.

from makefile.venv.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.