Re: Windows installer from python source code without access to source code

2023-04-06 Thread Eryk Sun
On 4/6/23, Jim Schwartz  wrote:
> Never mind.  I found it on the web.  I needed to point my PYTHONPATH to
> sitepackages:

In most cases an application should be isolated from PYTHON*
environment variables. If you're creating a Python application or
embedding Python in an application, use the embeddable distribution,
and add any additional required sys.path directories to the included
"._pth" file (e.g. "python311._pth").

https://docs.python.org/3/library/sys_path_init.html#pth-files
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Windows installer from python source code without access to source code

2023-04-06 Thread Jim Schwartz
Never mind.  I found it on the web.  I needed to point my PYTHONPATH to 
sitepackages:  
https://stackoverflow.com/questions/56857449/importerror-after-cython-embed


-Original Message-
From: Python-list  On 
Behalf Of Jim Schwartz
Sent: Thursday, April 6, 2023 2:50 PM
To: 'Barry' 
Cc: python-list@python.org
Subject: RE: Windows installer from python source code without access to source 
code

I downloaded VS community 2022 and I know how to access the developer command 
prompt.  I'm using the one called x64 Native Tools Command Prompt for VS 2022

I ran a command to compile my python code that was converted to c with the 
following command:

H:\Users\LindaJim\Documents\SourceCode\Software\aws_pc_backup\src\c>cl /O2 
/I"C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\include\\" 
aws_pc_backup.c 
C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\libs\\python311.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32216.1 for x64 Copyright 
(C) Microsoft Corporation.  All rights reserved.

aws_pc_backup.c
Microsoft (R) Incremental Linker Version 14.35.32216.1 Copyright (C) Microsoft 
Corporation.  All rights reserved.

/out:aws_pc_backup.exe
aws_pc_backup.obj
C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\libs\\python311.lib
   Creating library aws_pc_backup.lib and object aws_pc_backup.exp

When I ran the program, I got this, though.  Obviously, it doesn't know about 
the requests package.  Do I have to link something in with the executable?

H:\Users\LindaJim\Documents\SourceCode\Software\aws_pc_backup\src\c>aws_pc_backup.exe
 -m:lb Traceback (most recent call last):
  File "src\\python\\aws_pc_backup_main.py", line 7, in init 
python.aws_pc_backup_main
ModuleNotFoundError: No module named 'requests'





-Original Message-
From: Barry 
Sent: Tuesday, April 4, 2023 1:25 PM
To: Jim Schwartz 
Cc: Eryk Sun ; python-list@python.org
Subject: Re: Windows installer from python source code without access to source 
code



> On 4 Apr 2023, at 16:28, Jim Schwartz  wrote:
> 
> Where can I download that cl program?  I've used gcc before, but I hear that 
> cl can use a setup.py program to run the compile and link and create a 
> windows .msi installer.  Is that true?  

It is part of visual studio C++.
Once you have that installed there are bat files that setup environment in the 
terminal.
Then you can use cl, nmake etc

