Hi :slightly_smiling_face: I got an issue with my ...
# general
e
Hi 🙂 I got an issue with my module and my test. I’ve defined a python distribution like this :
Copy code
resource(name="pyproject", source="pyproject.toml")

python_sources(name="source", sources=["./**/*.py", "!setup.py"])  

python_distribution(   
    name="utils",
    provides=python_artifact(
        name="utils",
        version="0.1.0",
    ),
    dependencies=[
        ":pyproject",
        ":source",
    ],
    wheel_config_settings={"--global-option": ["--python-tag", "py3"]},
)
But when I tried to run a test which is in another module, I got the following error :
Copy code
ModuleNotFoundError: No module named 'utils'
I feel I’m not configuring as it should be, but I’m completely lost. Is there a project that I could have a look on to understand how to use pants ?
r
Are you able to build this distribution? using
./pants package
The other thing would be explicitly define dependency on the generated dist similar to what has been described here https://www.pantsbuild.org/docs/python-test-goal#testing-your-packaging-pipeline
This is an example python repo, but I don't see the test set-up. https://github.com/pantsbuild/example-python I would also advise to have a look at the
source_root
concept, if you aren't already aware of it. https://www.pantsbuild.org/docs/source-roots
e
I’m able to use
./pants package
The test fails when I try to reference to another module. When I try to the reference into the dependency of the test, I had this error :
pex.environment.ResolveError: Failed to resolve requirements from PEX environment
I use a file marker to define my roots, so every package is a root
The example project is too simple 😕 I can’t use like this
e
@echoing-london-29138 when "you run a test in another module", can you explain more what that means? What is the Pants command?
./pants test x/y/z:w
? What is the relevant BUILD file there? Can you provide full (possibly redacted) output from the failing Pants command and the same for the relevant BUILD files and pants.toml configuration?