Pipenv: Preserve order of Pipfile

Created on 26 Jan 2017  路  11Comments  路  Source: pypa/pipenv

Every time the Pipfile is changed the Pipfile section arrangement might, too. Which is a pain if you have to review such changes. Especially if it's the case for Pipfile and Pipfile.lock.

I'm not very familiar with TOML and the Python package used but maybe it's possible to preserve the order when writing to the Pipfile? (Using OrderedDicts internally or something).


TODO (this section by Kenneth Reitz)

  • [x] determine if TOML library supports dumping OrderedDicts.
  • [x] determine if TOML library supports loading OrderedDicts.
  • [ ] implement preserve order in Pipfile
  • [ ] implement preserve order in Pipfile.lock
Type Type help wanted

All 11 comments

I will have to investigate ordering of the lockfile and, most likely, the order of the resulting requirements.txt.

toml.dumps() supports ordered dicts. Loading is another issue.

It does support ordered dicts for loading!

```
print toml.loads(toml.dumps(d), _dict=OrderedDict)

I've just seen it, too ;) Are you going to change it or should I?

Go for it! I'm about to hop in a meeting :)

working on it

I was just doing the PR. Nevermind ;)

partially implemented

From some initial tests, this looks to be working with #115. A second pair of eyes confirming this would be helpful :)

It appears that in same cases (most likely random) it still changes the order of [packages] and [dev-packages] section. However the order within the section is indeed preserved.

As well as we might extend this issue to preserve the order of the lock file as well.

we've done the best we can for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erinxocon picture erinxocon  路  3Comments

marc-fez picture marc-fez  路  3Comments

jacebrowning picture jacebrowning  路  3Comments

FooBarQuaxx picture FooBarQuaxx  路  3Comments

hynek picture hynek  路  3Comments