How to create a pypi distribution ?

76 views
Skip to first unread message

Viktor Ransmayr

unread,
Jun 3, 2024, 3:55:47 PMJun 3
to leo-editor
Hello Edward & Community,

Has anyone tried to create a pypi distribution of Leo following the description in GitHub issue #3837 ?

When I try to follow the description I already fail during Step 1 !

* I start with an up to date version of Leo's devel branch.
* The only change I make is to change the version tag of Leo in 'PKG-INFO.TXT'.
* When I run the 'build_leo.py' script I immediately receive the following traceback:

###

    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$ python3 -m leo.scripts.build_leo
    build_leo.py
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/home/user/PyVE/GitHub/Leo/leo-editor/leo/scripts/build_leo.py", line 26, in <module>
        assert os.path.exists(dist_dir), dist_dir
    AssertionError: /home/user/PyVE/GitHub/Leo/leo-editor/dist
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$

###

The assertion ~ flags ~ "/home/user/PyVE/GitHub/Leo/leo-editor/dist" - but - should it not check for "/home/user/PyVE/GitHub/Leo/leo-editor/leo/dist" ?

What am I missing ?

With kind regards,

Viktor

Edward K. Ream

unread,
Jun 6, 2024, 8:40:29 AMJun 6
to leo-e...@googlegroups.com
On Mon, Jun 3, 2024 at 2:55 PM Viktor Ransmayr <viktor....@gmail.com> wrote:

* When I run the 'build_leo.py' script I immediately receive the following traceback:
[snip]
      File "/home/user/PyVE/GitHub/Leo/leo-editor/leo/scripts/build_leo.py", line 26, in <module>
        assert os.path.exists(dist_dir), dist_dir
    AssertionError: /home/user/PyVE/GitHub/Leo/leo-editor/dist
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$

Hmm. I guess this is a buglet.  Build devs should create a leo-editor/dist directory.

But it might create other difficulties if Leo's PyPi installer created the build directory.

Edward

Viktor Ransmayr

unread,
Jun 6, 2024, 12:29:03 PMJun 6
to leo-editor
Hello Edward,

Edward K. Ream schrieb am Donnerstag, 6. Juni 2024 um 14:40:29 UTC+2:
On Mon, Jun 3, 2024 at 2:55 PM Viktor Ransmayr <viktor....@gmail.com> wrote:

* When I run the 'build_leo.py' script I immediately receive the following traceback:
[snip]
      File "/home/user/PyVE/GitHub/Leo/leo-editor/leo/scripts/build_leo.py", line 26, in <module>
        assert os.path.exists(dist_dir), dist_dir
    AssertionError: /home/user/PyVE/GitHub/Leo/leo-editor/dist
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$

Hmm. I guess this is a buglet.  Build devs should create a leo-editor/dist directory.

I am not sure, that I understand your feedback completely ...

I was not relying / using the PyPI instance of Leo - but - the GitHub (devel branch) instance !

I  had expected, that I could follow the description from GH issue #3837 ( even if I am in a Linux environment).

Are there any pre-conditions for calling the 'build_leo.py' script, other than an up to date 'devel-branch' ?

With kind regards,

Viktor

Viktor Ransmayr

unread,
Jun 7, 2024, 5:56:44 AMJun 7
to leo-editor
Hello Edward,

Edward K. Ream schrieb am Donnerstag, 6. Juni 2024 um 14:40:29 UTC+2:
On Mon, Jun 3, 2024 at 2:55 PM Viktor Ransmayr <viktor....@gmail.com> wrote:

* When I run the 'build_leo.py' script I immediately receive the following traceback:
[snip]
      File "/home/user/PyVE/GitHub/Leo/leo-editor/leo/scripts/build_leo.py", line 26, in <module>
        assert os.path.exists(dist_dir), dist_dir
    AssertionError: /home/user/PyVE/GitHub/Leo/leo-editor/dist
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$

Hmm. I guess this is a buglet.  Build devs should create a leo-editor/dist directory.

This morning I re-read your feedback - and - understood that you did say: Leo's developer should create the 'leo-editor/dist' directory manually !

I did - but - ran into the next issue - See attached log:

###

    user@debian-leo-study-vm:~$
    user@debian-leo-study-vm:~$ cd PyVE/GitHub/Leo/
    user@debian-leo-study-vm:~/PyVE/GitHub/Leo$
    user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ source bin/activate
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo$
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ cd leo-editor/
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$ mkdir dist
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$ python3 -m leo.scripts.build_leo
    build_leo.py

    python -m build > build_log.txt

    /home/user/PyVE/GitHub/Leo/bin/python: No module named build
    See build_log.txt
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$

###

Should the GH issue #3837 be re-opened ?

With kind regards,

Viktor

Edward K. Ream

unread,
Jun 7, 2024, 8:15:18 AMJun 7
to leo-e...@googlegroups.com
On Fri, Jun 7, 2024 at 4:56 AM Viktor Ransmayr wrote:

> This morning I re-read your feedback - and - understood that you did say: Leo's developer should create the 'leo-editor/dist' directory manually !

