> On 4 Apr 2023, at 16:28, Jim Schwartz <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 <eryk...@gmail.com> > Sent: Friday, March 31, 2023 12:55 PM > To: Jim Schwartz <jsch...@sbcglobal.net> > Cc: python-list@python.org > Subject: Re: Windows installer from python source code without access to > source code > >> On 3/31/23, Jim Schwartz <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_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