Open lgarrison opened 1 year ago
Thanks for the report! Another possible fix that would avoid having to call os.remove
would be to check if the destination file is the same as the file being copied and to skip the copy if so?
Re-reading my own bug report, I'm now wondering if an even easier fix is to do the copy in a way that doesn't preserve the read-only permissions, which could be accomplished by using shutil.copyfile()
instead of shutil.copy()
. What would you think about that?
When installing astropy in spack, a curious situation comes up:
My diagnosis is this: first, extension-helpers is installed and spack decides to make it read-only; no problem. Then, astropy is built from source, calling extension-helpers'
get_extensions()
function twice: once in pip's "Preparing metadata" phase, and once to actually build it. The first time,extension-helpers/src/_compiler.c
is copied to./astropy/_compiler.c
without issue. The second time,./astropy/_compiler.c
already exists and is read-only, because it was copied along with its 0444 permissions the first time. So the copy fails the second time.I'm not 100% sure where the permissions on
_compiler.c
are being modified; I'm not even 100% sure it's spack. The build system is pretty complicated. But regardless, I think this issue would arise any time an installation of extension-helpers is made read-only, which seems reasonable, if uncommon.I worked around this issue by modifying extension-helpers to simply remove the
_compiler.c
file before attempting to overwrite it.os.remove()
doesn't care about read-only (likerm
), butshutil.copy()
does. Go figure!This seems like a pretty safe, general change, so I wanted to see if (1) you agree this is a reasonable modification, and (2) you would be interested in a PR. The diff is simply:
More build log details
``` ==> py-astropy: Executing phase: 'install' ==> [2023-02-06-18:19:11.359931] '/mnt/sw/nix/store/y80v9c1vpcqjlvxrkfxw5hyvrhjiixjr-python-3.9.15/bin/python3.9' '-m' 'pip' '-vvv' '--no-input' '--no-cache-dir' '--disable-pip-version-check' 'install' '--no-deps' '--ignore-installed' '--no-build-isolation' '--no-warn-script-location' '--no-index' '--prefix=/mnt/sw/nix/store/p16j2flby89r9m29p2bnd7cagqp780sf-py-astropy-5.1' '--install-option=--use-system-libraries' '--install-option=--use-system-erfa' '--install-option=--use-system-wcslib' '--install-option=--use-system-cfitsio' '--install-option=--use-system-expat' '.' WARNING: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option. Using pip 22.2.2 from /mnt/sw/nix/store/hmyviwx9ydli42d7al14dl0a644jr17f-py-pip-22.2.2/lib/python3.9/site-packages/pip (python 3.9) Non-user install due to --prefix or --target option Ignoring indexes: https://pypi.org/simple Created temporary directory: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-ephem-wheel-cache-jjoo0f0a Created temporary directory: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-build-tracker-gnsrljxg Initialized build tracking at /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-build-tracker-gnsrljxg Created build tracker: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-build-tracker-gnsrljxg Entered build tracker: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-build-tracker-gnsrljxg Created temporary directory: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-install-tjs3ee_h Processing /dev/shm/nix-build-py-astropy-5.1.drv-1/nixbld1/spack-stage-py-astropy-5.1-p16j2flby89r9m29p2bnd7cagqp780sf/spack-src Added file:///dev/shm/nix-build-py-astropy-5.1.drv-1/nixbld1/spack-stage-py-astropy-5.1-p16j2flby89r9m29p2bnd7cagqp780sf/spack-src to build tracker '/dev/shm/nix-build-py-astropy-5.1.drv-1/pip-build-tracker-gnsrljxg' Created temporary directory: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl Preparing metadata (pyproject.toml): started Running command Preparing metadata (pyproject.toml) /mnt/sw/nix/store/d9ksrdh7n65r9f6l2yfk9bh9scnxy03m-py-setuptools-62.6.0/lib/python3.9/site-packages/setuptools/config/setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class) running dist_info creating /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info writing /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/PKG-INFO writing dependency_links to /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/dependency_links.txt writing entry points to /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/entry_points.txt writing requirements to /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/requires.txt writing top-level names to /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/top_level.txt writing manifest file '/dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/SOURCES.txt' listing git files failed - pretending there aren't any reading manifest file '/dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching '*.templ' under directory 'astropy' warning: no files found matching 'astropy/astropy.cfg' warning: no files found matching '*' under directory 'scripts' warning: no files found matching '*' under directory 'static' no previously-included directories found matching 'astropy/_dev' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'build' warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.o' found anywhere in distribution adding license file 'LICENSE.rst' writing manifest file '/dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy.egg-info/SOURCES.txt' creating '/dev/shm/nix-build-py-astropy-5.1.drv-1/pip-modern-metadata-xuibowpl/astropy-5.1.dist-info' Preparing metadata (pyproject.toml): finished with status 'done' Source in /dev/shm/nix-build-py-astropy-5.1.drv-1/nixbld1/spack-stage-py-astropy-5.1-p16j2flby89r9m29p2bnd7cagqp780sf/spack-src has version 5.1, which satisfies requirement astropy==5.1 from file:///dev/shm/nix-build-py-astropy-5.1.drv-1/nixbld1/spack-stage-py-astropy-5.1-p16j2flby89r9m29p2bnd7cagqp780sf/spack-src Removed astropy==5.1 from file:///dev/shm/nix-build-py-astropy-5.1.drv-1/nixbld1/spack-stage-py-astropy-5.1-p16j2flby89r9m29p2bnd7cagqp780sf/spack-src from build tracker '/dev/shm/nix-build-py-astropy-5.1.drv-1/pip-build-tracker-gnsrljxg' Created temporary directory: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-unpack-h8qbi0x4 Building wheels for collected packages: astropy Created temporary directory: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-wheel-y1fm63d2 Destination directory: /dev/shm/nix-build-py-astropy-5.1.drv-1/pip-wheel-y1fm63d2 Building wheel for astropy (pyproject.toml): started Running command Building wheel for astropy (pyproject.toml) Traceback (most recent call last): File "/mnt/sw/nix/store/hmyviwx9ydli42d7al14dl0a644jr17f-py-pip-22.2.2/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, inThanks!