Comments (4)
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:
- You want to be able to automatically generate 'requirements.txt' with a Makefile recipe
- 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.
Thank you, we'll try it next week.
We're evaluating Makefile.venv for some internal GROOVE X projects.
from makefile.venv.
Thank you for the enhancement and detailed instructions-- it seems to be working!
from makefile.venv.
Good :) I've just pushed a new release, v2020.08.04, which includes these changes.
from makefile.venv.
Related Issues (19)
- Sha256sum not working on MacOS HOT 6
- Expose the VENV to child processes HOT 4
- control over pip version HOT 4
- Trying to install the local project isn't necessarily desired HOT 7
- Python Launcher for Windows HOT 11
- Execute CI in bare Windows environment HOT 2
- CI failure on Windows 10 / Python 3.9.10 HOT 3
- $(RM) HOT 1
- Support for cygwin (with proposed solution) HOT 6
- Using `venv` as a proper dependency HOT 3
- pyproject.toml HOT 3
- Source .env for interactive shell targets HOT 2
- Install pyproject.toml optional dependencies HOT 2
- Execute CI tests in Cygwin HOT 1
- Spaces in path fatally confuse the script HOT 5
- Error when overriding the VENVDIR HOT 9
- How to pass arguments to pip install? HOT 6
- Write docs for pipenv/poetry integration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from makefile.venv.