handsome-sunset-98068
08/24/2022, 12:11 PMfrom decouple import config
DEBUG = config('DEBUG') == 'True'
I get this exception:
decouple.UndefinedValueError: DEBUG not found. Declare it as envvar or define a default value.
I have added .env file as prescribed by this library with content
DEBUG=True
abundant-leather-17386
08/24/2022, 12:30 PMextra_env_vars
in the python_tests
target. I would like to put an absolute path to a directory inside the chroot in an environment variable. Does anyone have an idea how I can achieve this?flat-zoo-31952
08/24/2022, 2:25 PMancient-france-42909
08/24/2022, 2:40 PMpython_sources
that groups stuff, like pex_binaries
and files
, if I put that in the dependencies
for a docker_image
, will they be copied in? Just trying it out seems to suggest, no… How can we group things that we want to put in multiple docker_image
s then?handsome-sunset-98068
08/24/2022, 2:45 PM./pants run projects/appsflyer/:manage -- createsuperuser
throws:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
my settings.py file:
...
...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': '<database_name>',
'USER': '<database_username>',
'PASSWORD': '<password>',
'HOST': '<database_hostname_or_ip>',
'PORT': '<database_port>',
}
}
BUILD
python_sources()
resource(
name="env",
source=".env"
)
pex_binary(
name="manage",
entry_point="manage.py",
dependencies=[
"./appsflyer:appsflyer",
":env"
],
restartable=True
)
incalculable-hydrogen-44003
08/24/2022, 4:57 PMbored-glass-58755
08/24/2022, 5:57 PMPANTS_SETUP_CACHE
, would it automatically change the variables local_store_dir
and named_caches_dir
to correspond to the new setup location? Or would these variables still refer to the default ~/.cache/pants/
directory?bored-glass-58755
08/24/2022, 8:32 PMPEX_ROOT
at the time of bootstrapping?calm-ambulance-65371
08/24/2022, 9:42 PM[python-repo].indexes.add
stuff. Any thoughts?cold-sugar-54376
08/25/2022, 12:21 AMpython_distribution
as a first party dependency in other code? i have a repo that looks something like this:
- src
- internal_lib
- setup.py
- internal_lib
- __init__.py (and other files)
- other_app:
python files that ideally do import internal_lib.asdf
internal_lib has a python_distribution
in its BUILD
file, so i’d basically like to be able to just do import internal_lib.module
in my other src
code instead of having to do import internal_lib.internal_lib
. The reason I need it to be an actual distribution is so I can distribute that code elsewhere as well.faint-waitress-55925
08/25/2022, 12:54 PM./pants generate-lockfiles --resolve=python-default
, the execution is stucked and I don't know what to do. Usually it takes 1mn30 to finish, but after trying several things, I wait more than 20min and nothing changes. I use Pants 2.12.0 and I'm on Ubuntu (WSL on Windows 11). I didn't change my lockfile and it only happens on python-default
, no problem with black
, flake8
, etc. Any suggestion?incalculable-hydrogen-44003
08/25/2022, 3:49 PMFROM python:3.8-buster
and somebody runs ./pants run src/${appname}
we get an error saying /usr/bin/env: 'python3.9': No such file or directory
I do have 3..9 installed locally, but not 3.8. We can fix this error by changing the python version to FROM python:3.9-buster
. Does pants use your local python install when running docker?happy-pizza-30507
08/25/2022, 4:57 PMpants generate-lockfiles
with poetry backend, how can I resolve the dependencies for multiple platforms in requirements.txt? Specifically I find that the lockfile, which is generated from linux by other team mate, is missing a few hashes that are needed on m1, causing the build to fail. Not sure if I have done anything obviously wrong here. Thanks!future-oxygen-10553
08/25/2022, 6:49 PMpython_distribution
target and handling PEP 517 compliant backends. I have two specific problems, which are both demonstrated in this repo: https://github.com/bryanwweber/pep621-pants-test
First, running ./pants package src/test-flit::
, I get an error:
14:48:33.97 [ERROR] 1 Exception encountered:
Engine traceback:
in select
in pants.core.goals.package.package_asset
in pants.backend.python.goals.setup_py.package_python_dist (src/test-flit:test-flit)
in pants.backend.python.util_rules.dists.run_pep517_build
in pants.engine.process.fallible_to_exec_result_or_raise
Traceback (most recent call last):
File "/Users/bweber/.cache/pants/setup/bootstrap-Darwin-arm64/pants.MAN743/install/lib/python3.9/site-packages/pants/engine/process.py", line 272, in fallible_to_exec_result_or_raise
raise ProcessExecutionFailure(
pants.engine.process.ProcessExecutionFailure: Process 'Run flit_core.buildapi for src/test-flit:test-flit' failed with exit code 1.
stdout:
stderr:
Traceback (most recent call last):
File "/private/var/folders/zj/p64fbz8d6nd6st_w625_cf7r0000gq/T/pants-sandbox-MxaxV1/chroot/src/test-flit/../../../.cache/pex_root/venvs/31101af6a39067ea0ded21c13e22768ab8004113/c6158e3f0f08aecef5110af6fc1a7d94053f2bee/pex", line 229, in <module>
exec(ast, globals_map, locals_map)
File "backend_shim.py", line 16, in <module>
wheel_path = backend.build_wheel(dist_dir, wheel_config_settings) if build_wheel else None
File "/Users/bweber/.cache/pants/named_caches/pex_root/venvs/31101af6a39067ea0ded21c13e22768ab8004113/c6158e3f0f08aecef5110af6fc1a7d94053f2bee/lib/python3.10/site-packages/flit_core/buildapi.py", line 72, in build_wheel
info = make_wheel_in(pyproj_toml, Path(wheel_directory))
File "/Users/bweber/.cache/pants/named_caches/pex_root/venvs/31101af6a39067ea0ded21c13e22768ab8004113/c6158e3f0f08aecef5110af6fc1a7d94053f2bee/lib/python3.10/site-packages/flit_core/wheel.py", line 219, in make_wheel_in
(fd, temp_path) = tempfile.mkstemp(suffix='.whl', dir=str(wheel_directory))
File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tempfile.py", line 341, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tempfile.py", line 256, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/zj/p64fbz8d6nd6st_w625_cf7r0000gq/T/pants-sandbox-MxaxV1/chroot/src/test-flit/dist/tmplaw_7nkj.whl'
future-oxygen-10553
08/25/2022, 8:00 PMpython_distribution
? Do I need to list all of them individually? Or is there some way to say “All python_source()
targets which are in subdirectories of this BUILD
file”?ancient-rose-27306
08/25/2022, 8:19 PMpex_binary()
with following definition:
pex_binary(
name="greeter_server",
entry_point="greeter_server.py:main",
)
It builds fine and I am able to use it on my local machine. Moving a step ahead, I am building a docker_image()
with this pex:
docker_image(
name="docker-server",
dependencies=[":greeter_server"],
)
and the contents of Dockerfile are:
FROM python:3.7
RUN mkdir /app
WORKDIR /app
COPY src.server/greeter_server.pex /app/
EXPOSE 50051
CMD ["/app/greeter_server.pex"]
The Docker build works fine too but when I do docker run -it docker-server
, I end up in an error and the pex doesn’t execute:
(pants) [root@9a5752857756 pants-training]# docker run -it docker-server
Failed to find compatible interpreter on path /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.
Examined the following interpreters:
1.) /usr/local/bin/python3.7 CPython==3.7.13
2.) /usr/bin/python3.9 CPython==3.9.2
No interpreter compatible with the requested constraints was found:
A distribution for grpcio could not be resolved for /usr/local/bin/python3.7.
Found 1 distribution for grpcio that do not apply:
1.) The wheel tags for grpcio 1.47.0 are cp37-cp37m-macosx_10_10_x86_64 which do not match the supported tags of /usr/local/bin/python3.7:
cp37-cp37m-manylinux_2_31_x86_64
... 535 more ...
(pants) [root@9a5752857756 pants-training]#
I could provide the platforms
arg for pex_binary()
target but want to understand the reason that pex was working directly but not inside a container on the same machine. Could you please help?flaky-artist-57016
08/25/2022, 9:44 PMtailor
, lint
, and test
in the same runner. We’ve found that this intermittently results in the failure of one or more of the jobs with the error message ModuleNotFoundError: No module named 'pants'
. Re-running the failed job typically allows it to complete successfully so we suspect that this is being caused by our use of concurrent stages. We are running concurrently to reduce the time the pipeline runs, but perhaps it makes more sense to run these steps serially (i.e., to catch missing BUILD files before running the lint and test steps). Is there a better way we should be running pants in CI? Thanks in advance!gorgeous-addition-6562
08/25/2022, 11:02 PMrequirements.txt
is like this
bagpy
roslz4 --extra-index-url <https://rospypi.github.io/simple/>
Using that in a venv with pip works fine for my app. But pants
seems to not able to pick up the extra url:
stderr:
ERROR: Could not find a version that satisfies the requirement roslz4
ERROR: No matching distribution found for roslz4
pid 1205759 -> /home/aghosh/.cache/pants/named_caches/pex_root/venvs/b16167dce033b47f1a773c13706cbea19b1a1591/ddab8011daaee380698ac2fb9701af18c90c03f6/pex --disable-pip-version-check --no-python-version-warning --exists-action a --isolated -q --cache-dir /home/aghosh/.cache/pants/named_caches/pex_root --log /tmp/process-executionqu5xHv/.tmp/pex-pip-logz29_sdf0/pip.log download --dest /tmp/process-executionqu5xHv/.tmp/tmpjrywxg8u/usr.bin.python3.8 bagpy roslz4 --index-url <https://pypi.org/simple/> --retries 5 --timeout 15 exited with 1 and STDERR:
None
How do I fix this problem? Look like pex
has option to pick up --extra-index-url
as well, but my guess is pants
doesn't pass that to pex
?
More context: https://stackoverflow.com/questions/58754968/failed-to-load-python-extension-for-lz4-support-lz4-compression-will-not-be-avaincalculable-grass-76623
08/26/2022, 12:09 AM/src/<prod code>
/tests/test_<test-foo>.py
/sub-tests/test_<other-foo>.py
/util/utility_for_tests.py
/req.txt
/req..-test.txt
I am struggling to get the paths and source includes in the BUILD files correct
I have currently
/BUILD
/src/BUILD
/tests/BUILD
incalculable-grass-76623
08/26/2022, 12:10 AMincalculable-grass-76623
08/26/2022, 12:10 AMincalculable-grass-76623
08/26/2022, 12:10 AMincalculable-grass-76623
08/26/2022, 12:10 AMquaint-forest-8735
08/26/2022, 12:21 AMpex
CLI again to produce the same pex w/ the extra file. This seems brittle, so was curious if there's any functionality in PexBuilder
that could make this cleanerancient-rose-27306
08/26/2022, 2:59 AM./pants tailor --check update-build-files --check
and ./pants tailor --check
?strong-refrigerator-32393
08/26/2022, 8:19 AM./pants package build-recipees/amazon_cancelations/Dockerfile
03:14:35.54 [INFO] Initializing scheduler...
03:14:35.71 [INFO] Scheduler initialized.
03:14:35.75 [WARN] Please either set `enabled = true` in the [anonymous-telemetry] section of pants.toml to enable sending anonymous stats to the Pants project to aid development, or set `enabled = false` to disable it. No telemetry sent for this run. An explicit setting will get rid of this message. See <https://www.pantsbuild.org/v2.12/docs/anonymous-telemetry> for details.
03:14:43.55 [INFO] Completed: Building dockerfile_parser.pex from dockerfile-parser_default.lock
03:14:43.55 [ERROR] 1 Exception encountered:
ProcessExecutionFailure: Process 'Building dockerfile_parser.pex from dockerfile-parser_default.lock' failed with exit code 1.
stdout:
stderr:
Traceback (most recent call last):
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/unzipped_pexes/6059500ace72ed792367231dcc84ab6e7c3b99f0/.bootstrap/pex/pex.py", line 517, in execute
exit_value = self._wrap_coverage(self._wrap_profiling, self._execute)
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/unzipped_pexes/6059500ace72ed792367231dcc84ab6e7c3b99f0/.bootstrap/pex/pex.py", line 422, in _wrap_coverage
return runner(*args)
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/unzipped_pexes/6059500ace72ed792367231dcc84ab6e7c3b99f0/.bootstrap/pex/pex.py", line 453, in _wrap_profiling
return runner(*args)
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/unzipped_pexes/6059500ace72ed792367231dcc84ab6e7c3b99f0/.bootstrap/pex/pex.py", line 576, in _execute
EntryPoint.parse("run = {}".format(self._pex_info.entry_point))
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/unzipped_pexes/6059500ace72ed792367231dcc84ab6e7c3b99f0/.bootstrap/pex/pex.py", line 757, in execute_entry
return self.execute_entry_point(entry_point)
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/unzipped_pexes/6059500ace72ed792367231dcc84ab6e7c3b99f0/.bootstrap/pex/pex.py", line 788, in execute_entry_point
return runner()
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/installed_wheels/6242b902db69f59e1092b406655c0fb1634486c47ce563f5fd27277cf4561822/pex-2.1.90-py2.py3-none-any.whl/pex/bin/pex.py", line 768, in main
env=env,
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/installed_wheels/6242b902db69f59e1092b406655c0fb1634486c47ce563f5fd27277cf4561822/pex-2.1.90-py2.py3-none-any.whl/pex/bin/pex.py", line 788, in do_main
cache=ENV.PEX_ROOT,
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/installed_wheels/6242b902db69f59e1092b406655c0fb1634486c47ce563f5fd27277cf4561822/pex-2.1.90-py2.py3-none-any.whl/pex/bin/pex.py", line 649, in build_pex
max_parallel_jobs=pip_configuration.max_jobs,
File "/Users/gleiryserrano/.cache/pants/named_caches/pex_root/installed_wheels/6242b902db69f59e1092b406655c0fb1634486c47ce563f5fd27277cf4561822/pex-2.1.90-py2.py3-none-any.whl/pex/result.py", line 84, in try_
raise ResultError(error=result)
pex.result.ResultError: There was 1 error downloading required artifacts:
1. dockerfile 3.2 from <https://files.pythonhosted.org/packages/9e/19/0f56ebd6d535832bfbe7c4f16c983c08ab8e01927fe9ae15e1afcfa88996/dockerfile-3.2.0-cp36-abi3-macosx_10_14_x86_64.whl>
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)>
plain-truck-80265
08/26/2022, 9:42 AMBUILD
files? Seems it is not working for me, so I am just want to be sure 🙂 .user
08/26/2022, 12:16 PMbumpy-spoon-55438
08/26/2022, 1:38 PMbuf
directly with the command line argument, it works. so how to correctly exclude paths in pants?
[buf]
lint_args = [
"--exclude-path=something",
]
billions-bear-56484
08/26/2022, 2:38 PM- ./pants
- src
- python
- shared
- BUILD
- logging
- BUILD
- config.json
- accounts
- BUILD
- api
- server.py
- ...
What I want to do is to include the config.json
into the accounts package to be able to use a shared logging configuration.
This is the BUILD file in src/python/shared/logging
resource(
name="config",
source="config.json",
)
This is my pex_binary
in src/python/accounts/BUILD
where I want to use the config.json
pex_binary(
name="serve",
restartable=True,
dependencies=[
"src/python/shared/logging:config",
":sources",
],
entry_point="api/server.py",
shebang="/usr/bin/env python3",
)
```
If I got it right from documentation I should be able to set the path relative from the source root. In my case I have the `api/server.py` where I’m launching a uvicorn server with the following command:
```if __name__ == "__main__":
uvicorn.run(
get_app(),
host="0.0.0.0",
port=8000,
log_config="config.json",
)
What is the source root in that case? Currently I always get the error FileNotFoundError: [Errno 2] No such file or directory: 'config.json'
.
Thanks in advance ☀️