Re: [PATCH] python-cffi: read version from notmuch version file

2020-06-23 Thread Floris Bruynooghe
On Tue 23 Jun 2020 at 13:43 +0300, Frank LENORMAND wrote:

> On Tue Jun 23 12:33:36 2020, David Bremner wrote:
>> Frank LENORMAND  writes:
>> > For example, 0.30.1, with the first two numbers coming from the main
>> > repository, and the last one acting as major for the bindings.
>> >
>> > 0.29.3 → 0.29.1
>> > 0.30-rc2 → 0.30.1-rc2
>> > etc.
>> >
>> 
>> I'm mainly interested in supporting two use cases for notmuch: building
>> everything from source, and binary packages of released versions. We've
>> already gone to some trouble to tell Emacs users that try to mix and
>> match versions that they are on their own, and this seems to apply even
>> more strongly to bindings users.
>>
>> With that said, if Floris thinks some hierarchical version is useful,
>> and is willing to maintain it, I can live with it. I would ask that:
>> 
>> 1) You keep the whole "upstream" version number. So the first example
>> would be 0.29.3.1.  0.29.1 is a previous version of notmuch, and that
>> ambiguity can only cause trouble.
>
> The idea was that the bindings will work with the X.Y version they were
> released for, since the last component in X.Y.Z is for minor changes that
> shouldn't affect the API.

Minor nitpicking, but API is not strong enough here, you'd need to
ensure ABI compatibility.

> So we can keep X.Y from NotMuch itself, and append some information that
> hint at the state of the bindings.
[...]
> Or the exact same version number, but then what should happen to it when
> the bindings are modified, but not NotMuch?

If it was bad enough to need a new release then I guess everyone gets
the same version bump as the entire project gets a bugfix release?

I honestly like the simplicity of just having the same version number
and not having to think about maintaining it separately.  It also means
we mostly don't have to worry about how setuptools/pip is going to view
the version number.

The only way I think this could break is if we want to break backwards
compatibility in the bindings, but we're not supposed to do that
(realistically an impossible task in Python if you ask me, but we can
aim for at least avoiding doing this knowingly).

The most likely version number sin is that the python bindings get a new
feature while libnotmuch only gets bugfix.  I also don't think this is
terrible, but that's perhaps unusual and frowned upon.  Maybe this
warrants a README in the bindings to warn the version number just tracks
libnotmuch and as far as python goes can only be used to order the
releases.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] python-cffi: read version from notmuch version file

2020-06-23 Thread David Bremner
Frank LENORMAND  writes:
> For example, 0.30.1, with the first two numbers coming from the main
> repository, and the last one acting as major for the bindings.
>
> 0.29.3 → 0.29.1
> 0.30-rc2 → 0.30.1-rc2
> etc.
>

I'm mainly interested in supporting two use cases for notmuch: building
everything from source, and binary packages of released versions. We've
already gone to some trouble to tell Emacs users that try to mix and
match versions that they are on their own, and this seems to apply even
more strongly to bindings users.
   
With that said, if Floris thinks some hierarchical version is useful,
and is willing to maintain it, I can live with it. I would ask that:

1) You keep the whole "upstream" version number. So the first example
would be 0.29.3.1.  0.29.1 is a previous version of notmuch, and that
ambiguity can only cause trouble.

2) You don't insert things in the middle. So the second example would be
0.30-rc2.1

3) You have some way to distinguish between the notmuch version 0.30.1,
and the bindings version 0.30(.1) . I'd suggest using something
different than '.'  as a separator, but I don't know what the python
toolchain will tolerate.


___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] python-cffi: read version from notmuch version file

2020-06-22 Thread Floris Bruynooghe
On Fri 19 Jun 2020 at 15:26 +0300, Frank LENORMAND wrote:

