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

2022-08-18 Thread Chris Angelico
On Fri, 19 Aug 2022 at 10:07, Grant Edwards  wrote:
>
> On 2022-08-18, Chris Angelico  wrote:
> > On Fri, 19 Aug 2022 at 05:05, Grant Edwards  
> > wrote:
> >> On 2022-08-18, Chris Angelico  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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: setup.py + cython == chicken and the egg problem

2022-08-18 Thread Dan Stromberg
On Tue, Aug 16, 2022 at 2:03 PM Dan Stromberg  wrote:

> Hi folks.
>
> I'm attempting to package up a python package that uses Cython.
>
> Rather than build binaries for everything under the sun, I've been
> focusing on including the .pyx file and running cython on it at install
> time.  This requires a C compiler, but I'm OK with that.
>
> BTW, the pure python version works fine, and the cython version works too
> as long as you preinstall cython - but I don't want users to have to know
> that :)
>

For the actual chicken-and-egg problem, I'd needed to include my
pyproject.toml in my MANIFEST.in, like:
include pyx_treap.pyx pyx_treap.c pyproject.toml
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2022-08-18 Thread Grant Edwards
On 2022-08-18, Chris Angelico  wrote:
> On Fri, 19 Aug 2022 at 05:05, Grant Edwards  wrote:
>> On 2022-08-18, Chris Angelico  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


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem using cx_Freeze

2022-08-18 Thread subin
Hope you had a good time.

On Wed, Aug 17, 2022 at 10:19 PM Peter J. Holzer  wrote:

> 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
>
> --
>_  | Peter J. Holzer| Story must make more sense than reality.
> |_|_) ||
> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |   challenge!"
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UTF-8 and latin1

2022-08-18 Thread Chris Angelico
On Fri, 19 Aug 2022 at 08:15, Tobiah  wrote:
>
> > You configure the web server to send:
> >
> >  Content-Type: text/html; charset=...
> >
> > in the HTTP header when it serves HTML files.
>
> So how does this break down?  When a person enters
> Montréal, Quebéc into a form field, what are they
> doing on the keyboard to make that happen?  As the
> string sits there in the text box, is it latin1, or utf-8
> or something else?  How does the browser know what
> sort of data it has in that text box?
>

As it sits there in the text box, it is *a text string*.

When it gets sent to the server, the encoding is defined by the
browser (with reference to the server's specifications) and identified
in a request header.

The server should then receive that and interpret it as a text string.

Encodings should ONLY be relevant when data is stored in files or
transmitted across a network etc, and the rest of the time, just think
in Unicode.

Also - migrate to Python 3, your life will become a lot easier.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UTF-8 and latin1

2022-08-18 Thread Jon Ribbens via Python-list
On 2022-08-18, Tobiah  wrote:
>> You configure the web server to send:
>> 
>>  Content-Type: text/html; charset=...
>> 
>> in the HTTP header when it serves HTML files.
>
> So how does this break down?  When a person enters
> Montréal, Quebéc into a form field, what are they
> doing on the keyboard to make that happen?

It depends on what keybaord they have. Using a standard UK or US
("qwerty") keyboard and Windows you should be able to type "é" by
holding down the 'Alt' key to the right of the spacebar, and typing
'e'.  If they're using a French ("azerty") keyboard then I think they
can enter it by holding 'shift' and typing '2'.

> As the string sits there in the text box, is it latin1, or utf-8
> or something else?

That depends on which browser you're using. I think it's quite likely
it will use UTF-32 (i.e. fixed-width 32 bits per character).

> How does the browser know what sort of data it has in that text box?

It's a text box, so it knows it's text.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UTF-8 and latin1

2022-08-18 Thread Tobiah

You configure the web server to send:

 Content-Type: text/html; charset=...

in the HTTP header when it serves HTML files.


So how does this break down?  When a person enters
Montréal, Quebéc into a form field, what are they
doing on the keyboard to make that happen?  As the
string sits there in the text box, is it latin1, or utf-8
or something else?  How does the browser know what
sort of data it has in that text box?


--
https://mail.python.org/mailman/listinfo/python-list


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

2022-08-18 Thread Chris Angelico
On Fri, 19 Aug 2022 at 05:05, Grant Edwards  wrote:
>
> On 2022-08-18, Chris Angelico  wrote:
> > On Fri, 19 Aug 2022 at 04:19, David at Booomer  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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2022-08-18 Thread Grant Edwards
On 2022-08-18, Chris Angelico  wrote:
> On Fri, 19 Aug 2022 at 04:19, David at Booomer  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

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UTF-8 and latin1

2022-08-18 Thread Jon Ribbens via Python-list
On 2022-08-18, Tobiah  wrote:
>> Generally speaking browser submisisons were/are supposed to be sent
>> using the same encoding as the page, so if you're sending the page
>> as "latin1" then you'll see that a fair amount I should think. If you
>> send it as "utf-8" then you'll get 100% utf-8 back.
>
> The only trick I know is to use .  Would
> that 'send' the post as utf-8?  I always expected it had more
> to do with the way the user entered the characters.  How do
> they by the way, enter things like Montréal, Quebéc.  When they
> enter that into a text box on a web page can we say it's in
> a particular encoding at that time?  At submit time?

You configure the web server to send:

Content-Type: text/html; charset=...

in the HTTP header when it serves HTML files. Another way is to put:



or:



in the  section of your HTML document. The HTML "standard"
nowadays says that you are only allowed to use the "utf-8" encoding,
but if you use another encoding then browsers will generally use that
as both the encoding to use when reading the HTML file and the encoding
to use when submitting form data.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2022-08-18 Thread Chris Angelico
On Fri, 19 Aug 2022 at 04:19, David at Booomer  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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2022-08-18 Thread David at Booomer
From: Dennis Lee Bieber 
> 
> On Wed, 17 Aug 2022 12:09:14 -0600, David at Booomer 
> 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):

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
> scriptthe name of the file 
> containing the script
> which is to be frozen
> 
> ...
> 
> #11
> trademarksthe 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
>   wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
> 
...

