-
Notifications
You must be signed in to change notification settings - Fork 145
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
Format of Pipfile #46
Comments
We're pretty set on the current implementation. It's good. |
As of now, here's what I see in the contenders for the Pipfile format:
Every other format has been eliminated because of the same reasons as they were in PEP-518. If I could do whatever I wanted, I would yank out a spec for something like YAML and ask everyone to just use it where it makes sense in their domain. More realistically though, as @dstufft puts it:
TOMLTo me, the trade-offs seems most "balanced" with TOML. I just like how the picture comes together with it. There's a DSLAs I weighed up all of these options, I realized that the Python DSL is actually really nice. But there's just some really bad issues with it:
At which point, this leads to the following decisions to be made:
The answers to these questions lead me to lean toward TOML. Honestly though, if we settle on anything other than TOML, I think it's worth discussion (on Just to restate an important thing, this issue doesn't need to hamper the ongoing development of a prototype. It just needs to be finalized before this makes it into pip. |
@kennethreitz For a prototype, a POC, I don't mind the I don't think anyone would want an exec making it into the final thing that gets vendored into pip. |
could you please explain what you mean by “We're pretty set on the current implementation”? i don’t think it’s a good idea to remain with it if you mean what assume: i don’t think one should choose the initial prototype without having it prove itself in an objective comparison. and the most upvoted comments in the other thread – that talk about the format itself, not its executability – are the following: (i extracted the parts suggesting actual formats)
(there’s also a 👍 20 comment by @domenkozar, which however addresses executability) so of 4 comments:
|
I would add another minus against DSL. Too much flexibility can grow into something monstrous. |
Sorry that I've been kind of AWOL on The proof of concept is likely to go forward with the Python DSL if only because @kennethreitz has already written (most?) of the code to handle it. It's important to stress that this is only a proof of concept though and part of that is going to be hashing out how the idea in general works and how pip integrates with it as well as testing any issues with whatever format we're using. That being said, I was originally very pro Python DSL, but I've since started wavering more towards the TOML side of things. For two reasons:
|
To be clear, I am not sure the right direction yet, and hopefully experience with the PoC will give more insight. |
Can someone please paste the example from the readme in an ideal TOML format here? |
not sure what would be ideal, as you had time to iterate. here’s an ad-hoc attempt. everyone feel free to improve it. [[source]]
url = 'https://pypi.org/'
verify_ssl = true
[requirements]
python = '2.7'
[packages]
requests = { extras = ['socks'] }
Django = '>1.10'
pinax = { git = 'git://github.com/pinax/pinax.git', ref = '1.4', editable = true }
[dev-packages]
nose = '*' alternatively you can expand inline tables [packages.pinax]
git = 'git://github.com/pinax/pinax.git'
ref = '1.4'
editable = true also possible: quoted names or named sources: [[source]]
'https://pypi.org/' = { verify_ssl = true } [source.pypi]
# url for PyPI is known
verify_ssl = true i follow cargo here, which means that using as string as value is a shortcut for |
As @flying-sheep notes, any chosen TOML syntax would need iteration to figure out a table structure that gave nice readable files in common cases, but these are updated versions of a couple of draft examples I came up with in #10 (comment):
And showing some nesting examples:
The convention I've adopted there is that the object categories defined by the file format ( Without some kind of convention along those lines, nested examples like the last one become really hard to read, as the category names don't stand out from the names of the specific instance within that category and the whole line dissolves into a kind of alphabet soup. Relative to the DSL, the main readability feature lost in going to TOML is breaking the link between visual nesting (indentation) and structural nesting (dotted table names). However, losing that is also the main benefit from a tool development perspective, since it removes the sensitivity to leading whitespace, as well as much of the context dependence of attribute assignments (only the immediately preceding table header, if any, matters). Folks that aren't using automated tools to manipulate their TOML files could optionally inject visual structure via comments if they chose to do so:
As with anything based on comments though, the only defence against the comments and the actual configuration getting out of sync would be code review (and potentially a commenting-convention-aware linter) |
I took it to mean that in this PoC version, there is no need to change the format. And with the current format, we can experiment with the PyDSL, which can't hurt. |
I took some time and tried to assemble an ideal TOML pipfile example. [sources]
pypi = "https://pypi.org"
legacy = {url="http://pypi.python.org/", verify_ssl=false}
# "main" is the default group.
[packages.main]
django = "~= 1.10"
[packages.py27]
django = {version="~= 1.9", source="legacy"}
[packages.py36]
django = "~= 1.11"
[packages.pypy]
django = "~= 1.8"
[packages.linux]
linux-spicific-pkg = "1.0"
# Group parameters.
[groups]
py27 = {version="~= 2.7"}
py36 = {version="~= 3.6"}
pypy = {python="pypy"}
# Pinned versions, updated automatically by pip.
[versions.main]
django = "1.10.0"
[versions.py27]
django = "1.10.0"
[versions.py36]
django = "1.11.1"
[versions.py36]
django = "1.9.7" Here all version specifiers use PEP-04440 version specifiers. All packages should be defined in Group parameters can be defined in In addition, I think it is a good idea, to save pinned version in the same single TOML file. This would work by identifying
Tried to look to several example projects and wrote TOML files: Sanic https://github.com/channelcat/sanic [packages.main]
uvloop = ">= 0.5.3"
httptools = ">= 0.0.9"
ujson = ">= 1.35"
aiofiles = ">= 0.3.0"
multidict = ">= 2.0"
[packages.dev]
httptools = ""
ujson = ""
uvloop = ""
aiohttp = ""
aiocache = ""
pytest = ""
coverage = ""
tox = ""
gunicorn = ""
bottle = ""
kyoukai = ""
falcon = ""
tornado = ""
aiofiles = "" Ansible https://github.com/ansible/ansible [packages.main]
paramiko = ""
jinja2 = ""
PyYAML = ""
setuptools = ""
pycrypto = ">= 2.6"
[groups]
main = {version="~= 2.7"} Pandas https://github.com/pandas-dev/pandas [packages.main]
python-dateutil = ""
pytz = ">= 2011k"
numpy = ">= 1.7.0"
[packages.py3]
python-dateutil = ">= 2"
[groups]
py3 = {version="~= 3"} Fabric https://github.com/fabric/fabric [packages.main]
paramiko = ">= 1.10, <3.0"
[packages.py26]
paramiko = ">= 1.10, <1.13"
[groups]
py26 = {version="< 2.6"} |
there are again only two groups at this time (a-la composer): |
I am not a fan of the TOML syntax presented so far — I think it's far from intuitive, and would require someone to copy/paste from an example every time they go to use it. |
This is the best example I've seen so far, and what I asked for:
I think that is doable. |
now the question is, how, in this example, would i specify 'requests' without it being equal to anything?
? |
I see, |
Got the basics working in the new https://github.com/pypa/pipfile/blob/4230ddf91f25e5ef33eed88d12f0bca672818214/README.rst |
Merged the TOML branch. |
Pipfile will now use TOML. I like it. |
Check out the main README now for details. |
I'm happy with the way this worked out. Looking at the example in the README, I feel that it is very intuitive and concise. I think this format will be simple for beginners to grasp and remember. |
@kennethreitz in your version Here is slightly modified version of your example, that address this case: [[source]]
url = 'https://pypi.org/'
verify_ssl = true
[requires]
python = '~= 2.7, ~3'
[packages]
requests = { extras = ['socks'] }
Django = '>1.10'
pinax = { git = 'git://github.com/pinax/pinax.git', ref = '1.4', editable = true }
pathlib = { python = '>= 2.7, < 3.5' }
[dev-packages]
nose = '*' In this case, pathlib will be installed only for python 2.7..3.4. Python 3.5 and later have pathlib built-in. And if section names would be defined using TOML syntax: [packages.default]
[packages.dev] Then exactly same schema can be used for freeze file too. There will be no need to support two different schemes. |
Packages without version can be specified like this: nose = {} |
@flying-sheep @kennethreitz Good call on using "-packages" as a suffix to denote alternative package groups, as well as starting small with just the single predefined "dev-packages". |
I agree. But if support for custom groups will be added, something like what @sirex says will be the way to go; right? |
#10 organically grew into a discussion on which format should be used in
Pipfile
. Since that is a completely different question from whetherPipfile
should be executable, I think that it deserves a dedicated issue.You can obviously see comments there for the (brief) history on this.
The text was updated successfully, but these errors were encountered: