after a pants version upgrade to the latest versio...
# general
e
after a pants version upgrade to the latest version (2.1.140), new PEXes are returning the following error when executed
Copy code
can't find '__main__' module in '{pex-name}.pex'
any ideas on what might be causing this error/how to resolve this?
h
This is not enough information to go on. A repo that reproduces the problem would be helpful.
e
ahh I’m not sure if I can share an internal repo here… for what it’s worth, I think my issue is similar to the issue documented here: https://github.com/pantsbuild/pex/issues/958
h
And did the various suggestions there work?
e
it turns out my failure was caused by one of the dependency specifications in one of the BUILD files. still not entirely sure why that specific dependency specification would cause this error though. I’m assuming some sort of pants magic
specifically, a BUILD file that looked like this
Copy code
python_sources(
    dependencies=[
        "3rdparty/pandas_1_2#pandas",
        "3rdparty/cbml",
    ],
)
caused the issue, and the issue was fixed after specifying the precise dependency of our internal cbml library used by the code within the scope of the BUILD file
Copy code
python_sources(
    dependencies=[
        "3rdparty/pandas_1_2#pandas",
        "3rdparty/cbml#snowflake-connector-python",
    ],
)
any ideas why the first BUILD file might cause the
can't find '__main__' module in '{pex-name}.pex'
error?
h
What is in that 3rdparty/cbml BUILD file?
e
Copy code
python_requirements(
    module_mapping={
        "python-json-logger": ["pythonjsonlogger"],
        "scikit-learn": ["sklearn"],
        "boto3-stubs": ["mypy_boto3_s3"],
        "imbalanced-learn": ["imblearn"],
    },
)
h
And what are the relevant parts of the requirements.txt?
And was this after a Pants version upgrade? from which version to which version?
e
yeah this was after upgrading pants version from 2.13 to 2.16 and the pex version from 2.1.62 to 2.1.140
this is the relevant part of the requirements.txt file
Copy code
python-json-logger==2.0.2
sklearn==0.0
boto3-stubs==1.18.35
imbalanced-learn==0.8.0
h
So your original dep was not correct, but I think in an earlier version of Pants it caused a dep on the entire lockfile. Anyway, you've figured out the solution.
e
oh I see. so just to confirm my understanding, in an older pants version, depending on an entire lockfile was supported, but not anymore in a later release?
h
More or less, I haven't dived deeply, but I vaguely remember semantics changes there
1
🙏 1