Start with a setup.py like this:
python
setup(
name="foo",
version="0.1",
install_requires=[
# Your deps here
"bar",
"baz >= 2.0",
],
extras_require = {
# Your dev deps here
"dev": [
"pytest",
]
},
entry_points={
"console_scripts": [
"foo = foo:main"
]
},
)
Run dmenv freeze: it will
python -m venvpip intall --editable .[dev] so that your dev deps are installed, and the scripts listed in entry_points are
createdpip freeze to generate a requirements.lock file.Now you can add requirements.lock to your git repo, and anyone can run dmenv install to install all the deps.
As a convenience, you can use:
dmenv run to run any binary from the virtualenvsource $(dmenv show) to activate the virtualenv for your current shellQ: How do I add dependencies to build the documentation?
A: Stick them in the dev section.
Q: What if I don't want to install the dev dependencies?
A: Don't use dmenv. Run pip install without [dev] extras.
Q: How do I upgrade a dependency?
A: Just run dmenv freeze again. If something breaks, either fix your code or use more precise version specifiers
Q: How do I depend on a git specific repo/branch?
A: Edit the requirements.lock by hand like this:
foo==0.1
https://gitlab.com/foo/bar@my-branch
Q: But that sucks and it will disappear when I re-run dmenv freeze!
A: Yes that sucks. Feel free to:
* Open a pull request if you've forked an upstream project
* Use a local pipy mirror and a little bit of CI to publish your sources there
apt install python3-venv. But that's Debian's problem, not minesetup.py!Too bad. Don't use dmenv, then. poetry is cool.