I did - but - ran into the next issue: [build_log.txt doesn't exist].

> Should the GH issue #3837 be reopened ?

I have just amended the issue.  I added the section "Notes about the build environment".

Thanks for your help.

Edward

Viktor Ransmayr

unread,
Jun 7, 2024, 12:16:14 PMJun 7
to leo-editor
Hello Edward,

The amendment  does not make sense to me ...

The file 'build_log.txt' does exist & can be created. - See attached log:

###

    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$ python3 -m leo.scripts.build_leo
    build_leo.py

    python -m build > build_log.txt

    /home/user/PyVE/GitHub/Leo/bin/python: No module named build
    See build_log.txt
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$ ls -al build*
    -rw-r--r-- 1 user user 0 Jun  7 18:00 build_log.txt
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$ ls -al dist
    total 8
    drwxr-xr-x 2 user user 4096 Jun  7 18:00 .
    drwxr-xr-x 7 user user 4096 Jun  7 11:33 ..
    (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo/leo-editor$ 

###

IMO the problem is that the "leo-editor/dist" directory is empty !

With kind regards,

Viktor

Edward K. Ream

unread,
Jun 11, 2024, 5:10:05 AMJun 11
to leo-e...@googlegroups.com
On Fri, Jun 7, 2024 at 11:16 AM Viktor Ransmayr <viktor....@gmail.com> wrote:
Hello Edward,

Edward K. Ream schrieb am Freitag, 7. Juni 2024 um 14:15:18 UTC+2:
On Fri, Jun 7, 2024 at 4:56 AM Viktor Ransmayr wrote:

> This morning I re-read your feedback - and - understood that you did say: Leo's developer should create the 'leo-editor/dist' directory manually !

I did - but - ran into the next issue: [build_log.txt doesn't exist].

> Should the GH issue #3837 be reopened ?

I have just amended the issue.  I added the section "Notes about the build environment".

The amendment  does not make sense to me ...

The file 'build_log.txt' does exist & can be created. - See attached log:

I'm not concerned about such details for at least two reasons:

1. I only use Windows to create distributions.
2. I assume future build devs will be able to adjust their procedures to handle small glitches.

Edward

Viktor Ransmayr

unread,
Jun 12, 2024, 6:54:17 AMJun 12
to leo-editor
Hello Edward,

Fair enough !

I took the time & re-activated an old laptop with Windows 10 - but - it does not work there as well :-(

I fixed the first problem by adding the missing 'build' package to Leo's 'requirements.txt' file.

However the script still finishes with an error:

###

PS C:\Users\VR\Projects\leo-editor>
PS C:\Users\VR\Projects\leo-editor> python -m leo.scripts.build_leo

build_leo.py

python -m build > build_log.txt

error: package directory 'leo\doc\_static' does not exist
See build_log.txt
PS C:\Users\VR\Projects\leo-editor>
PS C:\Users\VR\Projects\leo-editor> cat build_log.txt
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
  - build>=1.0
  - setuptools>=61.0
* Getting build dependencies for sdist...
running egg_info
creating leo.egg-info
writing leo.egg-info\PKG-INFO
writing dependency_links to leo.egg-info\dependency_links.txt
writing entry points to leo.egg-info\entry_points.txt
writing requirements to leo.egg-info\requires.txt
writing top-level names to leo.egg-info\top_level.txt
writing manifest file 'leo.egg-info\SOURCES.txt'

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist
PS C:\Users\VR\Projects\leo-editor>

###

So I think it is fair to say, that at this point in time a distribution package for Leo can NOT be built by just using the content of the 'devel' branch on GitHub as is ...

I plan to follow up on my side after you have released Leo 6.8.0.

With kind regards,

Viktor

Edward K. Ream

unread,
Jun 12, 2024, 7:46:57 AMJun 12
to leo-e...@googlegroups.com
On Wed, Jun 12, 2024 at 5:54 AM Viktor Ransmayr <viktor....@gmail.com> wrote:

> I fixed the first problem by adding the missing 'build' package to Leo's 'requirements.txt' file.

Leo's users do not need "build", so adding "build" to requirements.txt isn't strictly necessary. Otoh, few would notice :-)

The "official/prissy" way would be to add extra requirements for build devs. Maybe in pyproject.toml.

> However the script still finishes with an error:
...
> So I think it is fair to say...a distribution package for Leo can NOT be built by just using the content of the 'devel' branch on GitHub...
> I plan to follow up on my side after you have released Leo 6.8.0.

Many thanks, Viktor, for your continued testing.

I'll add "build" to requirements.txt for 6.8.0 b1.

Edward

Edward K. Ream

unread,
Jun 12, 2024, 7:56:52 AMJun 12
to leo-editor
On Wednesday, June 12, 2024 at 6:46:57 AM UTC-5 Edward K. Ream wrote:

Many thanks, Viktor, for your continued testing.

I'll add "build" to requirements.txt for 6.8.0 b1.

Heh. I just did that, but python -m leo.scripts.build_leo failed:

C:\Python\Python3.12\python.exe:
No module named build.__main__;
'build' is a package and cannot be directly executed
See build_log.txt

It may be just the dreaded software rot, not a real build issue. I'll look into this today.

Edward

Edward K. Ream

unread,
Jun 12, 2024, 8:09:33 AMJun 12
to leo-editor
On Wednesday, June 12, 2024 at 6:56:52 AM UTC-5 Edward K. Ream wrote:

Heh. I just did that, but python -m leo.scripts.build_leo failed:

C:\Python\Python3.12\python.exe:
No module named build.__main__;
'build' is a package and cannot be directly executed
See build_log.txt

It may be just the dreaded software rot, not a real build issue. I'll look into this today.

It turned out that I didn't have "build" installed, as "pip list" confirmed. I don't have any idea why Python would issue the warning above!

Anyway, installing "build" worked for me. But there are complications that merit a new PR.  Coming soon.

Edward
Reply all
Reply to author
Forward
0 new messages