2

I am creating a cross-platform Python app, using pipenv (as I understand poetry has the same issue too) for management of dependencies and virtual envs.

While trying to build the app on Windows and Linux I noticed that Pipenv.lock is platform-specific.

For example, I create a project on Windows and add pytest, it has colorama with "markers": "sys_platform == 'win32'" in the lock file. But when modifying the lock file on Linux, such as adding a new lib, this dependency will disappear.

Here is the full output on both systems and diff https://gist.github.com/AlexP11223/6457fd4c98272c526c855c63088c00d4

Is it supposed to work like that? If yes, what is the best way to handle that? Is there any better solution than just committing lock files for all platforms to the Git repo (such as Pipenv-win.lock, Pipenv-linux.lock) and renaming one of them to Pipenv.lock when building?

Alex P.
  • 3,697
  • 9
  • 45
  • 110

1 Answers1

1

https://github.com/pypa/pipenv/issues/3902

A Pipenv developer suggested to add --keep-outdated option. It seems to work, at least in this simple example.

Currently it does not work in the latest release (2018.11.26), only in the Git repo master branch.

UPD: looks like I was wrong about Poetry and it handles this correctly by default https://gist.github.com/AlexP11223/afbe247175efdcc897930d8c6ab04184

Alex P.
  • 3,697
  • 9
  • 45
  • 110
  • I don't understand what that gist is trying to demonstrate, especially since I actually see changed lines in the [3.diff](https://gist.github.com/AlexP11223/afbe247175efdcc897930d8c6ab04184#file-3-diff) file. – Kal Nov 07 '19 at 03:11
  • @Kai there are no changes in the file content, it's just the [diff](https://en.wikipedia.org/wiki/Diff) syntax highlighting. It just shows that some dependencies get deleted when installing new dependencies on another platform. – Alex P. Nov 07 '19 at 06:59
  • 1
    I know it's diff syntax highlighting. The fact that you added the `hello-world` package in the linux run makes it really confusing. I don't know why you are diffing your lock file between before and after installing `hello-world`. A much better comparison would be to run `poetry install` *without* any lock file, on both Windows and Linux, and then comparing the resulting lock file between the two platforms. – Kal Nov 07 '19 at 07:16
  • @Kay iirc it happens only when the lock file is regenerated, that's why I added a new dependency. The whole point of lock files is to have the same dependencies everywhere, deleting it doesn't make sense. – Alex P. Nov 07 '19 at 07:47
  • 1
    My point is that, if, in the absence of a lock file, `poetry install` generates identical lock files on Windows and on Linux, even given PEP-508 markers in some dependencies (e.g. `ipython` and `pytest`), then you should be ok. Currently, I *know* that pipenv generates different lock files for ipython, between Windows and Linux (and probably also different for macOS/darwin). – Kal Nov 07 '19 at 08:12