gentle-florist-96289
08/10/2023, 6:31 AMpants for a mono repo in my project. The repository still does not have a build system yet. The requirement for me is to migrate existing libraries which are packaged using setuptools and setuptools-scm with pyproject.toml. I followed the documentation and created the BUILD file for the project. However, pants is not able to create a package from the source code. Below is the error that I get:
config = read_configuration(filepath, True, ignore_option_errors, dist)
usage: backend_shim.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: backend_shim.py --help [cmd1 cmd2 ...]
or: backend_shim.py --help-commands
or: backend_shim.py cmd --help
error: invalid command 'bdist_wheel'
Can anyone help me resolve this issue?lemon-yak-80782
08/10/2023, 7:54 AMBUILD file, or all BUILD files?gentle-florist-96289
08/10/2023, 8:13 AM.
├── my-lib
│ ├── BUILD
│ ├── lib
│ │ ├── __init__.py
│ │ └── main.py
│ └── pyproject.toml
└── pants.toml
The contents of BUILD is as shown below:
resource(name="pyproject", source="pyproject.toml")
python_distribution(
name="my-lib",
dependencies=[
":pyproject",
# Dependencies on code to be packaged into the distribution.
],
provides=python_artifact(
name="my-lib",
),
# Example of setuptools config, other build backends may have other config.
wheel_config_settings={"--build-option": ["--python-tag", "py310.py311"]},
)gentle-florist-96289
08/10/2023, 9:00 AMbdist_wheel I had to inlcude wheel in the requirements of the build-system. Now however I get a different error that it cannot find the package lib. My pyproject.toml is something like this.
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "my-lib"
authors = [
{name = "Shravan Kulkarni"},
]
description = "sample lib"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = ["numpy", "sqlalchemy"]
version="0.0.1.dev"
[tool.setuptools]
packages = ["lib"]
The error I get now is
config = read_configuration(filepath, True, ignore_option_errors, dist)
error: package directory 'lib' does not existlemon-yak-80782
08/10/2023, 9:22 AMpants requires a build in every folder. Call pants tailor :: this should create the missing BUILD file and add some required targets.
Regarding the python_distribution target I think you should change your weel_config_settings to wheel_config_settings={"--global-option": ["--python-tag", "py39"]}. Further, try to set generate_setup=True if you want pants to infer information from your pyproject.toml .wide-midnight-78598
08/10/2023, 5:50 PMlemon-yak-80782
08/10/2023, 5:54 PMhappy-kitchen-89482
08/10/2023, 10:42 PMgentle-florist-96289
08/11/2023, 5:04 AMpants tailor :: and adapted the BUILD file as mentioned above. It still gives an error that the lib package doesnt exist.lemon-yak-80782
08/11/2023, 9:34 AMtailor does most of the work for the developer it is not to big of a pain, for me at least. Further, compared to bazel it is not even in the same league. In its current state, would you suggest using one BUILD file per directory, or as @wide-midnight-78598 does it one per service/project leveraging recursive globs?lemon-yak-80782
08/11/2023, 9:37 AMpython_sources target look. I think you have to add the lib package as dependency in your python_distribution .gentle-florist-96289
08/11/2023, 9:54 AM:lib in python_distribution as a dependency, and it worked. Thanks.
@wide-midnight-78598 How to use recursive globs without creating multiple BUILD files?lemon-yak-80782
08/11/2023, 10:09 AMsource in the python_sources target. For example: foo/**/*.py .gentle-florist-96289
08/11/2023, 10:25 AM["lib/**/*.py"] and if I have nested directories inside lib, it doesn't copy them correctly in the chroot directory in the temp. I get the contents of the lib folder in the chroot at the same level as pyproject.toml and it doesn't copy the inner directories.lemon-yak-80782
08/11/2023, 11:01 AM// or /) should help.gentle-florist-96289
08/11/2023, 11:19 AMpython_sources only accepts *.py files. I have some json and sqlite3 files that do not get packaged. I believe these files should be created as a separate source and add as a dependency in the python_distribution. Can you please help with this?gentle-florist-96289
08/11/2023, 11:45 AMjson data as well. 👍lemon-yak-80782
08/11/2023, 11:55 AMhappy-kitchen-89482
08/11/2023, 3:24 PMoverrides={...} field) but it's a bit more clunky if you have many of them.happy-kitchen-89482
08/11/2023, 3:25 PM