Repository: pypa/pipenv

Issue:
Pipfile touched even on pipenv run
I have a watch command tracking my `Pipfile` but on every call of `pipenv run` the command is executed, even if the file wasn't changed. I tracked this down to the call of `Project.touch_pipfile`. I'm not sure if it required, for `Pipfile` to be touched every time, probably it is just a side effect of calling  `cli.py@ensure_project`.

Would it be reasonable to only touch the `Pipfile` if it either doesn't exist or if there is actually a change to its contents?


Discussion:
I noticed this too. In my Makefiles, I run `pipenv install` when `Pipfile*` is newer than the installed dependencies, but now this runs all the time.
Is this just annoying, or a real problem?
landed a fix in master
I think this was supposed to have been fixed with 7.1.0, but the issue persists for me.

```
$ pipenv --version                                                            
pipenv, version 7.1.0                                                         
$ ls -l --time-style=full-iso Pipfile                                         
-rw-rw-r-- 1 mbarkhau mbarkhau 416 2017-09-15 09:46:34.611467318 +0200 Pipfile
$ pipenv run python -m os                                                     
$ ls -l --time-style=full-iso Pipfile                                         
-rw-rw-r-- 1 mbarkhau mbarkhau 416 2017-09-15 09:46:56.526411866 +0200 Pipfile
```
To answer the earlier question, mostly this is just very confusing, as opposed to being a real problem.

Same for me. It's not a huge deal but it breaks all my build caching that relies on file modification time. It _could_ cause issues if pipenv intends to run in a container with a read-only filesystem.
Hi @kennethreitz I think this may have fallen off your radar, or is this a non issue in your view?
the file should only be touched when it doesn't exist. I can look into it, but i don't see it as a big issue, no. 
The `Pipfile` is still updated on every run with 7.6.7 (but not 6.2.9).

For reference, this is the Makefile pattern that this causes problems with:

```

.PHONY: install
install: .venv/installed
.venv/installed: Pipfile*
	pipenv install --dev
	@ touch $@

.PHONY: run
run: install
	pipenv run honcho start
```
You should be checking the lockfile for changes. 
It's what's being used for install anyway. 
@jacebrowning i'd be happy to accept a pull request that doesn't touch the makefile on every run — there's code in place to only touch it if it doesn't exist, so i'm not sure why this is happening, so you'd have to dig in a little bit. 
Cool. I'll look into it.
I would recommend keying off of the lockfile though — it's what's important, not the Pipfile. 
and the lockfile doesn't get touched constantly. 
pipenv automatically re-locks whenever anything gets installed/uninstalled, so it should take care of all your problems. 
Yeah. It's still handy to be able to manually add packages to the `Pipfile` or update version specs and have these changes get picked up automatically by Make tasks.
Gotcha. The intention behind pipenv is that you never have to edit the pipfile yourself unless you're doing fancy stuff (like markers, etc)

Resolving patch:
diff --git a/pipenv/project.py b/pipenv/project.py
--- a/pipenv/project.py
+++ b/pipenv/project.py
@@ -311,12 +311,15 @@ def touch_pipfile(self):
 
     @property
     def pipfile_is_empty(self):
-        self.touch_pipfile()
+        if not self.pipfile_exists:
+            return True
 
         with open('Pipfile', 'r') as f:
             if not f.read():
                 return True
 
+        return False
+
     def create_pipfile(self, python=None):
         """Creates the Pipfile, filled with juicy defaults."""
         data = {


Test patch: