many-night-18726
08/21/2024, 8:50 AM$ pants test ::
08:44:52.65 [INFO] Initialization options changed: reinitializing scheduler...
08:44:56.46 [INFO] Scheduler initialized.
08:44:58.39 [INFO] Completed: List contents of artifacts produced by src/ml:ml_distribution
08:44:59.56 [INFO] Completed: Building local_dists.pex with 1 requirement: mydist-0.0.1-py3-none-any.whl
08:45:00.45 [INFO] Completed: Building pytest_runner.pex
08:45:00.45 [ERROR] 1 Exception encountered:
Engine traceback:
in `test` goal
ProcessExecutionFailure: Process 'Building pytest_runner.pex' failed with exit code 1.
stdout:
stderr:
Failed to resolve requirements from PEX environment @ /tmp/pants-sandbox-0jSube/local_dists.pex.
Needed cp312-cp312-manylinux_2_39_x86_64 compatible dependencies for:
1: setuptools
Required by:
mydist 0.0.1
But this pex had no ProjectName(raw='setuptools', validated=False, normalized='setuptools') distributions.
2: numpy
Required by:
mydist 0.0.1
But this pex had no ProjectName(raw='numpy', validated=False, normalized='numpy') distributions.
3: torch
Required by:
mydist 0.0.1
But this pex had no ProjectName(raw='torch', validated=False, normalized='torch') distributions.
My BUILD file at the package root looks like this :
python_requirements(name="ml_requirements", source="pyproject.toml", resolve="python-ml")
python_sources(name="lib", sources=["src/**/*.py"], resolve="python-ml")
resource(name="pyproject", source="pyproject.toml")
python_distribution(
name="ml_distribution",
provides=python_artifact(name="mydist"),
dependencies=[":pyproject", ":lib"],
generate_setup = False,
)
python_tests(name="tests", sources=["tests/**/test_*.py"], dependencies=[":ml_distribution", ":ml_requirements"], resolve="python-ml")
square-elephant-85438
08/21/2024, 8:28 PMpants dependencies --transitive :ml_distribution
?many-night-18726
08/21/2024, 9:13 PM3rdparty/python/ml.lock:_python-ml_lockfile
src/ml/pyproject.toml:ml_requirements
src/ml/src/ml_datasets/__init__.py:../../lib
src/ml/src/ml_datasets/placeholder.py:../../lib
src/ml/src/ml_production/__init__.py:../../lib
src/ml/src/ml_production/train.py:../../lib
src/ml/src/ml_training/__init__.py:../../lib
src/ml:ml_requirements#numpy
src/ml:ml_requirements#torch
src/ml:pyproject
brief-branch-21752
08/21/2024, 11:23 PMpython_distribution
and running tests: https://github.com/pantsbuild/pants/issues/15801many-night-18726
08/22/2024, 8:34 AM[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "mydist"
version = "0.0.1"
description = ""
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"setuptools",
"numpy",
"torch",
"pytest",
]
But if i put all my dependancies inside the optional category :
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "mydist"
version = "0.0.1"
description = ""
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
]
[project.optional-dependencies]
test = [
"setuptools",
"numpy",
"torch",
"pytest"
]
Then the tests run fine 🤔
I saw here that the optional dependancies are used as a tag : https://www.pantsbuild.org/2.20/reference/targets/python_requirements
Is there a better way to fix this issue than putting dependancies as optional ? Is this related to the --intransitive
argument and is there a way to overwrite it somehow ?