enough-advantage-61561
08/11/2023, 11:54 AMpants
, which would consist of one library and one app. The folder structure is
š pants-tests/
āāš apps/
ā āāš my-app/
ā āāš pyproject.toml
ā āāš BUILD
ā āāš myapp/
ā āāš __init__.py
ā āāš app.py
ā āāš BUILD
āāš .gitignore
āāš lib/
ā āāš my-pkg/
ā āāš pyproject.toml
ā āāš BUILD
ā āāš mypkg/
ā āāš __init__.py
ā āāš something.py
ā āāš BUILD
āāš pants.toml
how do you make pants
and VS Code (or other IDEs) to know about the library without using virtual environments?enough-advantage-61561
08/11/2023, 11:56 AM[GLOBAL]
pants_version = "2.16.0"
backend_packages = ["pants.backend.python"]
[source]
root_patterns = ['/lib', '/apps']
the `apps/my-app/pyproject.toml`:
[project]
dependencies = ["my-pkg"]
name = "my-app"
requires-python = ">=3.10"
description = "An app"
version = "0.1.0"
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
where = ["."]
include = ["myapp*"]
and `apps/my-app/BUILD`:
python_requirements(source="pyproject.toml")
enough-advantage-61561
08/11/2023, 11:57 AMapps/my-app/myapp/app.py
from mypkg.something import foo
def main():
foo()
if __name__ == "__main__":
main()
enough-advantage-61561
08/11/2023, 11:58 AMpants
does not see the dependency to `mypkg`:
niko@niko-ubuntu:~/tmp/pants-tests$ pants dependencies apps/my-app/myapp/app.py
14:57:23.29 [WARN] Pants cannot infer owners for the following imports in the target apps/my-app/myapp/app.py:
* mypkg.something.foo (line: 1)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/v2.16/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
niko@niko-ubuntu:~/tmp/pants-tests$ pants dependencies apps/my-app/myapp/app.py
niko@niko-ubuntu:~/tmp/pants-tests$ pants dependencies --transitive apps/my-app/myapp/app.py
niko@niko-ubuntu:~/tmp/pants-tests$
enough-advantage-61561
08/11/2023, 11:59 AMrefined-addition-53644
08/11/2023, 11:59 AMrefined-addition-53644
08/11/2023, 12:01 PMrefined-addition-53644
08/11/2023, 12:02 PMpyproject.toml
and define all dependencies there.refined-addition-53644
08/11/2023, 12:03 PMpyproject.toml
can live alongside pants.toml
enough-advantage-61561
08/11/2023, 12:06 PMpyproject.toml
, but after this dummy example, I'm trying to make pants work with project with multiple apps and libraries. Then each app might have very different requirements.refined-addition-53644
08/11/2023, 12:09 PMenough-advantage-61561
08/11/2023, 3:10 PM