wooden-thailand-8386
10/19/2020, 6:23 PMhundreds-father-404
10/19/2020, 6:25 PMmodule_mapping
, but first-party doesn’t need it
(Only possible issue is when you have >1 target owning the same file, i.e. overlapping sources
fields; results in a no-op because we can’t disambiguate which target to use)wooden-thailand-8386
10/19/2020, 6:30 PM.py
files I have a from rasa_sdk import …
and I’m still getting a
ModuleNotFoundError: No module named 'rasa_sdk'
when trying to run the pex filehundreds-father-404
10/19/2020, 6:34 PM./pants dependencies path/to/foo.py
when debugging.
I’m wondering if source roots are set up the right way? When creating the mapping of all modules, Pants strips source roots. So src/python/myorg/lib.py
becomes the module myorg.lib
wooden-thailand-8386
10/19/2020, 6:37 PMrasa_sdk
at all but my internal libs are there which is really cool 😄hundreds-father-404
10/19/2020, 6:37 PMrasa_sdk
a first-party dep or third-party dep?wooden-thailand-8386
10/19/2020, 6:37 PMhundreds-father-404
10/19/2020, 6:38 PMwooden-thailand-8386
10/19/2020, 6:42 PMsite-packages
and it’s rasa_sdk there.. and I install it with pip install rasa-sdk
-
and _
module_mapping={}
so it now looks like:
"rasa-sdk": ["rasa_sdk"],
and now it found ithundreds-father-404
10/19/2020, 6:46 PMrasa-sdk
to the module rasa_sdk
. That’s good to know we’re notwooden-thailand-8386
10/19/2020, 6:47 PMhundreds-father-404
10/19/2020, 6:47 PMpython_req.project_name.lower().replace("-", "_")
rasa-sdk
in your requirements.txt
?wooden-thailand-8386
10/19/2020, 6:48 PMpython_req.project_name = python_req.project_name.lower().replace("-", "_")
hundreds-father-404
10/19/2020, 6:51 PM▶ pex setuptools
Python 3.8.3 (default, May 27 2020, 20:54:22)
[Clang 11.0.3 (clang-1103.0.32.59)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from pkg_resources import Requirement
>>> Requirement.parse('rasa-sdk').project_name.lower().replace("-", "_")
'rasa_sdk'
The only thing I can think of is if the dash in rasa-sdk
is not a normal dash, so I’m wondering if you can copy and paste the string you use in requirements.txt
exactlywooden-thailand-8386
10/19/2020, 6:54 PMmodule_mapping
before. I only have setuptools
now there since it is a different package naming. The rest I removed it and now it’s working fine. Sorry about that.hundreds-father-404
10/19/2020, 6:59 PMI don’t have to add anything to module_mapping if it’s just supposed to “work fine” right?That’s correct. It’s only when you need to override the default
wooden-thailand-8386
10/19/2020, 7:00 PMsetuptools
now is causing errors 😞ModuleNotFoundError: No module named 'pkg_resources'
but it is being defined inside python_requirements
like this:
python_requirements(
module_mapping={
"setuptools": ["pkg_resources"],
}
)
setuptools
is a dependency of one of my third-party dependencies…
File "/Users/lzfnyy/.pyenv/versions/3.7.8/lib/python3.7/runpy.py", line 208, in run_module
return _run_code(code, {}, init_globals, run_name, mod_spec)
File "/Users/lzfnyy/.pyenv/versions/3.7.8/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/lzfnyy/.pex/code/80df3353e9fd3bf4154fb48cf8e6aa7c612cfd56/main.py", line 5, in <module>
import rasa_sdk.endpoint
File "/Users/lzfnyy/.pex/installed_wheels/8ad79b9c644dff8f1b2cc9bc005597d50a98f3db/rasa_sdk-1.10.2-py3-none-any.whl/rasa_sdk/endpoint.py", line 10, in <module>
from sanic_cors import CORS
File "/Users/lzfnyy/.pex/installed_wheels/a4b580262eea6ce0fd763f8434011e5343a2ec82/Sanic_Cors-0.10.0.post3-py2.py3-none-any.whl/sanic_cors/__init__.py", line 11, in <module>
from .decorator import cross_origin
File "/Users/lzfnyy/.pex/installed_wheels/a4b580262eea6ce0fd763f8434011e5343a2ec82/Sanic_Cors-0.10.0.post3-py2.py3-none-any.whl/sanic_cors/decorator.py", line 13, in <module>
from spf import SanicPluginsFramework
File "/Users/lzfnyy/.pex/installed_wheels/e62f1a08fd4247125f0fec6326f5e3026e22db98/Sanic_Plugins_Framework-0.9.4-py2.py3-none-any.whl/spf/__init__.py", line 3, in <module>
from .framework import SanicPluginsFramework
File "/Users/lzfnyy/.pex/installed_wheels/e62f1a08fd4247125f0fec6326f5e3026e22db98/Sanic_Plugins_Framework-0.9.4-py2.py3-none-any.whl/spf/framework.py", line 15, in <module>
from spf.config import load_config_file
File "/Users/lzfnyy/.pex/installed_wheels/e62f1a08fd4247125f0fec6326f5e3026e22db98/Sanic_Plugins_Framework-0.9.4-py2.py3-none-any.whl/spf/config.py", line 8, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
hundreds-father-404
10/19/2020, 7:05 PMApparently setuptools is a dependency of one of my third-party dependencies…That happens all the time 😞 many users globally install
setuptools
, so library authors forget to include it in their requirements
Unfortunately, dep inference can’t help here. Your module_mapping
is 100% valid. But there is no import statement for Pants to analyze
On the plus side, your BUILD file will now be very declarative in calling attention to the problem:
python_library(
dependencies=[
# `foo` didn't declare its dep on `setuptools`
'3rdparty/python:setuptools',
]
)
wooden-thailand-8386
10/19/2020, 7:06 PMhundreds-father-404
10/19/2020, 7:07 PMsetuptools
, and it’s a tiny change. See https://github.com/pytest-dev/pytest-rerunfailures/pull/98 for an examplewooden-thailand-8386
10/19/2020, 7:10 PM