powerful-eye-58407
01/05/2024, 1:09 PMpython_distribution
is it expected that created wheel only requires (depends on) by default on things that are directly imported?powerful-eye-58407
01/05/2024, 1:09 PMpandera
, and that depends on pydantic
powerful-eye-58407
01/05/2024, 1:09 PMpowerful-eye-58407
01/05/2024, 1:10 PMpandera==0.11.0
pydantic==1.10.13
powerful-eye-58407
01/05/2024, 1:10 PMMetadata-Version: 2.1
Name: main
Version: 1.0.0
Author: Pantsbuild
Requires-Python: >=3.8.0
Requires-Dist: pandera (==0.11.0)
powerful-eye-58407
01/05/2024, 1:11 PMpowerful-eye-58407
01/05/2024, 1:12 PMpython_distribution
, otherwise it's not automatically included in created wheelpowerful-eye-58407
01/05/2024, 1:13 PMpython_distribution(
name="wheel",
dependencies=[
"src/main.py",
],
sdist=False,
wheel=True,
provides=python_artifact(
name="main",
author="Pantsbuild",
python_requires=">=3.8.0",
version="1.0.0"
),
)
this is what I have in BUILD file so far, and main.py looks like below:
import pandera as pa
def main():
print("Hello World!")
if __name__ == "__main__":
main()
powerful-eye-58407
01/05/2024, 1:19 PMpandera==0.11.0
in a fresh venv produces this:
$ pip list
Package Version
----------------- ------------
annotated-types 0.6.0
mypy-extensions 1.0.0
numpy 1.26.3
packaging 23.2
pandas 2.1.4
pandera 0.11.0
pip 23.0.1
pyarrow 14.0.2
pydantic 2.5.3
pydantic_core 2.14.6
python-dateutil 2.8.2
pytz 2023.3.post1
setuptools 66.1.1
six 1.16.0
typing_extensions 4.9.0
typing-inspect 0.9.0
tzdata 2023.4
wrapt 1.16.0
so clearly pydantic is installed with pandera, but pants has no way of figuring this out if it's not imported directly, correct?powerful-eye-58407
01/05/2024, 1:19 PMsquare-psychiatrist-19087
01/05/2024, 4:39 PMinstall_requires
of your python distribution, but you don't actually import or use it directly, right?powerful-eye-58407
01/05/2024, 4:41 PMsquare-psychiatrist-19087
01/05/2024, 4:43 PMsquare-psychiatrist-19087
01/05/2024, 4:44 PMsquare-psychiatrist-19087
01/05/2024, 4:47 PMpowerful-eye-58407
01/05/2024, 4:50 PMpowerful-eye-58407
01/05/2024, 4:51 PMsquare-psychiatrist-19087
01/05/2024, 4:52 PMpowerful-eye-58407
01/05/2024, 4:52 PMsquare-psychiatrist-19087
01/05/2024, 4:54 PMrequirements.txt
my-util-library==0.10.3
pydantic<2
Then install with pip install -r requirements.txt
powerful-eye-58407
01/05/2024, 4:54 PMpowerful-eye-58407
01/05/2024, 4:58 PMThen you can try to add it manually when you install your library
I add it to dependencies in BUILD file for python_distribution target and that solves it, but I wondered if there's a better way, it may not be the only pinned requirement to add there
square-psychiatrist-19087
01/05/2024, 4:58 PMpython_distribution(
...
dependencies=["requirements-target:pydantic"]
)
(Replace requirements target with the actual path)
This should add it manually
But again, logically I would add the constraint on install sidepowerful-eye-58407
01/05/2024, 4:59 PMsquare-psychiatrist-19087
01/05/2024, 5:03 PM