OldGrumpyViking / hatch-conda

Hatch plugin for conda environments
MIT License
38 stars 8 forks source link

environment.yml has no effect #30

Closed jklebes closed 1 month ago

jklebes commented 2 months ago

Hi, I would like to use this on my project with an existing conda environment.yml , but after following the recommended additions to pyproject.toml it does not seem to trigger conda install of the required libraries into the hatch virtual environment.

I tried this test project:

mkdir hatchtest
cd hatchtest
mkdir src
mkdir tests
mkdir src/hatchtest
touch LICENSE.txt
touch README.md
echo "__version__='0.0.1'" > src/hatchtest/__about__.py
touch src/hatchtest/__init__.py
hatch new --init

I added these lines to the bottom of pyproject.toml:

[tool.hatch.envs.testdask]
type = "conda"

[envs.testdask]
environment-file = "environment.yml"

I added this simple environment.yml:

name: testdask
channels:
  - defaults
  - conda-forge
dependencies:
  - numpy=1.21.5
  - dask

conda is present and this enivronment.yml works to create the desired environment via conda.

run hatch -e testdask shell check conda list

There is no dask etc in the conda list, but there is my project hatchtest.py 0.0.1 .

From the other issues I vaguely got the impression that it doesn't work to create the hatch environment via shell, so I also tried run in

hatch env remove testdask
hatch -e testdask run python3

, it also did not install numpy and dask.

Not sure if I'm doing it wrong (then the documentation is unclear) or if it's broken.

Thanks, Jason

imagejan commented 1 month ago

I assume it should be all under [tool.hatch.envs.testdask]:

[tool.hatch.envs.testdask]
type = "conda"
environment-file = "environment.yml"
jklebes commented 1 month ago

Thanks @imagejan , you're right, this was just a case of reading instructions too literally on my part.