My first attempt at a package.

2022-07-19 Thread Antoon Pardon

I am writing a python package which has the following structure

PACKAGE
   * module1.py
   * module2.py
   * data.cfg

However the data.cfg should be build at installation time.

Can someone give advise on which packaging tool and how
to use it, to accomplisch this.

e.g. de data config.cfg should be build with the following linix command:

$ date '+installed on %Y:%M:%d at %T' > data.cfg

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


Re: My first attempt at a package.

2022-07-19 Thread David Lowry-Duda

On Tue, Jul 19, 2022 at 03:58:41PM +0200, Antoon Pardon wrote:

I am writing a python package which has the following structure

PACKAGE
   * module1.py
   * module2.py
   * data.cfg

However the data.cfg should be build at installation time.

Can someone give advise on which packaging tool and how
to use it, to accomplisch this.


A lot of good packaging information can be found at

https://packaging.python.org/en/latest/

and in particular at

https://packaging.python.org/en/latest/tutorials/packaging-projects/

and

https://packaging.python.org/en/latest/overview/

There are a couple of different ways to handle python packaging, and it 
can be a bit confusing. But following the tutorial on packaging is a 
good start.


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


Pip upgrade causing issues in 3.10

2022-07-19 Thread David Raymond
So after a long while I'm finally getting around to upgrading to 3.10 on 
Windows from 3.9, and my first pip upgrade is causing issues with the 
installation.

Problem seems to be that I run pip from a command prompt in the Scripts folder, 
and it seems pip is trying to completely remove the Scripts folder, which it 
can't because the command prompt is in that folder. It successfully removes the 
old installation of pip before dying, leaving you without a pip to run. (Yay 
for ensurepip) It also creates a ~ripts folder in the main Python folder, and a 
few ~ip folders in the site-packages folder before it dies, which then cause 
warnings to be issued by pip from then on (or at least until you go and delete 
those folders)

Upgrading pip this way worked fine in 3.9.x, so I'm curious as to why the 
change for 3.10? And is there a chance to go back to it not trying to 
completely remove that Scripts folder? Or at least have it fail a little more 
gracefully without creating all those ~ folders? Maybe add a hint about 
ensurepip when it removes the old and can't install the new?

For those who will say just change how you update it: I can do that going 
forward, yes.
But nonetheless, running it like this probably shouldn't leave me without a 
pip, and with extra junk folders.



Fresh install here of 3.10.5. For all users, not including the py launcher 
thing. Below is running in an Admin Command Prompt.


C:\Program Files\Python310\Scripts>pip list
PackageVersion
-- ---
pip22.0.4
setuptools 58.1.0
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the 'C:\Program Files\Python310\python.exe -m 
pip install --upgrade pip' command.

C:\Program Files\Python310\Scripts>..\python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in c:\program 
files\python310\lib\site-packages (22.0.4)
Collecting pip
  Using cached pip-22.1.2-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
ERROR: Could not install packages due to an OSError: [WinError 32] The process 
cannot access the file because it is being used by another process: 
'c:\\program files\\python310\\scripts\\'
Consider using the `--user` option or check the permissions.


At this point the Scripts folder is completely empty, there's a ~ripts folder 
in the main python310 folder, and a few ~ip... folders in the site-packages 
folder


C:\Program Files\Python310\Scripts>..\python.exe -m ensurepip
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
Looking in links: c:\Users\usernamehere\AppData\Local\Temp\tmpt48ibdf3
Requirement already satisfied: setuptools in c:\program 
files\python310\lib\site-packages (58.1.0)
Processing 
c:\users\usernamehere\appdata\local\temp\tmpt48ibdf3\pip-22.0.4-py3-none-any.whl
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
Installing collected packages: pip
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
Successfully installed pip-22.0.4

C:\Program Files\Python310\Scripts>cd..

C:\Program Files\Python310>python.exe -m pip install -U pip
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
Requirement already satisfied: pip in c:\program 
files\python310\lib\site-packages (22.0.4)
Collecting pip
  Using cached pip-22.1.2-py3-none-any.whl (2.1 MB)
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
Installing collected packages: pip
  Attempting uninstall: pip
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
  Successfully uninstalled pip-22.0.4
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
Successfully installed pip-22.1.2
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)

C:\Program Files\Python310>cd Scripts

C:\Program Files\Python310\Scripts>pip list
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
PackageVersion
-- ---
pip22.1.2
setuptools 58.1.0
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\program 
files\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\program 
files\pytho

Are there any benefits of a shared build python, compared to a static build python?

2022-07-19 Thread Tianhe
Python by default builds the library `libpythonMAJOR.MINOR.a` and
statically links it into the interpreter. Also it has an `--enable-shared`,
(https://docs.python.org/3/using/configure.html#cmdoption-enable-shared)
flag, which will build a shared library `libpythonMAJOR.MINOR.so.1.0`, and
dynamically link it to the interpreter.

Are there any benefits of a shared build python, compared to a static build
python? Is there any performance difference?

I found a related question on SO and is it like he said (
https://stackoverflow.com/a/73035776/5983841), shared built vs statically
built python only affects the "Embedding Python in Another Application"
scenario ?

--

Regards,

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


Re: Pip upgrade causing issues in 3.10

2022-07-19 Thread Mike Dewhirst

On 20/07/2022 4:43 am, David Raymond wrote:

C:\Program Files\Python310\Scripts>..\python.exe -m pip install --upgrade pip
ERROR: Could not install packages due to an OSError: [WinError 32] The process 
cannot access the file because it is being used by another process: 
'c:\\program files\\python310\\scripts\\'
There's your problem. The 'other' process is your cmd.exe within which 
you are typing etc.


Python scripts dir should be on the path so you don't have to execute 
anything from within it. Windows is obviously tripping over its own toes 
trying to delete and install something in the same dir while you also 
have your foot in it.


M

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.



OpenPGP_signature
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list