-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pipfile support ? #417
Comments
Interesting. Never heard of pipfile. My first reflex without looking closely is the infamous xkcd about standards, but I will definitely have a look if this is something that one needs to keep an eye on :) Diclaimer I am quite new to the project although I have a maintainer hat on, so don't expect too much in depth knowledge from me yet. At the moment I am wading through all unlabelled issues and try to get a feel for what is needed and where things could be moving. So here are just some random thoughts to maybe help you assess a bit more in which direction this could move: Backwards compatibility is very important and there are a lot tox.inis out there already, so whatever we do, we must be very careful not to break existing test setups. This makes changes to the way Tox is plugin driven to extend functionality for special use cases so maybe there is a way to provide what you want as a plugin. |
For option 1, does https://tox.readthedocs.io/en/latest/config.html#substitution-for-values-from-other-sections not work? |
pipfile is quite distinct from the use-case for tox - as far as i can tell if tox had better requirements.txt support, then pipfile could argument it with the tool to generate the pinned requirements.txt |
@speedyleion I somehow missed that, sorry. I ended up using something like: [base]
deps =
colorama==0.3.7
path.py==9.0
ruamel.yaml==0.13.2
[lint]
deps =
{[base]deps}
pylint==1.6.4
astroid==1.4.9
[testenv:lint]
deps = {[lint]|deps}
commands = pylint foo Seems to work well so far ;) |
Proposing to close this as not necessary/applicable if we solve the actual problems with dependency handling. |
I believe it makes sense to refresh the discussion of Pipfile aka Pipenv. @kennethreitz The Pipenv docs say that Pipenv is meant to be a deployment tool. Does that mean this contradicts with integrating Pipenv with Tox?
In my opinion it would make sense to integrate Pipfile/Pipenv with Tox. Pipenv's role related to deployment needs to be clarified for that, though. Especially since testing plays an important role in the concept of deployment pipelines. See Also |
Hi @bittner, thanks for the overview - leaving this open for further discussion then. |
In version 2018.05.18 pipenv will detect if it's running in a virtual environment and not create a new one. You can therefore configure tox thus:
All the dependencies have to be defined in the Pipfile. Adding anything to
For older versions, I think the There's another suggestion of how to do it here: https://docs.pipenv.org/advanced/#tox-automation-project |
For more direct Pipfile support for tox (or a plugin), requirementslib may be useful. |
Oh I just noticed there's an open issue here for this. I've been trying to discuss it in tox-dev/tox-pipenv#37. The problem with the approach mentioned by @OrangeDog is that it's impossible to define multiple different versions of requirements. I think the final solution needs to:
So as I was saying there, my approach looks something like this: deps =
-p{toxinidir}/Pipfile # Or replace -p
pytest
pytest-mock To specify the pipfile environment, a few choices:
I'd really love to get this natively in tox. Ideally, it'd even be native to pip, but I don't think there's much hope of seeing this any time soon (especially if Pipfiles aren't in their final format). |
A single Pipfile already supports multiple environments. Any solution that involves multiple Pipfiles must be wrong. |
@OrangeDog Can you give a link to some docs or examples? The spec here shows dependency on only one version of Python. |
@butla You can have arbitrary |
No support is planned at the moment. If anyone wants can pick it up as a plugin outside of the project. |
So, I've stumbled upon the pipfile project and I'm thinking supporting
pipfile
insidetox
would be a good idea.Context
ruamel.yaml
andpath.py
.tox
to run the tests withpy.test
and do static analysis withpylint
.setup.py
looking like:python setup.py
takes a long time, so I'm usingskipsdist=True
Caveats
I'm pretty new to
tox
(been usinginvoke
for some time before), so maybe there's something obvious I'm missing. In this case, feel free to correct me :)The problem
Bot
py.test
andpylint
needs all the dependencies installed to run properly (pylint
will give an error if it can't importpath.py
for instance).A naive
tox.ini
would look like:You notice there is some code duplication between the
lint
and thetest
environments.First solution
To fix this, we could use string interpolation in the config file:
Unfortunately,
tox
usespy.iniconfig
and does not support this feature.Second solution
We could also use a
requirements.txt
with the frozen version inside, like so:This works, but if we have a new dependency, we have to:
setup.py
pip freeze
requirements.txt
tox
virtual environments.The same problem occurs if we bump
path.py
to0.43
.tox
has no way to know the dependencies have changed, and we have to re-create all the virtualenvs again.Third solution
The great thing about
pipfile
is that we get apipfile.lock
injson
which is very easy to parse, and always contain frozen versions numbers.So
tox
could simply read it:Proposed pull requests
So, there are many things we could do here:
Allow string interpolation in
tox.ini
, either by:configparser
instead ofpy.iniconfig
py.iniconfig
to add support for string interpolationImprove support of
requirements.txt
files intox
so that frozen versions are taken into accountImplement
pipfile
supportIn my humble opinion, working on
pipfile
is the best way to go, but it's not for me to decide.What do you think?
The text was updated successfully, but these errors were encountered: