bland-yak-74764
04/05/2022, 7:50 PMcoolcompany.lib1
) ? Is there a demo project anywhere that shows how to do this? I currently have a project that was inspired by this: https://medium.com/@jherreras/python-microlibs-5be9461ad979 which I am attempting to migrate to pants. Goal is to have all company packages in same namespace, with option to install a subset of them (and by extension their respective subdependencies).hundreds-father-404
04/05/2022, 8:08 PMechoing-farmer-15630
04/05/2022, 8:36 PMbland-yak-74764
04/05/2022, 9:14 PMbland-yak-74764
04/05/2022, 9:15 PM$ ./pants roots
I get
.
python_projects/acme_corp/app1/src
python_projects/acme_corp/lib1/src
which I think is what I wanthundreds-father-404
04/05/2022, 9:16 PMfrom acme_corp.lib.lib1_module
. What is the full file path that that should be coming from?hundreds-father-404
04/05/2022, 9:18 PMbland-yak-74764
04/05/2022, 9:19 PMlib1_module
would be python_projects/acme_corp/lib1/src/acme_corp/lib1/lib1_module.py
bland-yak-74764
04/05/2022, 9:21 PMlib1
and app1
each a separate "project", which could use poetry or pip.bland-yak-74764
04/05/2022, 9:23 PMhundreds-father-404
04/05/2022, 9:25 PMbland-yak-74764
04/05/2022, 9:28 PM$ ./pants run python_projects/acme_corp/lib1:lib1_pex
Traceback (most recent call last):
File "/c/Users/AshleyShultz/.cache/pants/named_caches/pex_root/unzipped_pexes/6151344b859fa5ca6377ed7f6029524c286be3a6/.bootstrap/pex/pex.py", line 503, in execute
exit_value = self._wrap_coverage(self._wrap_profiling, self._execute)
File "/c/Users/AshleyShultz/.cache/pants/named_caches/pex_root/unzipped_pexes/6151344b859fa5ca6377ed7f6029524c286be3a6/.bootstrap/pex/pex.py", line 408, in _wrap_coverage
return runner(*args)
File "/c/Users/AshleyShultz/.cache/pants/named_caches/pex_root/unzipped_pexes/6151344b859fa5ca6377ed7f6029524c286be3a6/.bootstrap/pex/pex.py", line 439, in _wrap_profiling
return runner(*args)
File "/c/Users/AshleyShultz/.cache/pants/named_caches/pex_root/unzipped_pexes/6151344b859fa5ca6377ed7f6029524c286be3a6/.bootstrap/pex/pex.py", line 559, in _execute
return self.execute_entry(self._pex_info.entry_point)
File "/c/Users/AshleyShultz/.cache/pants/named_caches/pex_root/unzipped_pexes/6151344b859fa5ca6377ed7f6029524c286be3a6/.bootstrap/pex/pex.py", line 695, in execute_entry
return self.execute_pkg_resources(entry_point)
File "/c/Users/AshleyShultz/.cache/pants/named_caches/pex_root/unzipped_pexes/6151344b859fa5ca6377ed7f6029524c286be3a6/.bootstrap/pex/pex.py", line 726, in execute_pkg_resources
runner = entry.resolve()
File "/c/Users/AshleyShultz/.cache/pants/named_caches/pex_root/unzipped_pexes/6151344b859fa5ca6377ed7f6029524c286be3a6/.bootstrap/pex/vendor/_vendored/setuptools/pkg_resources/__init__.py", line 2481, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'acme_corp'
hundreds-father-404
04/05/2022, 9:29 PMbland-yak-74764
04/05/2022, 9:36 PM./pants tailor
which added BUILD files which I was evidently missing, and that fixed it. 😎hundreds-father-404
04/05/2022, 9:38 PMbland-yak-74764
04/05/2022, 10:16 PMpython_sources
will automatically "name" itself after its parent directory. Is it okay to override this to make it use the namespace prefix? I think I gain something by labeling this package by the way it will be imported, but not sure if I'm breaking the rules:bland-yak-74764
04/05/2022, 10:18 PMhundreds-father-404
04/05/2022, 10:20 PMbland-yak-74764
04/05/2022, 10:21 PMhundreds-father-404
04/05/2022, 10:23 PMbland-yak-74764
04/05/2022, 10:27 PMhundreds-father-404
04/05/2022, 10:33 PM:target_name
)bland-yak-74764
04/05/2022, 10:37 PMentry_point
I didn't have src
on there when I was using the dot notation, but when I use a path to the file I need to add it.hundreds-father-404
04/05/2022, 10:38 PMhundreds-father-404
04/05/2022, 10:39 PMbland-yak-74764
04/05/2022, 10:40 PMbland-yak-74764
04/05/2022, 10:41 PMpex_binary
and the python_distribution
in the BUILD that is a sibling of the actual code?hundreds-father-404
04/05/2022, 10:41 PMhundreds-father-404
04/05/2022, 10:42 PMso, should I put the pex_binary and the python_distribution in the BUILD that is a sibling of the actual code?it's not required to do that, but it's generally how folks would do this. (Pants will work just fine either way)
bland-yak-74764
04/05/2022, 10:54 PMpython_sources
name? If I changed python_sources(name='acme_corp.lib1')
to python_sources(name='some.random.prefixes.lib1')
, would that affect how I import the library from from acme_corp.lib1.lib1_module import lib1_func
to from some.random.prefixes.lib1.lib1_module import lib1_func
?bland-yak-74764
04/05/2022, 10:58 PMhundreds-father-404
04/05/2022, 11:02 PMhundreds-father-404
04/05/2022, 11:03 PMbland-yak-74764
04/05/2022, 11:12 PMhappy-kitchen-89482
04/06/2022, 12:18 AMpex_binary
target) but it has no effect on naming inside your code, e.g., imports.happy-kitchen-89482
04/06/2022, 12:19 AM