Barry
> 
> -Original Message-
> From: Eryk Sun 
> Sent: Friday, March 31, 2023 12:55 PM
> To: Jim Schwartz 
> Cc: python-list@python.org
> Subject: Re: Windows installer from python source code without access 
> to source code
> 
>> On 3/31/23, Jim Schwartz  wrote:
>> I want a windows installer to install my application that's written 
>> in python, but I don't want the end user to have access to my source code.
> 
> Cython can compile a script to C source code for a module or executable 
> (--embed). The source can be compiled and linked normally.
> For example, the following builds a "hello.exe" executable based on a 
> "hello.py" script.
> 
>> cython -3 --embed hello.py
>> set "PYI=C:\Program Files\Python311\include"
>> set "PYL=C:\Program Files\Python311\libs"
>> cl /I"%PYI%" hello.c /link /libpath:"%PYL%"
>> copy hello.exe embed
>> embed\hello.exe
>Hello, World!
> 
> I extracted the complete embeddable distribution of Python 3.11 into the 
> "embed" directory. You can reduce the size of the installation, if needed, by 
> minimizing the zipped standard library and removing pyd extensions and DLLs 
> that your application doesn't use.
> 
> The generated "hello.c" is large and not particularly easy to read, but here 
> are some snippets [...]:
> 
>[...]
>/* Implementation of 'hello' */
>static PyObject *__pyx_builtin_print;
>static const char __pyx_k_main[] = "__main__";
>static const char __pyx_k_name[] = "__name__";
>static const char __pyx_k_test[] = "__test__";
>static const char __pyx_k_print[] = "print";
>static const char __pyx_k_Hello_World[] = "Hello, World!";
>[...]
>  /* "hello.py":1
> * print("Hello, World!") # <<
> */
>  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Hello_World);
>if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 1, __pyx_L1_error)
>[...]
>  /* "hello.py":1
> * print("Hello, World!") # <<
> */
>  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple_,
>  NULL);
>if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
>[...]
>int wmain(int argc, wchar_t **argv) {
>[...]
>if (argc && argv)
>Py_SetProgramName(argv[0]);
>Py_Initialize();
>if (argc && argv)
>PySys_SetArgv(argc, argv);
>[...]
>  m = PyInit_hello();
>[...]
>if (Py_FinalizeEx() < 0)
>return 2;
>[...]
>return 0;
>[...]
> 
> --
> https://ma

Re: Windows installer from python source code without access to source code

2023-04-06 Thread MRAB

On 2023-04-06 23:14, Jim Schwartz wrote:

Could someone please help Carlos?  I’m not sure how to answer his
question

Sent from my iPhone

  On Apr 6, 2023, at 3:53 PM, Carlos Fulqueris  wrote:

  
  Hello Jim,
  How can I unsubscribe to this email list?
  I'm waiting for your response.
  Thanks
  Carlos

[snip]
At the bottom of the post is a link to the page that explains how to 
unsubscribe. It's the link:



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


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


Re: Windows installer from python source code without access to source code

2023-04-06 Thread Jim Schwartz
   Could someone please help Carlos?  I’m not sure how to answer his
   question 

   Sent from my iPhone

 On Apr 6, 2023, at 3:53 PM, Carlos Fulqueris  wrote:

 
 Hello Jim,
 How can I unsubscribe to this email list?
 I'm waiting for your response.
 Thanks
 Carlos
 El jue, 6 abr 2023 a las 16:52, Jim Schwartz
 (<[1]jsch...@sbcglobal.net>) escribió:

   I downloaded VS community 2022 and I know how to access the developer
   command prompt.  I'm using the one called x64 Native Tools Command
   Prompt for VS 2022

   I ran a command to compile my python code that was converted to c with
   the following command:

   H:\Users\LindaJim\Documents\SourceCode\Software\aws_pc_backup\src\c>cl
   /O2
   
/I"C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\include\\"
   aws_pc_backup.c
   
C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\libs\\python311.lib
   Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32216.1 for x64
   Copyright (C) Microsoft Corporation.  All rights reserved.

   aws_pc_backup.c
   Microsoft (R) Incremental Linker Version 14.35.32216.1
   Copyright (C) Microsoft Corporation.  All rights reserved.

   /out:aws_pc_backup.exe
   aws_pc_backup.obj
   
C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\libs\\python311.lib
      Creating library aws_pc_backup.lib and object aws_pc_backup.exp

   When I ran the program, I got this, though.  Obviously, it doesn't
   know about the requests package.  Do I have to link something in with
   the executable?

   
H:\Users\LindaJim\Documents\SourceCode\Software\aws_pc_backup\src\c>aws_pc_backup.exe
   -m:lb
   Traceback (most recent call last):
     File "src\\python\\aws_pc_backup_main.py", line 7, in init
   python.aws_pc_backup_main
   ModuleNotFoundError: No module named 'requests'

   -Original Message-
   From: Barry <[2]ba...@barrys-emacs.org>
   Sent: Tuesday, April 4, 2023 1:25 PM
   To: Jim Schwartz <[3]jsch...@sbcglobal.net>
   Cc: Eryk Sun <[4]eryk...@gmail.com>; [5]python-list@python.org
   Subject: Re: Windows installer from python source code without access
   to source code

   > On 4 Apr 2023, at 16:28, Jim Schwartz <[6]jsch...@sbcglobal.net>
   wrote:
   >
   > Where can I download that cl program?  I've used gcc before, but I
   hear that cl can use a setup.py program to run the compile and link
   and create a windows .msi installer.  Is that true? 

   It is part of visual studio C++.
   Once you have that installed there are bat files that setup
   environment in the terminal.
   Then you can use cl, nmake etc

   Barry
   >
   > -Original Message-
   > From: Eryk Sun <[7]eryk...@gmail.com>
   > Sent: Friday, March 31, 2023 12:55 PM
   > To: Jim Schwartz <[8]jsch...@sbcglobal.net>
   > Cc: [9]python-list@python.org
   > Subject: Re: Windows installer from python source code without
   access
   > to source code
   >
   >> On 3/31/23, Jim Schwartz <[10]jsch...@sbcglobal.net> wrote:
   >> I want a windows installer to install my application that's written
   >> in python, but I don't want the end user to have access to my
   source code.
   >
   > Cython can compile a script to C source code for a module or
   executable (--embed). The source can be compiled and linked normally.
   > For example, the following builds a "hello.exe" executable based on
   a "hello.py" script.
   >
   >> cython -3 --embed hello.py
   >> set "PYI=C:\Program Files\Python311\include"
   >> set "PYL=C:\Program Files\Python311\libs"
   >> cl /I"%PYI%" hello.c /link /libpath:"%PYL%"
   >> copy hello.exe embed
   >> embed\hello.exe
   >    Hello, World!
   >
   > I extracted the complete embeddable distribution of Python 3.11 into
   the "embed" directory. You can reduce the size of the installation, if
   needed, by minimizing the zipped standard library and removing pyd
   extensions and DLLs that your application doesn't use.
   >
   > The generated "hello.c" is large and not particularly easy to read,
   but here are some snippets [...]:
   >
   >    [...]
   >    /* Implementation of 'hello' */
   >    static PyObject *__pyx_builtin_print;
   >    static const char __pyx_k_main[] = "__main__";
   >    static const char __pyx_k_name[] = "__name__";
   >    static const char __pyx_k_test[] = "__test__";
   >    static const char __pyx_k_print[] = "print";
   >    static const char __pyx_k_Hello_World[] = "Hello, World!";
   >    [...]
   >      /* "hello.py":1
   >     * print("Hello, World!")             # <<
   >     */
   >      __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u

RE: Windows installer from python source code without access to source code

2023-04-06 Thread Jim Schwartz
I downloaded VS community 2022 and I know how to access the developer command 
prompt.  I'm using the one called x64 Native Tools Command Prompt for VS 2022

I ran a command to compile my python code that was converted to c with the 
following command:

H:\Users\LindaJim\Documents\SourceCode\Software\aws_pc_backup\src\c>cl /O2 
/I"C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\include\\" 
aws_pc_backup.c 
C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\libs\\python311.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32216.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

aws_pc_backup.c
Microsoft (R) Incremental Linker Version 14.35.32216.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:aws_pc_backup.exe
aws_pc_backup.obj
C:\\Users\\jschw\\AppData\\Local\\Programs\\Python\\Python3112\\libs\\python311.lib
   Creating library aws_pc_backup.lib and object aws_pc_backup.exp

When I ran the program, I got this, though.  Obviously, it doesn't know about 
the requests package.  Do I have to link something in with the executable?

H:\Users\LindaJim\Documents\SourceCode\Software\aws_pc_backup\src\c>aws_pc_backup.exe
 -m:lb
Traceback (most recent call last):
  File "src\\python\\aws_pc_backup_main.py", line 7, in init 
python.aws_pc_backup_main
ModuleNotFoundError: No module named 'requests'





-Original Message-
From: Barry  
Sent: Tuesday, April 4, 2023 1:25 PM
To: Jim Schwartz 
Cc: Eryk Sun ; python-list@python.org
Subject: Re: Windows installer from python source code without access to source 
code



> On 4 Apr 2023, at 16:28, Jim Schwartz  wrote:
> 
> Where can I download that cl program?  I've used gcc before, but I hear that 
> cl can use a setup.py program to run the compile and link and create a 
> windows .msi installer.  Is that true?  

It is part of visual studio C++.
Once you have that installed there are bat files that setup environment in the 
terminal.
Then you can use cl, nmake etc

Barry
> 
> -Original Message-
> From: Eryk Sun 
> Sent: Friday, March 31, 2023 12:55 PM
> To: Jim Schwartz 
> Cc: python-list@python.org
> Subject: Re: Windows installer from python source code without access 
> to source code
> 
>> On 3/31/23, Jim Schwartz  wrote:
>> I want a windows installer to install my application that's written 
>> in python, but I don't want the end user to have access to my source code.
> 
> Cython can compile a script to C source code for a module or executable 
> (--embed). The source can be compiled and linked normally.
> For example, the following builds a "hello.exe" executable based on a 
> "hello.py" script.
> 
>> cython -3 --embed hello.py
>> set "PYI=C:\Program Files\Python311\include"
>> set "PYL=C:\Program Files\Python311\libs"
>> cl /I"%PYI%" hello.c /link /libpath:"%PYL%"
>> copy hello.exe embed
>> embed\hello.exe
>Hello, World!
> 
> I extracted the complete embeddable distribution of Python 3.11 into the 
> "embed" directory. You can reduce the size of the installation, if needed, by 
> minimizing the zipped standard library and removing pyd extensions and DLLs 
> that your application doesn't use.
> 
> The generated "hello.c" is large and not particularly easy to read, but here 
> are some snippets [...]:
> 
>[...]
>/* Implementation of 'hello' */
>static PyObject *__pyx_builtin_print;
>static const char __pyx_k_main[] = "__main__";
>static const char __pyx_k_name[] = "__name__";
>static const char __pyx_k_test[] = "__test__";
>static const char __pyx_k_print[] = "print";
>static const char __pyx_k_Hello_World[] = "Hello, World!";
>[...]
>  /* "hello.py":1
> * print("Hello, World!") # <<
> */
>  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Hello_World);
>if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 1, __pyx_L1_error)
>[...]
>  /* "hello.py":1
> * print("Hello, World!") # <<
> */
>  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple_,
>  NULL);
>if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
>[...]
>int wmain(int argc, wchar_t **argv) {
>[...]
>if (argc && argv)
>Py_SetProgramName(argv[0]);
>Py_Initialize();
>if (argc && argv)
>PySys_SetArgv(argc, argv);
>[...]
>  m = PyInit_hello();
>[...]
>if (Py_FinalizeEx() < 0)
>return 2;
>[...]
>return 0;
>[...]
> 
> --
> https://mail.python.org/mailman/listinfo/python-list
> 

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