hatch icon indicating copy to clipboard operation
hatch copied to clipboard

hatch build fails with default env matrix

Open aminalaee opened this issue 2 years ago • 4 comments

Hey,

First of all, thanks for this great tool. I'm not sure if this is a wrong usage or just an issue with hatch, but the following configuration fails:

[tool.hatch.envs.default]
dependencies = [
    "pytest",
]

[tool.hatch.envs.default.scripts]
# some commands

[[tool.hatch.envs.default.matrix]]
sqlalchemy = ["1.4", "2.0"]

Then running hatch build fails with the following error:

Unknown environment: default

But if you change the environment name from default to something else, it works fine:

[tool.hatch.envs.test]
dependencies = [
    "pytest",
]

[tool.hatch.envs.test.scripts]
# some commands

[[tool.hatch.envs.test.matrix]]
sqlalchemy = ["1.4", "2.0"]

Apparently it has something to do with the default environment and adding matrix option to it.

aminalaee avatar Jan 30 '23 09:01 aminalaee

I had the same problem.

ischaojie avatar Jan 30 '23 10:01 ischaojie

Thanks I will fix this

ofek avatar Jan 30 '23 13:01 ofek

I'm facing the same issue when trying to build for several mypyc targets.

I work around it by adding this to the toml:

[tool.hatch.envs.test]
dependencies = [
  "pytest",
  "pytest-cov",
  "build"
]

[tool.hatch.envs.default.scripts]
version = "python --version"
cov = "pytest --cov-report=term --cov-config=pyproject.toml"
no-cov = "cov --no-cov {args}"
build = "python -m build"

[[tool.hatch.envs.test.matrix]]
python = [ "38", "39", "310", "311"]

and then building with:

hatch run test:build

Rather silly to add build as a dependency and then use a matrix from another environment (Though I'm sure you could also use matrix + default) but as a workaround this is fine.

icfly2 avatar Feb 10 '23 11:02 icfly2

The problem seems to be linked to use of the environment matrix in the pyproject.toml. Without using it, the command "hatch env show" prints the default environment as a standalone environment .

If you use "hatch build" without the environment matrix it will work.

I tried to use the following command based on the last comment but i got a "Permission denied" error on use.

hatch run default:build

KinkosPouet avatar Feb 29 '24 03:02 KinkosPouet