Open brightlightkim opened 2 weeks ago
Hi @brightlightkim , isn't the a problem because the way you wrote the import statement (from helpers.aws import generate_background_aws
)? Shouldn't it be a relative import instead of the absolute import?
The other thing I can see that you are using find:
in setup.cfg
, but some of your folders don't contain an __init__.py
file.
Hey @abravalheri,
I'm having a similar issue with python-3.12 only with my package. While running on 3.8/9/10/11, I can build my package and run my tests, please check the log below.
Package: cocotbext-ahb Setup file: setup.py
Ps.: I modified my local noxfile.py
to include 3.12 in the run session.
root@bbfc4b27bcad:/cocotbext-ahb# nox -s run-3.12 -- -k "test_ahb_lite_sram.py"
nox > Running session run-3.12
nox > Re-using existing virtual environment at .nox/run-3-12.
nox > python -m pip install pytest pytest-xdist pytest-sugar pytest-cov pytest-split cocotb-bus==0.2.1 cocotb-test==0.2.4 'cocotb>=1.8.0'
nox > python -m pip install -e .
nox > Command python -m pip install -e . failed with exit code 1:
Obtaining file:///cocotbext-ahb
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Checking if build backend supports build_editable: started
Checking if build backend supports build_editable: finished with status 'done'
Getting requirements to build editable: started
Getting requirements to build editable: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> [27 lines of output]
Traceback (most recent call last):
File "/cocotbext-ahb/.nox/run-3-12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/cocotbext-ahb/.nox/run-3-12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/cocotbext-ahb/.nox/run-3-12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-px4dvd0v/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 448, in get_requires_for_build_editable
return self.get_requires_for_build_wheel(config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-px4dvd0v/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-px4dvd0v/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-px4dvd0v/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-px4dvd0v/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 4, in <module>
File "/cocotbext-ahb/cocotbext/ahb/__init__.py", line 16, in <module>
from .ahb_master import AHBLiteMaster, AHBMaster
File "/cocotbext-ahb/cocotbext/ahb/ahb_master.py", line 10, in <module>
import cocotb
ModuleNotFoundError: No module named 'cocotb'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
nox > Session run-3.12 failed.
root@bbfc4b27bcad:/cocotbext-ahb#
Version
Package Version │ modified: cocotbext/ahb/utils.py
------------ --------- │ deleted: monitor.py
argcomplete 3.4.0 │ modified: noxfile.py
colorlog 6.8.2 │ modified: tests/test_ahb_lite_sram.py
distlib 0.3.8 │
filelock 3.15.1 │no changes added to commit (use "git add" and/or "git commit -a")
nox 2024.4.15 │❯ rm -rf log.txt
packaging 24.1 │╭─ ~/projects/cocotbext-ahb on master *3 !5 ······················
pip 24.0 │················ ✔ at 06:45:25 pm
platformdirs 4.2.2 │╭─ ~/projects/cocotbext-ahb on master *3 !5 ······················
setuptools 68.1.2 │··············· ✔ at 06:45:25 pm ─╮
virtualenv 20.26.2 │╭─ ~/projects/cocotbext-ahb on master *3 !5 ····· ✔ at 06:45:25
wheel 0.42.0
Hi @aignacio , I don't think your problem is the same as discussed in this issue.
It seems that you are trying to perform an import statement during build time without defining a build time dependency in a way that pip
understands (i.e. via pyproject.toml
).
You probably forgot to factor in the "build isolation" behaviour that sometimes is triggered by pip
(don't ask me when, it is internal pip
heuristics, maybe it is described in pip's docs...).
In "build isolation" pip
completely ignore everything you have installed and create a brand new throw away environment just for the build.
Please revise your setup/CI to make sure you account for that. After that if you still have problems that are associated with setuptools behaviour, please open a separated issue.
pyproject.toml
Hi @aignacio , I don't think your problem is the same as discussed in this issue.
It seems that you are trying to perform an import statement during build time without defining a build time dependency in a way that
pip
understands (i.e. viapyproject.toml
).You probably forgot to factor in the "build isolation" behaviour that sometimes is triggered by
pip
(don't ask me when, it is internalpip
heuristics, maybe it is described in pip's docs...).In "build isolation"
pip
completely ignore everything you have installed and create a brand new throw away environment just for the build.Please revise your setup/CI to make sure you account for that. After that if you still have problems that are associated with setuptools behaviour, please open a separated issue.
Thanks @abravalheri, that solved the problem, It was a miss the pyproject.toml
indeed! I just wonder now how it is working for previous python versions...
the "build isolation" behaviour that sometimes is triggered by pip (don't ask me when, it is internal pip heuristics, maybe it is described in pip's docs...).
☝️
setuptools version
70.0.0
Python version
Python 3.12
OS
Mac M2 Pro Max, Mac M1 Pro
Additional environment information
[metadata] name = backend description = backend author = Kimchi platforms = unix, linux, osx, win32 classifiers = Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 version = 0.1.0
[options] packages = find: install_requires = requests >= 2 python_requires = >=3.10
requirements.txt file
aiohttp==3.9.5 asyncio==3.4.3 boto3==1.34.122 fastapi==0.111.0 firebase-admin==6.5.0 google-cloud-storage==2.17.0 httpx==0.27.0 poetry==1.1.12 pre-commit==3.7.1 pytest==8.2.2 pytest==8.2.2 pytest-mock==3.14.0 requests setuptools==70.0.0 uvicorn==0.30.1 wheel==0.43.0 gemini_webapi==1.5.1
Description
File Name: generate_background.py
from api.controllers.helpers import ( generate_background_aws, generate_background_firebase, generate_background_google, )
This returns the error that ModuleNotFoundError: No module named 'api'
File Path: src --api ----controllers ------helpers --------init.py --------aws.py --------firebase.py --------gcs.py ------generate_background.py
In the helpers folder, The init file looks like
File Name: init.py
from .firebase import generate_background_firebase from .gcs import generate_background_google
all = [ "generate_background_aws", "generate_background_firebase", "generate_background_google", ]
And the aws.py file has this kind of function:
File Name: aws
async def generate_background_aws()
Please let me know if any of the change I should make to make this work. Our team is wondering if we should downgrade our python version to 3.10 which worked for one member.
Expected behavior
We should be able to import the local modules correctly.
How to Reproduce
Just try to run the file after making the similar file and path structure. It returns an error....
Output