lively-dusk-46231
10/24/2022, 8:16 AMpackage
, the setuptools
integration and setuptools_scm
parts too
Current setup: We have setup.py
and pyproject.toml
. With setuptools_scm
I tried:
$ cat BUILD
python_sources(name='source', sources=['my_api/**/*.py'])
vcs_version(
name='version',
generate_to='my_api/_version.py',
template='version = {version}',
)
resource(name='pyproject', source='pyproject.toml')
python_distribution(
name='my-api',
dependencies=[
':pyproject',
':version',
],
provides=python_artifact(name='my-api'),
sdist=False,
generate_setup=False,
)
And then did: ./pants package ::
It threw an error about setuptools_scm
:
LookupError: setuptools-scm was unable to detect version for /tmp/pants-sandbox-hVjRo4/chroot.
So, I removed setuptools_scm
from my pyproject.toml
Then again ran: ./pants package ::
This is generating dist/UNKNOWN-0.0.0-py3-none-any.whl
And I can't figure out why the name/version is incorrect
Any thoughts ?lively-dusk-46231
10/24/2022, 8:20 AM"pants.backend.experimental.python"
bitter-ability-32190
10/24/2022, 10:29 AM--keep-sandboxes
./pants --keep-sandboxes=always package <target>
will leak the sandboxes pants used to run processes. The last one logged is usually the one you're looking for (the process description is logged too).
And if it doesn't leak and log, it's likely a cache issue. Just add a comment or whitespace to the file and try againbitter-ability-32190
10/24/2022, 10:29 AM__run.sh
which is made to run the process exactly like pants didhappy-kitchen-89482
10/24/2022, 3:14 PM':version'
needs to be a dep of the python_sources
that owns your setup.py
happy-kitchen-89482
10/24/2022, 3:15 PMmy_api/setup.py
, that would be the python_sources()
in your BUILD file, not the python_distribution()
happy-kitchen-89482
10/24/2022, 3:16 PMhappy-kitchen-89482
10/24/2022, 3:21 PMlively-dusk-46231
10/24/2022, 3:30 PMpython_sources()
🙂
I don't think it would have mattered because my setup.py is just adding some extra setup.py commands for pybabel translations
But I added: python_sources(name='setup', sources=['setup.py'], dependencies=[':version'])
which didn't help
Will try --keep-sandboxes
and check whats going onlively-dusk-46231
10/24/2022, 3:37 PMlively-dusk-46231
10/24/2022, 4:05 PM$ unzip -l dist/UNKNOWN-0.0.0-py3-none-any.whl.zip
Archive: dist/UNKNOWN-0.0.0-py3-none-any.whl.zip
Length Date Time Name
--------- ---------- ----- ----
132 2022-10-24 15:29 UNKNOWN-0.0.0.dist-info/METADATA
92 2022-10-24 15:29 UNKNOWN-0.0.0.dist-info/WHEEL
1 2022-10-24 15:29 UNKNOWN-0.0.0.dist-info/top_level.txt
296 2022-10-24 15:29 UNKNOWN-0.0.0.dist-info/RECORD
--------- -------
521 4 files
Which is again weird, cause I have:
python_sources(name='source', sources=['my_api/**/*.py'])
resource(name='pyproject', source='pyproject.toml')
python_sources(name='setup', sources=['setup.py'], dependencies=[':version'])
python_distribution(
name='my-api',
dependencies=[
':pyproject',
':setup',
':source', # <----- Should have added my code ?
],
provides=python_artifact(name='my-api'),
sdist=False,
generate_setup=False,
)
I also have this in setup.cfg
[options]
packages = find_namespace:
[options.packages.find]
include = my_api, my_api.*