refined-addition-53644
11/26/2021, 4:25 PMpyproject.toml generated by poetry using BUILD.
I am not able to generate a python distribution for internal-project1 because I think there is no main.py file and hence it doesn't show in the target list
repo
|
+-- src/
| |
| +-- internal-project1/
| | |
| | +-- pyproject.toml
| | +-- BUILD
| | +-- internal_project1/
| | |
| +-- internal-project2/
| | |
| | +-- pyproject.toml
| | +-- BUILD
| | +-- internal_project2/
| | |
+-- pants
|
+-- pants.toml
|
+-- BUILD
|
+-- requirements.txtrefined-addition-53644
11/26/2021, 4:25 PMpants.toml looks like
[GLOBAL]
pants_version = "2.8.0"
backend_packages = [
"pants.backend.python",
"pants.backend.python.lint.black",
"pants.backend.python.lint.docformatter",
"pants.backend.python.lint.flake8",
"pants.backend.python.lint.pylint",
"pants.backend.python.typecheck.mypy",
"pants.backend.python.lint.isort",
]
[source]
marker_filenames = ["pyproject.toml"]
[anonymous-telemetry]
enabled = falserefined-addition-53644
11/26/2021, 4:27 PMinternal-project1 has just
poetry_requirements()enough-analyst-54434
11/26/2021, 4:57 PM./pants tailor?: https://www.pantsbuild.org/docs/create-initial-build-filesrefined-addition-53644
11/26/2021, 5:26 PMsrc/internal-project1
to use poetry generated pyproject.toml by adding poetry_requirements()
Other than that I'm not sure what definitions I need to add. I do see it's able to generate proper targets for those python packages where it can find a main definition. The project-internal1 has no main definition anywhere. It's just bunch of python modulesenough-analyst-54434
11/26/2021, 5:38 PMpython_sources() target in each directory with non-main python sources.happy-kitchen-89482
11/26/2021, 6:40 PMhappy-kitchen-89482
11/26/2021, 6:40 PMhappy-kitchen-89482
11/26/2021, 6:41 PMrefined-addition-53644
11/28/2021, 9:36 PMsrc/internal-project1 . I am following this
https://www.pantsbuild.org/docs/python-distributions#pep-517
This is the content of BUILD. In this case ds-research is the internal-project1
resource(name="lib", source="pyproject.toml")
python_distribution(
name="ds-research",
dependencies=[":lib"],
wheel=True,
sdist=True,
provides=setup_py(
name="ds-research",
version="0.1.0",
description="DS research.",
),
wheel_config_settings={"--global-option": ["--python-tag", "py37.py38.py39"]},
)refined-addition-53644
11/28/2021, 9:40 PMrepo
|
+-- src/
| |
| +-- ds-research/
| | |
| | +-- pyproject.toml
| | +-- BUILD
| | +-- ds_research/
+-- pants
|
+-- pants.toml
|
+-- BUILD
|
+-- requirements.txt
Just to point out ds_research contains all the necessary python modules.
I am running this command from root
./pants package src/ds-research:ds-research
The error stack is shown below. I guess it's not able to identify that ds_research has the necessary modules. Not sure how to fix that.
22:39:37.59 [ERROR] 1 Exception encountered:
ProcessExecutionFailure: Process 'Run poetry.core.masonry.api for src/ds-research:ds-research' failed with exit code 1.
stdout:
stderr:
Traceback (most recent call last):
File "/private/var/folders/9w/9_4n35r57d707zkrk86rvh9w0000gn/T/process-executionwrO07k/chroot/../.cache/pex_root/venvs/693b0be1ae76a2a6f062957b1ce86976628da9ae/5ce1b5a57a6013508c623affedc7f3171959254a/pex", line 151, in <module>
exec(ast, globals_map, locals_map)
File "backend_shim.py", line 20, in <module>
wheel_path = backend.build_wheel(dist_dir, wheel_config_settings) if build_wheel else None
File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/s/e9759030/venv/lib/python3.7/site-packages/poetry/core/masonry/api.py", line 68, in build_wheel
return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))
File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/s/e9759030/venv/lib/python3.7/site-packages/poetry/core/masonry/builders/wheel.py", line 70, in make_in
poetry, target_dir=directory, original=original, executable=executable
File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/s/e9759030/venv/lib/python3.7/site-packages/poetry/core/masonry/builders/wheel.py", line 57, in __init__
super(WheelBuilder, self).__init__(poetry, executable=executable)
File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/s/e9759030/venv/lib/python3.7/site-packages/poetry/core/masonry/builders/builder.py", line 89, in __init__
includes=includes,
File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/s/e9759030/venv/lib/python3.7/site-packages/poetry/core/masonry/utils/module.py", line 77, in __init__
source=package.get("from"),
File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/s/e9759030/venv/lib/python3.7/site-packages/poetry/core/masonry/utils/package_include.py", line 22, in __init__
self.check_elements()
File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/s/e9759030/venv/lib/python3.7/site-packages/poetry/core/masonry/utils/package_include.py", line 61, in check_elements
"{} does not contain any element".format(self._base / self._include)
ValueError: /private/var/folders/9w/9_4n35r57d707zkrk86rvh9w0000gn/T/process-executionwrO07k/chroot/ds_research does not contain any element
Use --no-process-execution-local-cleanup to preserve process chroots for inspection.refined-addition-53644
11/28/2021, 9:42 PMpoetry build inside src/ds-research , it builds the distribution correctly.refined-addition-53644
11/28/2021, 9:45 PMpyproject.toml looks like
[tool.poetry]
name = "ds-research"
version = "0.1.0"
description = "data science projects"
authors = ["email-address"]
packages = [
{ include = "ds_research" },
{ include = "ds_research/**/*.py" },
]
[tool.poetry.dependencies]
python = "^3.8,<3.10"
pandas = "^1.3.0"
environs = "^9.3.2"
psycopg2 = "^2.9.1"
geopandas = "^0.9.0"
google-cloud = "^0.34.0"
pre-commit = "^2.13.0"
nbdime = "^3.1.0"
awswrangler = "^2.12.1"
pymsteams = "^0.1.16"
mygeotab = "^0.8.6"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"refined-addition-53644
11/28/2021, 9:48 PMrefined-addition-53644
11/29/2021, 11:08 AMds-research as a dependency. Is there an easier way to provide the whole folder as a dependency?
poetry_requirements()
python_distribution(
name="ds_research",
dependencies=["src/ds-research/ds_research/data:data"],
wheel=True,
sdist=True,
provides=setup_py(
name="ds_research",
version="0.1.0",
description="DS research.",
),
wheel_config_settings={"--global-option": ["--python-tag", "py37.py38.py39"]},
)refined-addition-53644
11/29/2021, 11:47 AMsetup.py generated by pants when I run
./pants package src/ds-research:ds_research
# DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
# Target: src/ds-research:ds-research
from setuptools import setup
setup(**{
'description': 'DS research.',
'install_requires': (
),
'name': 'ds-research',
'namespace_packages': (
),
'package_data': {
},
'packages': (
),
'version': '0.1.0',
})
As you can see it has no entry for packageshappy-kitchen-89482
11/29/2021, 6:46 PMhappy-kitchen-89482
11/29/2021, 9:05 PMhappy-kitchen-89482
11/29/2021, 9:07 PMresource(name="lib", source="pyproject.toml")
python_distribution(
name="ds-research",
dependencies=[":lib"],
wheel=True,
sdist=True,
provides=setup_py(
name="ds-research",
version="0.1.0",
),
wheel_config_settings={"--global-option": ["--python-tag", "py37.py38.py39"]},
)happy-kitchen-89482
11/29/2021, 9:09 PMgenerate_setup = False on that targethappy-kitchen-89482
11/29/2021, 9:09 PMhappy-kitchen-89482
11/29/2021, 9:09 PM[setup-py-generation]
generate-setup-default = falsehappy-kitchen-89482
11/29/2021, 9:10 PMhappy-kitchen-89482
11/29/2021, 9:10 PMgenerate_setup = Falsehappy-kitchen-89482
11/29/2021, 9:15 PMrefined-addition-53644
11/29/2021, 10:42 PMsetup.py with all correct 3rd party dependencies defined in pyproject.toml
repo
|
+-- src/
| |
| +-- ds-research/
| | |
| | +-- pyproject.toml
| | +-- BUILD
| | +-- ds_research/
| | | |
| | | +--- BUILD
| | | +--- data/
+-- pants
|
+-- pants.toml
|
+-- BUILD
|
+-- requirements.txt
The other issue I pointed out was that it's not able to figure out all the local dependencies for ds_research such as another package inside it called data unless I explicitly add it to the BUILD file inside ds_research . This BUILD file with explicit dependencies looks like
python_sources(dependencies=["src/ds-research/ds_research/data:data"])
I feel like this can introduce bugs if we don't actively keep adding any new package added inside ds_research to the dependencies inside the BUILD
poetry figures it out on its own such sub-packagesrefined-addition-53644
11/29/2021, 10:47 PM23:47:01.10 [ERROR] Invalid option 'generate-setup-default' under [setup-py-generation] in /Users/developer/shantanu/pyfleet/pants.toml
23:47:01.10 [ERROR] Invalid config entries detected. See log for details on which entries to update or remove.
(Specify --no-verify-config to disable this check.)
Use --print-stacktrace for more error details and/or -ldebug for more logs.
See <https://www.pantsbuild.org/v2.8/docs/troubleshooting> for common issues.
Consider reaching out for help: <https://www.pantsbuild.org/v2.8/docs/getting-help>happy-kitchen-89482
11/30/2021, 4:12 AMhappy-kitchen-89482
11/30/2021, 4:13 AMhappy-kitchen-89482
11/30/2021, 4:14 AMhappy-kitchen-89482
11/30/2021, 4:15 AMimport statement that reflects the dependency.happy-kitchen-89482
11/30/2021, 4:15 AMds_research/data imported by some file in ds_research ?happy-kitchen-89482
11/30/2021, 4:17 AMpackages = [
{ include = "ds_research" },
{ include = "ds_research/**/*.py" },
]happy-kitchen-89482
11/30/2021, 4:29 AMsources=["**/*.py"] for example)happy-kitchen-89482
11/30/2021, 4:29 AMds_research/? so there are no importshappy-kitchen-89482
11/30/2021, 4:30 AMpython_distribution target does need an explicit dependency on some python_sourceshappy-kitchen-89482
11/30/2021, 4:31 AMpython_sources(name="srcs", sources=["**/*.py"]) in the same directory as python_distribution, and have an explicit dep on :srcs.refined-addition-53644
11/30/2021, 8:29 AMsetup.py when I extract the generated tar dist locally. Please see the attached screenshotrefined-addition-53644
11/30/2021, 8:35 AMdata inside ds_research
Actually I manually added this statement in pyproject.toml when pants was failing to build the distribution and throwing error that the ds_research is empty or something. Even before that poetry was able to package them all in same dist. I suppose internally poetry does have some default packages statement.
packages = [
{ include = "ds_research" },
{ include = "ds_research/**/*.py" },
]happy-kitchen-89482
11/30/2021, 1:50 PMgenerate_setup = False on the python_distribution target?happy-kitchen-89482
11/30/2021, 1:54 PM./pants package does it log something like "Run poetry.core.masonry.api for ds_research" ?refined-addition-53644
11/30/2021, 2:11 PM./pants package I do see "Run poetry.core.masonry.api for ds_research"refined-addition-53644
11/30/2021, 2:11 PMpython_distribution options and both time, it creates setup.pyrefined-addition-53644
11/30/2021, 2:15 PMpoetry build and poetry is also generating setup.py , which I guess is expected when you are building a dist or wheel.refined-addition-53644
11/30/2021, 2:17 PMsetup.py is one generated by poetry, not pants.happy-kitchen-89482
11/30/2021, 3:54 PMhappy-kitchen-89482
11/30/2021, 3:57 PM