-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: ModuleNotFoundError: No module named 'NanoVNASaver._version' when compiling using the uv python package mananger #759
Comments
_version.py is generated by setuptools_scm package and it is not related to venv or package installation. You may run 'python -m setuptools_scm' inside venv or check documentation. About requerements management, 'uv export' may be used to form requirements.txt file, then you may use "usual" pip/pip3 to prepare venv "manually". 'uv pip instal' may also work and be more faster option, however I am not sure how it manage multiarch configurations. |
Exactly. |
https://docs.astral.sh/uv/concepts/projects/config/#project-environment-path may be helpful for this case. Seems it posdible to change location or venv using env vars. However I still not sure how uv handles multiplatform builds (e. g. will it choose right wheel pakage to install) |
Currently I delete the But the The |
Question/idea: do you need to use UV to build application package at all? In theory it should be possible to build python package by @xros could you try it? Would it simplify macos package building process? |
Yes I tried to use As for the Python interpreter, I used one Interpreter compiled with 2 different architectures. https://www.python.org/downloads/macos/ , download the universal2 version which has both arm64 and x86_64 .
I need this multi-arch Python3 for building packages for multi-arch macOS in different shell: https://github.com/xros/nanovna-saver/wiki/Making-apps-for-MacOS Don't use the homebrew version of Python since it's ONLY support 1 architecture. Or you need to install 2 (different architectures) Python interpreter using homebrew which is not wise and waste of resources. The Python3.9 interpreter macOS 15.2 has is too old for this project which needs Python3.10+. If you build apps using If you want to build for different architectures using Previously, we used |
Right now I think the work-around would be that find a method to automatically change the Such as # build 1 (on arm64)
# do something in shell, change to arm64 shell
uv sync # this uv is in arm64 binary
uv build xxxxx
# build 2 (on x86_64)
# do something in shell, change to x86_64 shell
mv .env .env_arm64
uv sync # this uv is in x86_64 binary
uv build xxxxx
# build 3 (on arm64)
# then switch to another architecture, do something in shell, change to arm64 shell
mv .env .env_x86_64
ln -sf .env_arm64 .env
uv sync # this uv is in arm64 binary
uv build xxxxx
Suppose if you want to build Linux binaries for arm64 platform on a x86_64 Linux. For cross-platform compiling, you would need to install different |
I still not sure why do you need to swap dirs manually. E.g. following code should work if you need different venv:
More details is here
Just FYI uv is not for building. pip is not for building too. This project use setuptools (*.gz and wheel) to prepare python packages and pyinstall to prepare binary distributions. Plus keep in mind, the project does not have any platform specific libs or native bindings, and result package has a valid meta information. So you may build source package, move it to any platform and prepare venv with whatever tool do you prefer. This means you do not need any |
I think because you didn't try, that's why you don't know why. If you have M chip mac computer by side, you can try. Here's the error that
I thought that's the error from system parameters. So I changed to the full path As I shared with you from here #759 (comment)
From The do-able method I found is to either delete the FYI, I know Certainly we can get the file Here I address that if you want to get requirements.txt, then you'll have to install virtual enviroment A, then in A install uv. Then uv will create another virtual enviroment B for development purposes. Of cause we don't need to use I think For buildings app for mutiple architectures on different OS, the simpler the better. Especially for small project. |
Just as I tried
I tried once again. |
Looks weird, I will try "custom" venv location on M3 laptop, however on win machine it works without any issues ;(
Perhaps we need to export requirements.txt as part of build process and put it under git control to simplify scenarios like you have. |
Sorry, I have not idea why it does not work in your case. |
And, just as illustration for "uv and requriements.txt less" approach:
|
Bug Report
NanoVNA-Saver version:
main branch at the time of writting
Current behavior:
ModuleNotFoundError: No module named 'NanoVNASaver._version'
Before we used
pip install -r requirments.txt
to install default packages needed for nanovna-saver, but @redrathnure changed to package manager uv https://github.com/astral-sh/uv from this pull-request: #752I don't use uv to create virtual enviroment, because I need 2 defined virtual enviroment for building binaries for both ARM64 macOS and X86_64 macOS
In a pre-configured python virtual enviroment for macOS ARM64, and another virtual environment for macOS x86_64
uv pip sync pyproject.toml
It automatically installed some packages in my defined virtual enviroment, but when I started to test the app usingpython nanovna-saver.py
it had this bugI read the doc https://github.com/NanoVNA-Saver/nanovna-saver/blob/main/docs/DEVELOPMENT.md, and tried to manually install the packages by switching back to pip by doing this
uv pip compile pyproject.toml -o requirements.txt
. This will create the file requirements.txt back. Then I tried withpip install -r requirements.txt
, then tried to re-run the apppython nanovna-saver.py
and it had the same error.The error
ModuleNotFoundError: No module named 'NanoVNASaver._version'
pointed to this file https://github.com/NanoVNA-Saver/nanovna-saver/blob/main/src/NanoVNASaver/app_version.py#L9. I think it's because I didn't use uv to create a virtual enviroment in.env
folder and other auto-machines were stopped.I used this method I wrote here for building apps https://github.com/xros/nanovna-saver/wiki/Making-apps-for-MacOS for different architectures of macOS including ARM64 and x86_64 on 1 Apple Computer.
By using 2 different pre-defined virtual enviroments, I don't need to re-install all the packages again everytime in the ONLY 1 folder .env (which uv creates) for us, and it's fast when building apps
By using the
uv run NanoVNASaver
, the file_version.py
will be automatically generated as thisExpected behavior:
python nanovna-saver.py
should run without errorSteps to reproduce:
As above
Related code:
file https://github.com/NanoVNA-Saver/nanovna-saver/blob/main/src/NanoVNASaver/app_version.py#L9
Other information:
Can someone come up with a method which can keep that using pip as package manager is still available for some cases and not using uv for creating the python virtual environment?
Yes I know
uv
works, but can we still be able to usepip
as an option?Here I address why
uv sync
should create 2 different virtual enviroments in different folders for building packages for different architectures so that I don't need to manually delete the folder.env
everytime I build apps for arm64 macOS and x86_64 macOS.The text was updated successfully, but these errors were encountered: