Skip to content

Only set group and permissions on downloads dir if needed - #391

Merged
hugovk merged 3 commits into
python:mainfrom
hugovk:chmod
May 25, 2026
Merged

Only set group and permissions on downloads dir if needed#391
hugovk merged 3 commits into
python:mainfrom
hugovk:chmod

Conversation

@hugovk

@hugovk hugovk commented May 17, 2026

Copy link
Copy Markdown
Member

run_release.py:

During the 3.14.4 release, I held off uploading the files built by this repo (tarballs, docs, Android etc), awaiting some Windows build issues. This took some time. Once that was sorted, I continued.

But by this time, the macOS files had already been uploaded:

$ ls -l /srv/www.python.org/ftp/python/

drwxrwxr-x  47 hugovk    downloads  65536 Oct  7 14:16 3.14.0
drwxrwxr-x   5 hugovk    downloads   4096 Dec  2 16:18 3.14.1
drwxrwxr-x   5 hugovk    downloads   4096 Dec  5 20:01 3.14.2
drwxrwxr-x   5 hugovk    downloads   4096 Feb  3 18:29 3.14.3
drwxrwxr-x   2 nad       downloads   4096 Apr  7 15:15 3.14.4
drwxrwxr-x  26 hugovk    downloads  36864 Apr  7 14:12 3.15.0

Usually, the tarballs etc. get there first, but the script fell over because Ned had already created the directories and set permissions, and my user could not do that:

✅  Upload files to the PSF downloads server
💥  Place files in the download folder
Traceback (most recent call last):
  File "/Users/hugo/github/release-tools/run_release.py", line 1483, in <module>
    main()
    ~~~~^^
  File "/Users/hugo/github/release-tools/run_release.py", line 1479, in main
    automata.run()
    ~~~~~~~~~~~~^^
  File "/Users/hugo/github/release-tools/run_release.py", line 281, in run
    raise e from None
  File "/Users/hugo/github/release-tools/run_release.py", line 278, in run
    self.current_task(self.db)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/hugo/github/release-tools/release.py", line 151, in __call__
    return getattr(self, "function")(db)
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
  File "/Users/hugo/github/release-tools/run_release.py", line 836, in place_files_in_download_folder
    execute_command(f"chgrp downloads {destination}")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hugo/github/release-tools/run_release.py", line 832, in execute_command
    raise ReleaseException(channel.recv_stderr(1000))
ReleaseException: b"chgrp: changing group of '/srv/www.python.org/ftp/python/3.14.4': Operation not permitted\n"

After commenting out the chgrp, the chmod also fell over:

💥  Place files in the download folder
Traceback (most recent call last):
  File "/Users/hugo/github/release-tools/run_release.py", line 1483, in <module>
    main()
    ~~~~^^
  File "/Users/hugo/github/release-tools/run_release.py", line 1479, in main
    automata.run()
    ~~~~~~~~~~~~^^
  File "/Users/hugo/github/release-tools/run_release.py", line 281, in run
    raise e from None
  File "/Users/hugo/github/release-tools/run_release.py", line 278, in run
    self.current_task(self.db)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/hugo/github/release-tools/release.py", line 151, in __call__
    return getattr(self, "function")(db)
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
  File "/Users/hugo/github/release-tools/run_release.py", line 837, in place_files_in_download_folder
    execute_command(f"chmod 775 {destination}")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hugo/github/release-tools/run_release.py", line 832, in execute_command
    raise ReleaseException(channel.recv_stderr(1000))
ReleaseException: b"chmod: changing permissions of '/srv/www.python.org/ftp/python/3.14.4': Operation not permitted\n"

So for the release I commented the chmod as well.

The proper fix is to check the group and permissions first, and only try setting them when needed.

Also refactored these similar calls for downloads + docs into copy_and_set_permissions().


add_to_pydotorg.py - replace calls like run_cmd(["chmod", "644", sig_file]) with direct os.chmod(sig_file, 0o644) calls.

@savannahostrowski savannahostrowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Briefly wondered if ! -perm -775 would be safer in case the dir was 2775, but checked the server and it's plain 775. LGTM!

@hugovk
hugovk merged commit 2e7d4c6 into python:main May 25, 2026
18 checks passed
@hugovk
hugovk deleted the chmod branch May 25, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants