• Re: Problem using cx_Freeze > auto-py-to-exe

    From David at Booomer@21:1/5 to All on Thu Aug 18 12:17:25 2022
    From: Dennis Lee Bieber <wlfraed@ix.netcom.com>

    On Wed, 17 Aug 2022 12:09:14 -0600, David at Booomer <david@boomer.org> declaimed the following:

    executables=[
    Executable(
    "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py",
    "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py",
    "separete.py","speak.py",
    )
    ]
    )

    You are defining a list "executables" with only ONE member... (and is that really how you spelled "separate").

    Not my spelling, although I do have to be careful when typing that word.

    From before:
    "I’m trying to get LaTex-to-Speech (https://github.com/SGanesh19/LaTeX-to-Speech) to run as an accessibility aid, converting equations into speech. I haven’t used cx_Freeze before so stumbling somewhat."


    Searching for ‘__init__(' in the 13 *.py files returned five lines in two files (algorithm.py and prjui.py). As mentioned searching for this error only produced mention of adding self which is in these lines already. Previously I had search for __
    init__() which returned no lines due to the closing ).

    You are still searching the wrong place... The __init__() that is complaining is the one in cx_Freeze.Executable().

    I had visited the page you provided (https://cx-freeze.readthedocs.io/en/latest/setup_script.html#cx-freeze-executable) but didn’t noticed the 11 plus self as 12 arguments.

    Really? Please count (reformatted from cut&paste):

    I did count but hadn’t noticed this argument list before you mentioned it. However, I still don’t see any of these argument names in the Executable list or anywhere else.

    """
    argument name description

    #1
    script the name of the file containing the script
    which is to be frozen

    ...

    #11
    trademarks the trademarks value to include in the version
    resource associated with the executable (Windows only).
    """

    You are passing 13 .py file names. There are only two arguments that really want file names: script, and init_script. Most of the other
    arguments are either optional or Windows specific (#6-11).

    I suspect you need to pass JUST main.py or Maiui.py (based on casing) -- which ever is really the file you'd invoke to start the program running. I'd hope the freeze system then scans (recursively) that file to find anything imported, and include those in the final product.


    I tried passing just main.py or one of the others that might be a starting point but just got ’NoneType has no len()

    I was hoping to use someone else’s code to turn Latex equations into Speech. Maybe easier to just narrated each equation to create an audio file.

    Thanks for your suggestions Dennis. This was the first time I saw the possibility of creating a python executable.

    Then I searched for ‘python executable’ and found auto-py-to-exe and pyinstaller which I must/might explore later. First tries ran into PyQt4 to PyQt5 conversions. Good start at https://towardsdatascience.com/how-to-easily-convert-a-python-script-to-
    an-executable-file-exe-4966e253c7e9

    I might wait for the original author to respond to an issue I posted on GitHub.

    Thanks again. David

    --
    Wulfraed Dennis Lee Bieber AF6VN
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

    ...

    From: "Peter J. Holzer" <hjp-python@hjp.at>
    Subject: Re: Problem using cx_Freeze
    Date: August 17, 2022 at 3:17:27 PM MDT
    To: python-list@python.org

    On 2022-08-17 12:09:14 -0600, David at Booomer wrote:
    Executable(
    "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py",
    "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py",
    "separete.py","speak.py",
    )
    [...]
    I am/was worried about the trailing ‘,' after ',"speak.py”,’ <- but
    deleting it or moving it after the ] didn’t help.

    This has nothing to do with your problem but:

    Python allows a trailing comma in any comma-separated list of values. It
    will just be ignored.

    This is really common in modern programming languages (read: programming languages younger than 30 years or so), because it makes it much more convenient to extend/shorten/reorder a list. Otherwise you alway have to remember add or remove a comma in the right place. (Some people
    (especially SQL programmers for some reason) resorted to put the comma
    at the start of each line to get around this, which is really ugly.)

    hp

    The trailing , does make commenting out arguments easier but unexpected coming from ‘older’ languages. ;-)

    Thanks, Peter


    David Bourne, Ph.D., Associate Professor C/T
    Skaggs School of Pharmacy and Pharmaceutical Sciences, Mail Stop C238
    Aurora, CO 80045-2605
    Email: david.bourne@ucdenver.edu or david@boomer.org
    CV: http://www.boomer.org/db/CV.pdf
    My books and apps: https://www.pharmpk.com/MyeBooks.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Angelico@21:1/5 to David at Booomer on Fri Aug 19 04:23:59 2022
    On Fri, 19 Aug 2022 at 04:19, David at Booomer <david@boomer.org> wrote:
    This is really common in modern programming languages (read: programming languages younger than 30 years or so), because it makes it much more convenient to extend/shorten/reorder a list. Otherwise you alway have to remember add or remove a comma in the right place. (Some people
    (especially SQL programmers for some reason) resorted to put the comma
    at the start of each line to get around this, which is really ugly.)

    hp

    The trailing , does make commenting out arguments easier but unexpected coming from ‘older’ languages. ;-)


    It's one of the frustrations with JSON, since that format doesn't
    allow the trailing comma :)

    ChrisA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Grant Edwards@21:1/5 to Chris Angelico on Thu Aug 18 12:03:47 2022
    On 2022-08-18, Chris Angelico <rosuav@gmail.com> wrote:
    On Fri, 19 Aug 2022 at 04:19, David at Booomer <david@boomer.org> wrote:

    The trailing , does make commenting out arguments easier but
    unexpected coming from ‘older’ languages. ;-)

    It's one of the frustrations with JSON, since that format doesn't
    allow the trailing comma :)

    Yep, that's a constant, low-level pain for all the C code I deal with
    which generates JSON. You'd think after 10+ years of maintaining code
    that outputs JSON, I wouldn't trip over that any longer...

    --
    Grant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Angelico@21:1/5 to Grant Edwards on Fri Aug 19 06:59:21 2022
    On Fri, 19 Aug 2022 at 05:05, Grant Edwards <grant.b.edwards@gmail.com> wrote:

    On 2022-08-18, Chris Angelico <rosuav@gmail.com> wrote:
    On Fri, 19 Aug 2022 at 04:19, David at Booomer <david@boomer.org> wrote:

    The trailing , does make commenting out arguments easier but
    unexpected coming from ‘older’ languages. ;-)

    It's one of the frustrations with JSON, since that format doesn't
    allow the trailing comma :)

    Yep, that's a constant, low-level pain for all the C code I deal with
    which generates JSON. You'd think after 10+ years of maintaining code
    that outputs JSON, I wouldn't trip over that any longer...


    With some JSON files, I just cheat and define a shim at the end of arrays...

    https://raw.githubusercontent.com/Rosuav/MustardMine/master/template.json

    ChrisA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Grant Edwards@21:1/5 to Chris Angelico on Thu Aug 18 17:05:43 2022
    On 2022-08-18, Chris Angelico <rosuav@gmail.com> wrote:
    On Fri, 19 Aug 2022 at 05:05, Grant Edwards <grant.b.edwards@gmail.com> wrote:
    On 2022-08-18, Chris Angelico <rosuav@gmail.com> wrote:

    It's one of the frustrations with JSON, since that format doesn't
    allow the trailing comma :)

    Yep, that's a constant, low-level pain for all the C code I deal with
    which generates JSON. You'd think after 10+ years of maintaining code
    that outputs JSON, I wouldn't trip over that any longer...

    With some JSON files, I just cheat and define a shim at the end of arrays...

    https://raw.githubusercontent.com/Rosuav/MustardMine/master/template.json

    That's OK if it's strictly internal. Almost all of the JSON data I
    work with is part of published APIs — many of which are defined by
    industry consortiums or corporate-wide "standards".

    --
    Grant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Angelico@21:1/5 to Grant Edwards on Fri Aug 19 10:35:17 2022
    On Fri, 19 Aug 2022 at 10:07, Grant Edwards <grant.b.edwards@gmail.com> wrote:

    On 2022-08-18, Chris Angelico <rosuav@gmail.com> wrote:
    On Fri, 19 Aug 2022 at 05:05, Grant Edwards <grant.b.edwards@gmail.com> wrote:
    On 2022-08-18, Chris Angelico <rosuav@gmail.com> wrote:

    It's one of the frustrations with JSON, since that format doesn't
    allow the trailing comma :)

    Yep, that's a constant, low-level pain for all the C code I deal with
    which generates JSON. You'd think after 10+ years of maintaining code
    that outputs JSON, I wouldn't trip over that any longer...

    With some JSON files, I just cheat and define a shim at the end of arrays...

    https://raw.githubusercontent.com/Rosuav/MustardMine/master/template.json

    That's OK if it's strictly internal. Almost all of the JSON data I
    work with is part of published APIs — many of which are defined by
    industry consortiums or corporate-wide "standards".


    That's an export/import format that I defined, so I mandated (a) that
    there's an empty-string key as a signature (on import, it can be
    anywhere, but on export, it's that final shim), and (b) all arrays are
    allowed to have an empty string at the end, which is ignored on
    import. Saves so much trouble.

    That particular export format is actually designed as a git-managed
    config file as well, which is why the line breaks are done the way
    they are (anything on a single line is intended to be added/removed as
    a single unit), which is why I definitely don't want the "add a comma
    to the previous line" deltas.

    "Strictly internal" is a subset of "protocols/standards that you are
    in control of". :)

    ChrisA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dennis Lee Bieber@21:1/5 to All on Thu Aug 18 21:54:36 2022
    On Thu, 18 Aug 2022 12:17:25 -0600, David at Booomer <david@boomer.org> declaimed the following:


    I did count but hadn’t noticed this argument list before you mentioned it. However, I still don’t see any of these argument names in the Executable list or anywhere else.


    It's your responsibility to provide them when you called Executable(). As I said, you are (were?) providing a whole bunch of .py files, which were being mapped to these arguments.


    """
    argument name description

    #1
    script the name of the file containing the script
    which is to be frozen

    prjui.py

    #2
    init_script the name of the initialization script that will
    be executed before the actual script is executed; this script is used to
    set up the environment for the executable; if a name is given without an >absolute path the names of files in the initscripts subdirectory of the >cx_Freeze package is searched

    Maiui.py

    #3
    base the name of the base executable; if a name is
    given without an absolute path the names of files in the bases subdirectory >of the cx_Freeze package is searched

    about.py

    #4
    target_name the name of the target executable; the default
    value is the name of the script; the extension is optional (automatically >added on Windows); support for names with version; if specified a pathname, >raise an error.

    dict.py

    #5
    icon name of icon which should be included in the
    executable itself on Windows or placed in the target directory for other >platforms (ignored in Microsoft Store Python app)

    geometry.py

    #6
    manifest name of manifest which should be included in
    the executable itself (Windows only - ignored by Python app from Microsoft >Store)

    getEquation.py

    #7
    uac-admin creates a manifest for an application that will
    request elevation (Windows only - ignored by Python app from Microsoft
    Store)

    gtrail.py

    #8
    shortcut_name the name to give a shortcut for the executable
    when included in an MSI package (Windows only).

    main.py

    #9
    shortcut_dir the directory in which to place the
    shortcut when being installed by an MSI package; see the MSI Shortcut table >documentation for more information on what values can be placed here
    (Windows only).

    matchingstring.py

    #10
    copyright the copyright value to include in the version
    resource associated with executable (Windows only).

    producelatex.py

    #11
    trademarks the trademarks value to include in the version
    resource associated with the executable (Windows only).

    readfile.py

    and
    separete.py
    speak.py
    are not mapped to anything, hence the too-many arguments error.
    """

    As you can see, a lot of those don't even fit with the data type of the argument.

    I tried passing just main.py or one of the others that might be a starting point but just got ’NoneType has no len()

    What did the traceback say? Just reporting the last line message is meaningless.

    Then I searched for ‘python executable’ and found auto-py-to-exe and pyinstaller which I must/might explore later. First tries ran into PyQt4 to PyQt5 conversions. Good start at https://towardsdatascience.com/how-to-easily-convert-a-python-script-to-
    an-executable-file-exe-4966e253c7e9


    Note that pretty much all such python->executable scheme is just making an archive of the required Python source files, and packaging the core of
    the Python interpreter is such a way that running this archive is simply extracting the source files and running the packaged Python interpreter
    with them.


    --
    Wulfraed Dennis Lee Bieber AF6VN
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)