Skip to content

Commit 44e39ab

Browse files
authored
allow env=<relative path>, relative to current project (#201)
* allow env=<relative path>, relative to current project * test against newer pydantic old version was incompatible with python 3.14 --------- Co-authored-by: Christopher Doris <github.com/cjdoris>
1 parent 5d9b227 commit 44e39ab

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
* If the `env` preference (or `JULIA_CONDAPKG_ENV`) can now be a relative path, which is
5+
taken to be relative to the current Julia project.
6+
37
## 0.2.33 (2025-09-18)
48
* Add `[dev]` section to CondaPkg.toml, specifying development dependencies which are only
59
installed for packages being developed/tested.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ By default, CondaPkg installs Conda packages into the current project, so that d
226226
projects can have different dependencies. If you wish to centralize the Conda environment,
227227
you can set one of these preferences:
228228
- `env=@<name>` for a named shared environment, stored in `~/.julia/conda_environments/<name>`.
229-
- `env=<some absolute path>` for a shared environment at the given path.
229+
- `env=<some path>` for a shared environment at the given path. If the path is relative,
230+
it is taken to be relative to the current Julia project, e.g if you have `conda-env/` in
231+
the same folder as `Project.toml` then set `env=conda-env`.
230232
- `backend=Current` to use the currently activated Conda environment.
231233

232234
**Warning:** If you do this, the versions specified in a per-julia-version `CondaPkg.toml`

src/resolve.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,9 @@ function resolve(;
848848
conda_env = joinpath(Base.DEPOT_PATH[1], "conda_environments", conda_env_name)
849849
shared = true
850850
else
851-
isabspath(conda_env) || error("shared env must be an absolute path")
851+
if !isabspath(conda_env)
852+
conda_env = joinpath(dirname(Base.active_project()), conda_env)
853+
end
852854
occursin(".CondaPkg", conda_env) &&
853855
error("shared env must not be an existing .CondaPkg, select another directory")
854856
shared = true

test/main.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ end
143143
end
144144

145145
# install package without extras
146-
CondaPkg.add_pip("pydantic", version = "==2.9.2")
146+
CondaPkg.add_pip("pydantic", version = "==2.12.2")
147147
@test occursin("pydantic", status())
148-
@test occursin("(==2.9.2)", status())
148+
@test occursin("(==2.12.2)", status())
149149
CondaPkg.withenv() do
150150
isnull || run(`python -c "import pydantic"`)
151151
# fails on Windows sometimes - not sure why
@@ -154,17 +154,17 @@ end
154154
Sys.iswindows() ||
155155
@test_throws Exception run(`python -c "import email_validator"`)
156156
end
157-
@test occursin("v2.9.2", status()) == !isnull
157+
@test occursin("v2.12.2", status()) == !isnull
158158

159159
# install package with extras
160-
CondaPkg.add_pip("pydantic", version = "==2.9.2", extras = ["email"])
160+
CondaPkg.add_pip("pydantic", version = "==2.12.2", extras = ["email"])
161161
@test occursin("pydantic", status())
162-
@test occursin("(==2.9.2, [email])", status())
162+
@test occursin("(==2.12.2, [email])", status())
163163
CondaPkg.withenv() do
164164
isnull || run(`python -c "import pydantic"`)
165165
isnull || run(`python -c "import email_validator"`)
166166
end
167-
@test occursin("v2.9.2", status()) == !isnull
167+
@test occursin("v2.12.2", status()) == !isnull
168168

169169
# remove package
170170
CondaPkg.rm_pip("pydantic")

test/pkgrepl.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ end
2121

2222
@testitem "add/rm pip package" begin
2323
include("setup.jl")
24-
CondaPkg.PkgREPL.pip_add(["six==1.16.0", "pydantic[email]==2.9.2"])
24+
CondaPkg.PkgREPL.pip_add(["six==1.16.0", "pydantic[email]==2.12.2"])
2525
@test occursin("six", status())
2626
@test occursin("(==1.16.0)", status())
2727
@test occursin("pydantic", status())
28-
@test occursin("(==2.9.2, [email])", status())
28+
@test occursin("(==2.12.2, [email])", status())
2929
CondaPkg.PkgREPL.pip_rm(["six", "pydantic"])
3030
@test !occursin("six", status())
3131
@test !occursin("pydantic", status())

0 commit comments

Comments
 (0)