pre-commit: Executable python not found when committing a new file - virtualenv

I'm trying to use pre-commit 2.20.0 on Ubuntu 22.04.1 / Python 3.10.6.
I followed the instructions at https://pre-commit.com/#installation and installed pre-commit with pip (22.2.2).
Here's my .pre-commit-config.yaml file:
$ cat /home/username/Projects/web/app/.pre-commit-config.yaml
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pycqa/isort
rev: "5.10.1"
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black
rev: "22.8.0"
hooks:
- id: black
language_version: python3.10
But I face an error when committing a new file:
$ git commit -m "Update file."
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
Executable `python` not found
stderr: (none)
Check the log at /home/username/.cache/pre-commit/pre-commit.log
The same error occurs when using a virtual environment (virtualenv 20.16.5):
$ virtualenv venv
created virtual environment CPython3.10.6.final.0-64 in 170ms
creator CPython3Posix(dest=/home/username/Projects/web/app/venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/username/.local/share/virtualenv)
added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
$ git commit -m "Update file."
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
Executable `python` not found
stderr: (none)
Check the log at /home/username/.cache/pre-commit/pre-commit.log
Here's the full log:
$ cat /home/username/.cache/pre-commit/pre-commit.log
pre-commit version: 2.20.0
git --version: git version 2.34.1
sys.version:
3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux
### error information is the same as here above
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/usr/local/lib/python3.10/dist-packages/pre_commit/main.py", line 358, in main
return hook_impl(
File "/usr/local/lib/python3.10/dist-packages/pre_commit/commands/hook_impl.py", line 254, in hook_impl
return retv | run(config, store, ns)
File "/usr/local/lib/python3.10/dist-packages/pre_commit/commands/run.py", line 424, in run
install_hook_envs(to_install, store)
File "/usr/local/lib/python3.10/dist-packages/pre_commit/repository.py", line 223, in install_hook_envs
_hook_install(hook)
File "/usr/local/lib/python3.10/dist-packages/pre_commit/repository.py", line 79, in _hook_install
lang.install_environment(
File "/usr/local/lib/python3.10/dist-packages/pre_commit/languages/python.py", line 221, in install_environment
helpers.run_setup_cmd(prefix, install_cmd)
File "/usr/local/lib/python3.10/dist-packages/pre_commit/languages/helpers.py", line 48, in run_setup_cmd
cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/pre_commit/util.py", line 146, in cmd_output_b
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
Executable `python` not found
stderr: (none)
Here is my venv/ folder structure:
$ tree -L 3 venv/
venv/
├── lib
│   └── python3.10
├── local
│   ├── bin
│   │   ├── activate
│   │   ├── activate.csh
│   │   ├── activate.fish
│   │   ├── activate.nu
│   │   ├── activate.ps1
│   │   ├── activate_this.py
│   │   ├── deactivate.nu
│   │   ├── pip
│   │   ├── pip3
│   │   ├── pip-3.10
│   │   ├── pip3.10
│   │   ├── python -> /usr/bin/python3
│   │   ├── python3 -> python
│   │   ├── python3.10 -> python
│   │   ├── wheel
│   │   ├── wheel3
│   │   ├── wheel-3.10
│   │   └── wheel3.10
│   └── lib
│   └── python3.10
└── pyvenv.cfg
6 directories, 19 files
...which may be the cause of the trouble as per https://github.com/pypa/virtualenv/issues/2350 but I can definitely not understand all the story.
More:
$ which python # empty result!
$ which python3
/usr/bin/python3
$ ls -l /usr/bin/python3
(...) /usr/bin/python3 -> python3.10
Did I miss something in the pre-commit installation?
How could I properly and simply (#basic user) fix this error, if possible?

Related

How to change the default directory structure of dh_make so that dpkg-buildpackage does not throw any errors

I am trying to create a debian package for a postgreSQL extension Apache-age release 1.1.1 and created the directory structure using dh_make command.
The directory structure is as follows:
age-1.1.1 (project root)
├── debian
│   ├── changelog
│   ├── compat
│   ├── control
│   ├── docs
│   ├── examples
│   ├── links
│   ├── manpages
│   ├── menu
│   ├── postinst
│   ├── postrm
│   ├── preinst
│   ├── prerm
│   ├── rules
│   ├── source
│   └── watch
├── src
└── Makefile
The dpkg-buildpackage -b when run from project-root folder it looks for debian folder, then reads the rule file, then reads the Makefile located in the project root to build the package.
I want to change the directory structure to the following:
.project root
├── packaging
│ ├── debian
│ │ ├── control
│ │ ├── control.in
│ │ ├── changelog
│ │ ├── copyright
│ │ ├── pgversions
│ │ ├── rules
│ │ └── ...
│ └──
├── src
├── LICENSE
├── README.md
├── Makefile
└── ...
I want to change the directory structure so that the dpkg-buildpackage -b command can be run from the packaging folder and it should build the package.
Inside your Makefile
Modify the install paths accordingly. It should point to your packaging/debian/* where * is the filename.
This way the Makefile can point to the correct file path target inside the new folder structure.
I'm not sure if this is the best way to do this but it's working for me:
Here are the steps:
First run the dh_make_pgxs command from the project root directory.
Create a packaging directory in the project root and move the debian directory created in step 1 to this directory along with the Makefile, age.control and the age--1.1.1.sql.
Your file structure should look like this:
.project root
├── packaging
│   ├── debian
│   │   ├── control
│   │   ├── control.in
│   │   ├── changelog
│   │   ├── copyright
│   │   ├── pgversions
│   │   ├── rules
│   │   └── ...
│   ├── age--1.1.1.sql
│   ├── age.control
│   ├── Makefile
│   └── ...
├── src
├── LICENSE
├── README.md
└── ...
Change the file paths in the Makefile like:
src/backend/age.o should be ../src/backend/age.o.
./tools/ should be ./../tools/.
and so on.
Now you can simply run the dpkg-buildpackage -b command from the packaging directory to build the debian package.
Note: In step 1 we are running dh_make_pgxs in the project root first, this is to make sure that the project name in the control files and the version in the changelog file are correct. In this case the name/source in control, control.in & changelog files should be apache-age and the version number in changelog file should be 1.1.1-1.
Alternatively, you can run the command from the packaging directory and manually change the name and version in the control and changelog files.

Recipe for MV BlueFox3 using Yocto and a minimal image

I am using MV BlueFox3 camera on a RaspberryPi4 and I am trying to write a .bb recipe which is going to install the necessary software for the camera. A quick setup guide is on the manufacturer website, but I can not get the first part to work. So far, this is how my recipe looks:
SUMMARY = "Installs mvIMPACT Acquire base libraries"
DESCRIPTION = "This recipe installs mvIMPACT Acquire base libraries for all MATRIX VISION devices."
HOMEPAGE = "http://www.matrix-vision.de"
LICENSE_FLAGS = "EULA"
LICENSE_FLAGS_WHITELIST = "EULA"
LICENSE = "EULA"
LIC_FILES_CHKSUM = "file://${WORKDIR}/mvIMPACT_Acquire-ARM64-2.45.0/doc/EULA.txt;md5=f6f99507036166a5604b38e6df10f004"
PACKAGE_ARCH = "${MACHINE_ARCH}"
S = "${WORKDIR}"
SRC_URI = "file://mvGenTL_Acquire-ARM64_gnu-2.45.0.tgz"
TARGET = "arm64"
MVIA_SUBDIR = "opt/mvIMPACT_Acquire"
MVIA_LIB_SUBDIR = "lib"
TOOLKITS_LIB_SUBDIR = "Toolkits"
MV_DATA_DIR = "opt/mvIMPACT_Acquire/data"
do_install() {
# install mvIMPACT Acquire runtime binaries
install -m 0755 -d ${D}${base_prefix}/${MVIA_SUBDIR}/${MVIA_LIB_SUBDIR}
install -m 0755 -d ${D}${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}
install -m 0755 -d ${D}${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/FreeImage3160/bin/Release/FreeImage/${TARGET}
oe_soinstall ${S}/mvIMPACT_Acquire-ARM64-${PV}/lib/${TARGET}/libmvDeviceManager.so.${PV} ${D}${base_prefix}/${MVIA_SUBDIR}/${MVIA_LIB_SUBDIR}
oe_soinstall ${S}/mvIMPACT_Acquire-ARM64-${PV}/lib/${TARGET}/libmvPropHandling.so.${PV} ${D}${base_prefix}/${MVIA_SUBDIR}/${MVIA_LIB_SUBDIR}
oe_soinstall ${S}/mvIMPACT_Acquire-ARM64-${PV}/Toolkits/expat/bin/${TARGET}/lib/*.so.* ${D}${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}
install -m 0755 ${S}/mvIMPACT_Acquire-ARM64-${PV}/Toolkits/FreeImage3160/bin/Release/FreeImage/${TARGET}/*.so ${D}${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/FreeImage3160/bin/Release/FreeImage/${TARGET}
# set environment variables for mvIMPACT Acquire
install -m 0755 -d ${D}${sysconfdir}/profile.d
echo 'export MVIMPACT_ACQUIRE_DIR=/opt/mvIMPACT_Acquire' >> ${D}${sysconfdir}/profile.d/acquire.sh
echo 'export MVIMPACT_ACQUIRE_DATA_DIR=/opt/mvIMPACT_Acquire/data' >> ${D}${sysconfdir}/profile.d/acquire.sh
# set library search paths for the dynamic linker
install -m 0755 -d ${D}${sysconfdir}/ld.so.conf.d
echo '/opt/mvIMPACT_Acquire/lib' >> ${D}${sysconfdir}/ld.so.conf.d/acquire.conf
echo '/opt/mvIMPACT_Acquire/Toolkits' >> ${D}${sysconfdir}/ld.so.conf.d/acquire.conf
# set up logfiles
install -m 0755 -d ${D}${base_prefix}/${MV_DATA_DIR}/logs
install -m 0755 ${S}/mvIMPACT_Acquire-ARM64-${PV}/apps/mvDebugFlags.mvd ${D}${base_prefix}/${MV_DATA_DIR}/logs/
}
INHIBIT_PACKAGE_STRIP = "1"
INSANE_SKIP_${PN} += "dev-so \
already-stripped \
ldflags"
PACKAGES = "${PN} ${PN}-dev ${PN}-doc"
FILES_${PN} += "${base_prefix}/${MVIA_SUBDIR}/${MVIA_LIB_SUBDIR}/lib*.so.* \
${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/lib*.so.* \
${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/FreeImage3160/bin/Release/FreeImage/${TARGET}/lib*.so \
${sysconfdir}/profile.d/*.sh \
${sysconfdir}/ld.so.conf.d/*.conf"
FILES_${PN}-dev += "${base_prefix}/${MVIA_SUBDIR}/${MVIA_LIB_SUBDIR}/lib*.so \
${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/lib*.so"
FILES_${PN}-doc += "${base_prefix}/${MV_DATA_DIR}/logs"
but I am getting the following error:
NOTE: Executing Tasks
ERROR: mvimpact-acquire-base-2.45.0-r0 do_package: QA Issue: File '/opt/mvIMPACT_Acquire/Toolkits/FreeImage3160/bin/Release/FreeImage/arm64/libfreeimage-3.16.0.so' from mvimpact-acquire-base was already stripped, this will prevent future debugging! [already-stripped]
ERROR: mvimpact-acquire-base-2.45.0-r0 do_package: QA Issue: File '/opt/mvIMPACT_Acquire/Toolkits/libexpat.so.1.6.0' from mvimpact-acquire-base was already stripped, this will prevent future debugging! [already-stripped]
ERROR: mvimpact-acquire-base-2.45.0-r0 do_package: QA Issue: File '/opt/mvIMPACT_Acquire/lib/libmvDeviceManager.so.2.45.0' from mvimpact-acquire-base was already stripped, this will prevent future debugging! [already-stripped]
ERROR: mvimpact-acquire-base-2.45.0-r0 do_package: QA Issue: File '/opt/mvIMPACT_Acquire/lib/libmvPropHandling.so.2.45.0' from mvimpact-acquire-base was already stripped, this will prevent future debugging! [already-stripped]
ERROR: mvimpact-acquire-base-2.45.0-r0 do_package: QA Issue: mvimpact-acquire-base: Files/directories were installed but not shipped in any package:
/opt
/opt/mvIMPACT_Acquire
/opt/mvIMPACT_Acquire/Toolkits
/opt/mvIMPACT_Acquire/lib
/opt/mvIMPACT_Acquire/data
/opt/mvIMPACT_Acquire/Toolkits/libexpat.so
/opt/mvIMPACT_Acquire/Toolkits/libexpat.so.1.6.0
/opt/mvIMPACT_Acquire/Toolkits/libexpat.so.1
/opt/mvIMPACT_Acquire/Toolkits/FreeImage3160
/opt/mvIMPACT_Acquire/Toolkits/FreeImage3160/bin
/opt/mvIMPACT_Acquire/Toolkits/FreeImage3160/bin/Release
/opt/mvIMPACT_Acquire/Toolkits/FreeImage3160/bin/Release/FreeImage
/opt/mvIMPACT_Acquire/Toolkits/FreeImage3160/bin/Release/FreeImage/arm64
/opt/mvIMPACT_Acquire/Toolkits/FreeImage3160/bin/Release/FreeImage/arm64/libfreeimage-3.16.0.so
/opt/mvIMPACT_Acquire/lib/libmvPropHandling.so
/opt/mvIMPACT_Acquire/lib/libmvDeviceManager.so.2.45.0
/opt/mvIMPACT_Acquire/lib/libmvDeviceManager.so.2
/opt/mvIMPACT_Acquire/lib/libmvDeviceManager.so
/opt/mvIMPACT_Acquire/lib/libmvPropHandling.so.2.45.0
/opt/mvIMPACT_Acquire/lib/libmvPropHandling.so.2
/opt/mvIMPACT_Acquire/data/logs
/opt/mvIMPACT_Acquire/data/logs/mvDebugFlags.mvd
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
mvimpact-acquire-base: 22 installed and not shipped files. [installed-vs-shipped]
ERROR: mvimpact-acquire-base-2.45.0-r0 do_package: Fatal QA errors found, failing task.
ERROR: Logfile of failure stored in: /home/stefan/Projects/raspberrypiOS/build/tmp/work/raspberrypi4_64-poky-linux/mvimpact-acquire-base/2.45.0-r0/temp/log.do_package.2280592
ERROR: Task (/home/stefan/Projects/raspberrypiOS/meta-mvimpact-acquire/recipes-mvimpactacquire/mvimpact-acquire/mvimpact-acquire-base_2.45.0.bb:do_package) failed with exit code '1'
I am guessing that I should change the FILES variable to ensure proper package splitting but I do not know how. I have tried adding the directories and files from the error message, but no matter what I do, the error message seems to be the same (22 packages).
In the workdir, the image and package folders seem to be identical, and the package-split folder contains mvimpact-acquire-base (with only the /etc folder inside, but no /opt), while the mvimpact-acquire-base-dev, mvimpact-acquire-base-doc, mvimpact-acquire-base-src folders are all empty.
Can anyone help me understand this problem better or suggest a potential solution regarding the FILES variable and the error message.
I think the other error messages about stripping are not at issue here, but if you can share additional info it would be great.
Below are the contents of some WORKDIR(/work/raspberrypi4_64-poky-linux/mvimpact-acquire-base/2.45.0-r0) subdirectories.
image/
├── etc
│   ├── ld.so.conf.d
│   │   └── acquire.conf
│   └── profile.d
│   └── acquire.sh
└── opt
└── mvIMPACT_Acquire
├── data
│   └── logs
│   └── mvDebugFlags.mvd
├── lib
│   ├── libmvDeviceManager.so -> libmvDeviceManager.so.2.45.0
│   ├── libmvDeviceManager.so.2 -> libmvDeviceManager.so.2.45.0
│   ├── libmvDeviceManager.so.2.45.0
│   ├── libmvPropHandling.so -> libmvPropHandling.so.2.45.0
│   ├── libmvPropHandling.so.2 -> libmvPropHandling.so.2.45.0
│   └── libmvPropHandling.so.2.45.0
└── Toolkits
├── FreeImage3160
│   └── bin
│   └── Release
│   └── FreeImage
│   └── arm64
│   └── libfreeimage-3.16.0.so
├── libexpat.so -> libexpat.so.1.6.0
├── libexpat.so.1 -> libexpat.so.1.6.0
└── libexpat.so.1.6.0
14 directories, 13 files
package/
├── etc
│   ├── ld.so.conf.d
│   │   └── acquire.conf
│   └── profile.d
│   └── acquire.sh
└── opt
└── mvIMPACT_Acquire
├── data
│   └── logs
│   └── mvDebugFlags.mvd
├── lib
│   ├── libmvDeviceManager.so -> libmvDeviceManager.so.2.45.0
│   ├── libmvDeviceManager.so.2 -> libmvDeviceManager.so.2.45.0
│   ├── libmvDeviceManager.so.2.45.0
│   ├── libmvPropHandling.so -> libmvPropHandling.so.2.45.0
│   ├── libmvPropHandling.so.2 -> libmvPropHandling.so.2.45.0
│   └── libmvPropHandling.so.2.45.0
└── Toolkits
├── FreeImage3160
│   └── bin
│   └── Release
│   └── FreeImage
│   └── arm64
│   └── libfreeimage-3.16.0.so
├── libexpat.so -> libexpat.so.1.6.0
├── libexpat.so.1 -> libexpat.so.1.6.0
└── libexpat.so.1.6.0
14 directories, 13 files
packages-split/
├── mvimpact-acquire-base
│   └── etc
│   ├── ld.so.conf.d
│   │   └── acquire.conf
│   └── profile.d
│   └── acquire.sh
├── mvimpact-acquire-base-dev
├── mvimpact-acquire-base-doc
└── mvimpact-acquire-base-src
7 directories, 2 files
The issue was new BitBake syntax. I changed the following lines:
INSANE_SKIP_${PN} += "dev-so
FILES_${PN} += "${base_prefix}/${MVIA_SUBDIR}/${MVIA_LIB_SUBDIR}/lib*.so.* \
${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/lib*.so.* \
${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/FreeImage3160/bin/Release/FreeImage/${TARGET}/lib*.so \
${sysconfdir}/profile.d/*.sh \
${sysconfdir}/ld.so.conf.d/*.conf"
to
INSANE_SKIP:${PN} += "dev-so
FILES:${PN} += "${base_prefix}/${MVIA_SUBDIR}/${MVIA_LIB_SUBDIR}/lib*.so.* \
${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/lib*.so.* \
${base_prefix}/${MVIA_SUBDIR}/${TOOLKITS_LIB_SUBDIR}/FreeImage3160/bin/Release/FreeImage/${TARGET}/lib*.so \
${sysconfdir}/profile.d/*.sh \
${sysconfdir}/ld.so.conf.d/*.conf"
So basically, instead of underscores it now uses colons.

Bitbake hello world example fails

I'm following this tutorial:
https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-hello.html
My bitbake version is 1.50.0 and BBPATH is following:
export BBPATH="/home/testusr/projects/bitbake_example/bitbake_sample_project/hello"
and I'm at the last step of the tutorial with following file structure:
/home/testusr/projects/bitbake_example/bitbake_sample_project $ tree
.
├── hello
│   ├── classes
│   │   └── base.bbclass
│   └── conf
│   ├── bblayers.conf
│   └── bitbake.conf
└── mylayer
├── conf
│   └── layer.conf
└── printhello.bb
The problem is when I try to build that:
/home/testusr/projects/bitbake_example/bitbake_sample_project/hello $ bitbake printhello
WARNING: Layer mylayer should set LAYERSERIES_COMPAT_mylayer in its conf/layer.conf file to list the core layer names it is compatible with.
Loading cache: 100% | | ETA: --:--:--
Loaded 0 entries from dependency cache.
WARNING: No bb files in default matched BBFILE_PATTERN_mylayer '^\/home\/testusr\/projects\/bitbake_example\/bitbake_sample_project\/mylayer/'
ERROR: Nothing PROVIDES 'printhello'
The warning is saying that there are no bb files under:
/home/testusr/projects/bitbake_example/bitbake_sample_project/mylayer/
but this file is clearly there as can be seen in tree output, so I'm totally confused.
The problem was with the tutorial in layer.conf file. It had:
BBFILES += "${LAYERDIR}/\*.bb"
Instead of:
BBFILES += "${LAYERDIR}/*.bb"
and that's why it couldn't be found.

If I have a local rpm in my ansible-playbook can I do yum install in one step?

I have downloaded a rpm in my ansible-playbook:
(djangoenv)~/P/c/apache-installer ❯❯❯ tree .
.
├── defaults
│   └── main.yml
├── files
│   ├── apache2latest.tar
│   ├── httpd_final.conf
│   ├── httpd_temp.conf
│   └── sshpass-1.05-9.1.i686.rpm
├── handlers
│   └── main.yml
├── hosts
├── meta
│   └── main.yml
├── README.md
├── tasks
│   └── main.yml
├── templates
├── tests
│   ├── inventory
│   └── test.yml
└── vars
└── main.yml
My question is why can't I just install it using:
- yum: name=files/sshpass-1.05-9.1.i686.rpm
? It complains that files/sshpass-1.05-9.1.i686.rpm is not found in the system. Now I am doing it in two steps:
- copy: src=files/sshpass-1.05-9.1.i686.rpm dest=/tmp/sshpass-1.05-9.1.i686.rpm force=no
- yum: name=/tmp/sshpass-1.05-9.1.i686.rpm state=present
No, there is no simple way around coping the package to the remote host before installing. Ansible yum module expects a local file when you define a file in the name parameter.
IMHO it is not a good idea to keep packages inside the Ansible code base. Because they are binary and not exactly part of the actual Ansible code. It would be cleaner to setup a private repository and store those files there. That is the only way around coping a package in this situation I'm aware of.

How should I download specific file type from folder (and ONLY it's subfolders) using wget or httrack?

I'm trying to use HTTrack or Wget do download some .docx files from a website. I want to do this only for a folder and it's subfolders. Ex: www.examplewebsite.com/doc (this goes down 5 more levels)
How would be a good way to do this?
The previous proposed answer is ludicrous considering the "spider" option has ALWAYS specifically NOT DOWNLOADED, but instead followed.
Better late than never, but here is the command you seek to both mirror the desired file extension files locally, but then as a bonus pull down the target html and auto-adjust it so that if you open it locally and click the links, they will have been altered and adjusted accordingly to now point to the local drive.
wget -e robots=off -r -k -A docx,doc "https://<url>"
If this works for you, I would appreciate the answer points!
You can use --spider with -r (recursive option ) and have --accept to filter the files of your intrest
wget --spider -r --accept "*.docx" <url>
Usage
wget -r -np -A pdf,doc https://web.cs.ucla.edu/~harryxu/
Result
tree
└── web.cs.ucla.edu
├── ~harryxu
│   ├── papers
│   │   ├── chianina-pldi21.pdf
│   │   ├── dorylus-osdi21.pdf
│   │   ├── genc-pldi20.pdf
│   │   ├── jaaru-asplos21.pdf
│   │   ├── jportal-pldi21.pdf
│   │   ├── li-sigcomm20.pdf
│   │   ├── trimananda-fse20.pdf
│   │   ├── vigilia-sec18.pdf
│   │   ├── vora-asplos17.pdf
│   │   ├── wang-asplos17.pdf
│   │   ├── wang-osdi18.pdf
│   │   ├── wang-osdi20.pdf
│   │   ├── wang-pldi19.pdf
│   │   └── zuo-eurosys19.pdf