> From: "Peter J. Holzer" 
> 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.bou...@ucdenver.edu or 

Re: UTF-8 and latin1

2022-08-18 Thread Jon Ribbens via Python-list
On 2022-08-17, Barry  wrote:
>> On 17 Aug 2022, at 18:30, Jon Ribbens via Python-list 
>>  wrote:
>> On 2022-08-17, Tobiah  wrote:
>>> I get data from various sources; client emails, spreadsheets, and
>>> data from web applications.  I find that I can do 
>>> some_string.decode('latin1')
>>> to get unicode that I can use with xlsxwriter,
>>> or put  in the header of a web page to display
>>> European characters correctly.  But normally UTF-8 is recommended as
>>> the encoding to use today.  latin1 works correctly more often when I
>>> am using data from the wild.  It's frustrating that I have to play
>>> a guessing game to figure out how to use incoming text.   I'm just wondering
>>> if there are any thoughts.  What if we just globally decided to use utf-8?
>>> Could that ever happen?
>> 
>> That has already been decided, as much as it ever can be. UTF-8 is
>> essentially always the correct encoding to use on output, and almost
>> always the correct encoding to assume on input absent any explicit
>> indication of another encoding. (e.g. the HTML "standard" says that
>> all HTML files must be UTF-8.)
>> 
>> If you are finding that your specific sources are often encoded with
>> latin-1 instead then you could always try something like:
>> 
>>try:
>>text = data.decode('utf-8')
>>except UnicodeDecodeError:
>>text = data.decode('latin-1')
>> 
>> (I think latin-1 text will almost always fail to be decoded as utf-8,
>> so this would work fairly reliably assuming those are the only two
>> encodings you see.)
>
> Only if a reserved byte is used in the string.
> It will often work in either.

Because it's actually ASCII and hence there's no difference between
interpreting it as utf-8 or iso-8859-1? In which case, who cares?

> For web pages it cannot be assumed that markup saying it’s utf-8 is
> correct. Many pages are I fact cp1252. Usually you find out because
> of a smart quote that is 0xa0 is cp1252 and illegal in utf-8.

Hence what I said above. But if a source explicitly states an encoding
and it's false then these days I see little need for sympathy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UTF-8 and latin1

2022-08-18 Thread Tobiah

Generally speaking browser submisisons were/are supposed to be sent
using the same encoding as the page, so if you're sending the page
as "latin1" then you'll see that a fair amount I should think. If you
send it as "utf-8" then you'll get 100% utf-8 back.


The only trick I know is to use .  Would
that 'send' the post as utf-8?  I always expected it had more
to do with the way the user entered the characters.  How do
they by the way, enter things like Montréal, Quebéc.  When they
enter that into a text box on a web page can we say it's in
a particular encoding at that time?  At submit time?

--
https://mail.python.org/mailman/listinfo/python-list


Re: UTF-8 and latin1

2022-08-18 Thread Jon Ribbens via Python-list
On 2022-08-17, Tobiah  wrote:
>> That has already been decided, as much as it ever can be. UTF-8 is
>> essentially always the correct encoding to use on output, and almost
>> always the correct encoding to assume on input absent any explicit
>> indication of another encoding. (e.g. the HTML "standard" says that
>> all HTML files must be UTF-8.)

> I got an email from a client with blast text that
> was in French with stuff like: Montréal, Quebéc.
> latin1 did the trick.

There's no accounting for the Québécois. They think they speak French.

> Also, whenever I get a spreadsheet from a client and save as .csv,
> or take browser data through PHP, it always seems to work with latin1,
> but not UTF-8.

That depends on how you "saved as .csv" and what you did with PHP.
Generally speaking browser submisisons were/are supposed to be sent
using the same encoding as the page, so if you're sending the page
as "latin1" then you'll see that a fair amount I should think. If you
send it as "utf-8" then you'll get 100% utf-8 back.
-- 
https://mail.python.org/mailman/listinfo/python-list