> On Fri Jun 19 12:46:28 2020, Floris Bruynooghe wrote:
>> This keeps it in sync with the main notmuch version which is less
>> confusing to users.
>> ---
>>  bindings/python-cffi/setup.py | 10 +-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>> 
>> diff --git a/bindings/python-cffi/setup.py b/bindings/python-cffi/setup.py
>> index 37918e3d..1effcfc6 100644
>> --- a/bindings/python-cffi/setup.py
>> +++ b/bindings/python-cffi/setup.py
>> @@ -1,9 +1,17 @@
>> +import pathlib
>> +
>>  import setuptools
>>  
>>  
>> +THIS_FILE = pathlib.Path(__file__).absolute()
>> +PROJECT_ROOT = THIS_FILE.parent.parent.parent
>> +with open(PROJECT_ROOT.joinpath('version')) as fp:
>> +VERSION = fp.read().strip()
>> +
>> +
>>  setuptools.setup(
>>  name='notmuch2',
>> -version='0.1',
>> +version=VERSION,
>>  description='Pythonic bindings for the notmuch mail database using 
>> CFFI',
>>  author='Floris Bruynooghe',
>>  author_email='f...@devork.be',
>> -- 
>> 2.27.0
>
> It seems that this strategy doesn't work well when the user runs
> `pip install .` in the `bindings/python-cffi` directory.
>
> Apparently all the files are copied to a temporary directory first:
>
> https://travis-ci.com/github/pazz/alot/jobs/351377760#L708-L710
>
> It doesn't happen with the original bindings, probably because the version
> number is stored in `bindings/python/notmuch/version.py`, which is also
> copied when `pip` runs.

Ouch, I only tested pip install -e, which does work.  But indeed a plain
pip install no longer works which is pretty bad.

I guess we could either revert this and do the same sed hackery as the
other bindings, or copy the version file into bindings/python-cffi and
have it loaded in the same way as now.  It would still have to be kept
in sync there sadly.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] python-cffi: read version from notmuch version file

2020-06-19 Thread Floris Bruynooghe
On Fri 19 Jun 2020 at 07:20 -0300, David Bremner wrote:

> Floris Bruynooghe  writes:
> BTW I noticed something (setuptools?) translates "0.30~rc2" to
> "0.30-rc2". I assume that is as intended, and there are some stricter
> rules for python module versions. It should only affect pre-release
> versions in any case.

Supposedly setuptools uses packaging.version:

   $ python3
   Python 3.8.3 (default, May 14 2020, 11:03:12)
   [GCC 9.3.0] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import packaging.version
   >>> rc1 = packaging.version.parse('0.30~rc1')
   >>> rc1
   
   >>> rc2 = packaging.version.parse('0.30~rc2')
   >>> maj = packaging.version.parse('0.30')
   >>> maj
   
   >>> rc1 < rc2 < maj
   True

So I think this is ok?  Just for completeness:

   >>> rc1b = packaging.version.parse('0.30-rc1')
   >>> rc1b
   
   >>> rc1b < maj
   True

Apparently PEP440 has the full details of how Python wants to see
version numbers work, but it's too many years ago that I read that
thing ;).  This seems good enough to me.

Cheers,
Floris
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] python-cffi: read version from notmuch version file

2020-06-19 Thread David Bremner
Floris Bruynooghe  writes:

> This keeps it in sync with the main notmuch version which is less
> confusing to users.

ah, that's much nicer than what I did for the old bindings. merged.

BTW I noticed something (setuptools?) translates "0.30~rc2" to
"0.30-rc2". I assume that is as intended, and there are some stricter
rules for python module versions. It should only affect pre-release
versions in any case.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] python-cffi: read version from notmuch version file

2020-06-19 Thread Floris Bruynooghe
This keeps it in sync with the main notmuch version which is less
confusing to users.
---
 bindings/python-cffi/setup.py | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/bindings/python-cffi/setup.py b/bindings/python-cffi/setup.py
index 37918e3d..1effcfc6 100644
--- a/bindings/python-cffi/setup.py
+++ b/bindings/python-cffi/setup.py
@@ -1,9 +1,17 @@
+import pathlib
+
 import setuptools
 
 
+THIS_FILE = pathlib.Path(__file__).absolute()
+PROJECT_ROOT = THIS_FILE.parent.parent.parent
+with open(PROJECT_ROOT.joinpath('version')) as fp:
+VERSION = fp.read().strip()
+
+
 setuptools.setup(
 name='notmuch2',
-version='0.1',
+version=VERSION,
 description='Pythonic bindings for the notmuch mail database using CFFI',
 author='Floris Bruynooghe',
 author_email='f...@devork.be',
-- 
2.27.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch