ppa-dev-tools creates __pycache__/sitecustomize.cpython-310.pyc if sitecustomize.py exists in current directory

Bug #2068011 reported by Adrien Nader

This bug report will be marked for expiration in 15 days if no further activity occurs. (find out why)

6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ppa-dev-tools
Incomplete
Undecided
Unassigned

Bug Description

Hi,

If a "sitecustomize.py" file is present in the current directory, running ppa-dev-tools will create __pycache__/sitecustomize.cpython-310.pyc and this can cause issues with dpkg-source which will complain about the new file.

I am using the snap:

  ppa-dev-tools 0.6.0 74 latest/edge bryce-harrington -

I cannot tell if other files trigger similar behaviour as I was not able to strace without affecting the process, maybe as I had to run it as root (strace would show nothing related to sitecustomize).

Adrien Nader (adrien)
summary: ppa-dev-tools creates __pycache__/sitecustomize.cpython-310.pyc if
- sitecustomize.py exists
+ sitecustomize.py exists in current directory
Revision history for this message
Bryce Harrington (bryce) wrote :

Hi Adrien,

That does sound annoying, however I'm not sure how to reproduce it. I tried:

stirling: /tmp$ mkdir lp2068011
stirling: /tmp$ cd lp2068011/
stirling: /tmp/lp2068011$ touch sitecustomize.py
stirling: /tmp/lp2068011$ sudo snap install ppa-dev-tools
[sudo] password for bryce:
ppa-dev-tools 0.5.0 from Bryce Harrington installed
stirling: /tmp/lp2068011$ /snap/bin/ppa create lp2068011-test
The authorization page:
 (https://launchpad.net/+authorize-token?oauth_token=Rs4jdBN3hCgv0GDrVQwD&allow_permission=DESKTOP_INTEGRATION)
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.
Waiting to hear from Launchpad about your decision...
PPA 'lp2068011-test' created for the following architectures:

  i386, amd64, armhf, ppc64el, s390x, arm64, powerpc

The PPA can be viewed at:

  https://launchpad.net/~bryce/+archive/ubuntu/lp2068011-test

You can upload packages to this PPA using:

  dput ppa:bryce/lp2068011-test <source.changes>

Wait for the uploads to build and publish using:

  ppa wait ppa:bryce/lp2068011-test

To add the repository and to your system:

  sudo add-apt-repository -yus {the_ppa.address}
  sudo apt-get install <package(s)>
stirling: /tmp/lp2068011$

Offhand, it's not obvious what in ppa-dev-tools would trigger that kind of behavior. Can you try reproducing it some different ways to see if you can narrow down where the error is coming in?

Changed in ppa-dev-tools:
status: New → Incomplete
Revision history for this message
Adrien Nader (adrien) wrote :
Download full text (3.4 KiB)

Hi Bryce,

Sorry: I wasn't clear about how to reproduce!

I've been doing it exactly the way you've tried: "touch sitecustomize.py".

Using "snap run --strace":

  % rm -rf strace.log* __pycache__
  % snap run --strace='-tt -f -o strace.log -s 128' ppa-dev-tools.ppa &>/dev/null
  % grep sitecustomize strace.log.*

Do you get anything from grep?

I tried with 0.5.0 too and I experience the same thing.

For reference, an excerpt of strace's output here:

09:46:50.267472 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/local/lib/python3.10/dist-packages", 0x7ffe08010150, 0) = -1 ENOENT (No such file or directory)
09:46:50.267497 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3/dist-packages", 0x7ffe08010150, 0) = -1 ENOENT (No such file or directory)
09:46:50.267519 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3.10/dist-packages", 0x7ffe08010150, 0) = -1 ENOENT (No such file or directory)
09:46:50.267566 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3.10/site-packages", {st_mode=S_IFDIR|0755, st_size=308, ...}, 0) = 0
09:46:50.267599 openat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3.10/site-packages", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
09:46:50.267620 newfstatat(3, "", {st_mode=S_IFDIR|0755, st_size=308, ...}, AT_EMPTY_PATH) = 0
09:46:50.267643 getdents64(3, 0x64f361297d60 /* 13 entries */, 32768) = 480
09:46:50.267665 getdents64(3, 0x64f361297d60 /* 0 entries */, 32768) = 0
09:46:50.267683 close(3) = 0
09:46:50.267711 openat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3.10/site-packages/distutils-precedence.pth", O_RDONLY|O_CLOEXEC) = 3
09:46:50.267733 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=151, ...}, AT_EMPTY_PATH) = 0
09:46:50.267753 ioctl(3, TCGETS, 0x7ffe0800fde0) = -1 ENOTTY (Inappropriate ioctl for device)
09:46:50.267776 lseek(3, 0, SEEK_CUR) = 0
09:46:50.267795 ioctl(3, TCGETS, 0x7ffe080100b0) = -1 ENOTTY (Inappropriate ioctl for device)
09:46:50.267821 read(3, "import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distuti"..., 8192) = 151
09:46:50.267894 read(3, "", 8192) = 0
09:46:50.267917 close(3) = 0
09:46:50.267937 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/local/lib/python3.10/dist-packages", 0x7ffe08010330, 0) = -1 ENOENT (No such file or directory)
09:46:50.267960 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3/dist-packages", 0x7ffe08010330, 0) = -1 ENOENT (No such file or directory)
09:46:50.267980 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3.10/dist-packages", 0x7ffe08010330, 0) = -1 ENOENT (No such file or directory)
09:46:50.268041 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/lib/python3.10/site-packages", {st_mode=S_IFDIR|0755, st_size=308, ...}, 0) = 0
09:46:50.268073 newfstatat(AT_FDCWD, "/snap/ppa-dev-tools/74/usr/lib/python3/dist-packages", {st_mode=S_IFDIR|0755, st_size=1686, ...}, 0) = 0
09:46:50.268100 newfstatat(AT_FDCWD, "/home/adrien/public/ubuntu/t/t", {st_mode=S_IFDIR|0775, st_size=4096, ...}, 0) = 0
09:46:50.268126 newfstatat(AT_FDCWD, "/home/adrien/public/ubuntu/t/t/sitecustomize.py", {st_mode=S_IFREG|0664, st_size=0, ...}, 0) = 0
09:4...

Read more...

Revision history for this message
Adrien Nader (adrien) wrote :

A (partial?) work-around is to "export PYTHONDONTWRITEBYTECODE=1". I was looking for an environment variable that would give the same behaviour as python's -S command-line switch ( https://docs.python.org/3/using/cmdline.html#cmdoption-S ) initially.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.