-
Notifications
You must be signed in to change notification settings - Fork 15
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
More accurate name for the Python versioning preset #112
Comments
Yeah, and I think other Python projects might just embed their version directly in I'm not sure if I'd be keen on the idea of having a |
My thinking is that as long as versionist acts in expected and natural way for the particular language, and the behaviour is well documented, things should be fine. It already automatically handles cases like having That is to say, we do not have to specify explicitly which This as you mentioned will eliminate the need to error out on specifying both As for the cases where the version is directly specified in Django for example uses a Not sure I expressed myself well, or I am confused, or both. |
Yeah, but OTOH if we had a Perhaps @jviotti or @jhermsmeier or @hedss or @lekkas would like to share their wisdom? ;)
Well at the moment we do support that case - the user just needs to specify updateVersion: {
preset: 'initPy',
targetFile: 'setup.py'
}
Yeah, something as bizarre as that will always need to use a custom preset 😉 |
Talking about
Do they mean that the Version metadata field can be used for generating I see your point about There is confusion coming from the fact that Maybe they should not share the same prefix ( |
|
Dunno, I haven't read the PEP, and I don't think we should concern ourselves with it (sorry if I caused confusion by not making that clear in my earlier comments). I was just thinking of simple use-cases like https://github.com/RPi-Distro/python-gpiozero/blob/master/setup.py#L25
Cool 🙂
Oooh, that's a good idea! 😀 Should we error if updateVersion: {
preset: 'python',
targetDir: 'foo/bar'
}
updateVersion: {
preset: 'python',
targetDir: 'foo/bar',
targetFile: '__init__.py'
} or should we always just join the two together, so that these four would all be equivalent: updateVersion: {
preset: 'python',
targetDir: 'foo/bar'
}
updateVersion: {
preset: 'python',
targetFile: 'foo/bar/__init__.py'
}
updateVersion: {
preset: 'python',
targetDir: 'foo/bar',
targetFile: '__init__.py'
}
updateVersion: {
preset: 'python',
targetDir: 'foo',
targetFile: 'bar/__init__.py'
} ? (even in the latter more-lenient case, I guess we'd still need to error if |
+1 for error when Now looking at the examples above, |
...and just for the sake of completion, these would also be equivalent: updateVersion: {
preset: 'python'
}
updateVersion: {
preset: 'python',
targetFile: '__init__.py'
}
updateVersion: {
preset: 'python',
targetDir: '.',
targetFile: '__init__.py'
}
updateVersion: {
preset: 'python',
targetDir: '.'
} I think we're in agreement now ( 🎉 ) but we should still wait for feedback from @nghiant2710 before working on this. To maintain backwards-compatibilty, we should probably leave the |
Oh, now that you provided this example (#110 (comment)), it starts to make sense to allow Also related: since BTW, the +1 for leaving |
Thinking about this further, since the most common scenario will be a single file, it will feel odd for naming the argument |
Yeah, I'd also be 👎 on supporting multiple files or globs - dealing with multiple files is exactly what #107 is about 😃 So, I guess we have a number of different options:
Disadvantage of 2. is that it allows 'yucky' things like: updateVersion: {
preset: 'python',
targetDir: 'foo',
targetFile: 'bar/__init__.py'
} Disadvantage of 3. is that it means you need to do: updateVersion: {
preset: 'updateQuotedVersion',
targetDir: 'meta-resin-common/conf/distro/include',
targetFile: 'resin-os.inc',
regex: '^DISTRO_VERSION\s+=\s+', Disadvantage of 4. is that it's slightly more complex logic (which may confuse users?). Whichever we go for, we should maintain consistent behaviour across all the different update-presets. Pretending for now that #106 #105 #112 and #110 have all been implemented, I think we'd have:
(obviously if we went for option 1. above, then EDIT: Updated the table, following discussions below |
I would not say #107 resolves multiple files that well. Let's consider the example:
If two files from the same directory has to be updated with the same preset, then the only option would be to copy and paste the whole thing. If the files are four or five, then it will be even worse. |
Support for multiple files can be expanded on top of the same API without the need for breaking changes, so it is not that important at this stage. |
I am looking at the parameters name and values above. In general I prefer more concise names when possible. So looking at the example above, I would say I like it more like:
What do you think? EDIT: For this one I do not have that stronger opinion. I guess it is a matter of personal taste only. |
I think we should go with the simplest option ^^. Although it has the disadvantage like you showed, this would be totally users fault, as there are better ways to define the same thing. And also that will leave the door open to eventually supporting multiple files in the future. |
I'd argue that if there are four or five files in the same directory that all need to be version-bumped at the same time, then that project is probably doing something wrong 😜 With regards to the parameter-names I also don't have strong opinions, so I'm happy to go with your suggestions. Not sure I'm too keen on |
I like that: |
In #99 we added support for version updates of Python modules. Although it is more common that the version number string
__version__
exists in a Python module's__init__.py
file, it is possible a Python module to be in the form of a file (like many in the std lib) and not in the form of a directory. If that is the case, then there is not an__init__.py
file, but the file name is equivalent to the module name.More on that here: PEP 396 -- Module Version Numbers
So it is better to rename the preset to something like
pythonModule
orpython
. I lean towardspython
since this is the standard way version numbers are defined in Python.Another related improvement is the
targetFile
argument. If we allow this to be a module directory path as well, then it will automatically mean that it targets__init__.py
in that directory. SotargetFile
can be renamed totarget
orpath
, which can accept both directory and file paths. The same can be used in #106 and #105 as well instead oftargetDir
.The text was updated successfully, but these errors were encountered: