Skip to content

Commit 4843466

Browse files
committed
add PyPreferences module
remove artifact remove build phase start adapting CI fix ci fix ci fix ci fix ci fix ci conda fixes fix conda ci stop testing on 1.0 remove testers fix fix aot ci fixes dont test build fixes fix venv test refactor PyPreferences use env variable pyprefs project fix fixes stuff test fix conda revert changes fix cng fix python version custom which to work in julia 1.6 make test work with python 2 fixup docs
1 parent 9dfa3c2 commit 4843466

23 files changed

+768
-330
lines changed

.github/workflows/aot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ jobs:
1616
os:
1717
- ubuntu-latest
1818
architecture: [x64]
19-
python-version: ['3.x']
19+
python-version: ['3.9']
2020
julia-version:
21+
- '1.6'
2122
- '1'
22-
- '~1.7.0-rc1'
23+
- '~1.7'
2324
# - 'nightly' # TODO: reenable
2425
fail-fast: false
2526
env:
@@ -46,7 +47,6 @@ jobs:
4647
version: ${{ matrix.julia-version }}
4748
arch: ${{ matrix.architecture }}
4849
show-versioninfo: true
49-
5050
- run: julia -e 'using Pkg; pkg"add PackageCompiler@v1"'
5151

5252
- run: aot/compile.jl

.github/workflows/conda.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818
- macos-latest
1919
- windows-latest
2020
architecture: [x64]
21-
julia-version: ['1']
21+
julia-version: ['1.6', '1']
2222
include:
2323
- os: windows-latest
2424
architecture: x86
2525
julia-version: '1'
2626
fail-fast: false
2727
env:
28-
PYTHON: ""
28+
PYPREFERENCES_PYTHON: "conda"
2929
name: Test
3030
Julia ${{ matrix.julia-version }}
3131
Conda
@@ -41,7 +41,13 @@ jobs:
4141
version: ${{ matrix.julia-version }}
4242
arch: ${{ matrix.architecture }}
4343
show-versioninfo: true
44-
- uses: julia-actions/julia-buildpkg@v1
44+
- name: Install PyPreferences
45+
shell: julia --project=@. {0}
46+
run: |
47+
using Pkg;
48+
pkg"dev ./PyPreferences.jl";
49+
using PyPreferences;
50+
PyPreferences.use_conda();
4551
- uses: julia-actions/julia-runtest@v1
4652
- uses: julia-actions/julia-processcoverage@v1
4753
- uses: codecov/codecov-action@v1

.github/workflows/system.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
architecture: [x64]
2121
python-version: ['3.x']
2222
julia-version:
23-
- '1.0'
23+
- '1.6'
2424
- '1'
2525
- 'nightly'
2626
include:
@@ -34,14 +34,6 @@ jobs:
3434
architecture: x64
3535
python-version: '3.9'
3636
julia-version: '1'
37-
- os: ubuntu-latest
38-
architecture: x64
39-
python-version: '3.x'
40-
julia-version: '1.5'
41-
- os: ubuntu-latest
42-
architecture: x64
43-
python-version: '3.x'
44-
julia-version: '1.4'
4537
# Test Python 2.7 only with a few combinations (TODO: drop 2.7).
4638
# Note that it does not work in macOS:
4739
- os: ubuntu-latest
@@ -80,10 +72,14 @@ jobs:
8072
version: ${{ matrix.julia-version }}
8173
arch: ${{ matrix.architecture }}
8274
show-versioninfo: true
83-
- uses: julia-actions/julia-buildpkg@v1
84-
env:
85-
PYTHON: python
86-
- run: julia test/check_deps_version.jl ${{ matrix.python-version }}
75+
- name: Set PYTHON Env variable
76+
run: echo "PYTHON=python" >> $GITHUB_ENV
77+
if: ${{ matrix.python-version == '2.7' }}
78+
- name: Install PyPreferences
79+
shell: julia --project=@. {0}
80+
run: |
81+
using Pkg;
82+
pkg"dev ./PyPreferences.jl"
8783
- uses: julia-actions/julia-runtest@v1
8884
- uses: julia-actions/julia-processcoverage@v1
8985
- uses: codecov/codecov-action@v1

Project.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PyCall"
22
uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
33
authors = ["Steven G. Johnson <[email protected]>", "Yichao Yu <[email protected]>", "Takafumi Arakaki <[email protected]>", "Simon Kornblith <[email protected]>", "Páll Haraldsson <[email protected]>", "Jon Malmaud <[email protected]>", "Jake Bolewski <[email protected]>", "Keno Fischer <[email protected]>", "Joel Mason <[email protected]>", "Jameson Nash <[email protected]>", "The JuliaPy development team"]
4-
version = "1.93.0"
4+
version = "2.0.0"
55

66
[deps]
77
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
@@ -14,13 +14,14 @@ Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1414
VersionParsing = "81def892-9a0e-5fdd-b105-ffc91e053289"
1515

1616
[compat]
17-
Conda = "1.0"
17+
Conda = "1"
1818
MacroTools = "0.4, 0.5"
19-
VersionParsing = "1.0"
19+
VersionParsing = "1"
2020
julia = "1.6"
2121

2222
[extras]
23+
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
2324
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2425

2526
[targets]
26-
test = ["Test"]
27+
test = ["Test", "Preferences"]

PyPreferences.jl/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Takafumi Arakaki <[email protected]> and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PyPreferences.jl/Project.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name = "PyPreferences"
2+
uuid = "cc9521c6-0242-4dda-8d66-c47a9d9eec02"
3+
authors = ["Takafumi Arakaki <[email protected]> and contributors"]
4+
version = "0.1.0"
5+
6+
[deps]
7+
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
8+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
9+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
10+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
11+
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
12+
VersionParsing = "81def892-9a0e-5fdd-b105-ffc91e053289"
13+
14+
[compat]
15+
Conda = "1"
16+
julia = "1.6"
17+
VersionParsing = "1"
18+
Preferences = "1"
19+
20+
[extras]
21+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
22+
23+
[targets]
24+
test = ["Test"]

PyPreferences.jl/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# PyPreferences
2+
3+
```julia
4+
using PyPreferences
5+
6+
PyPreferences.use_system("python_exe")
7+
PyPreferences.use_conda()
8+
```

PyPreferences.jl/src/PyPreferences.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
baremodule PyPreferences
2+
3+
using Logging
4+
5+
function use_system end
6+
function use_conda end
7+
# function use_jll end
8+
function use_inprocess end
9+
function recompile end
10+
11+
# API to be used from PyCall
12+
function assert_configured end
13+
function instruction_message end
14+
15+
# function diagnose end
16+
function status end
17+
18+
module Implementations
19+
20+
module PythonUtils
21+
include("python_utils.jl")
22+
end
23+
include("which.jl")
24+
include("core.jl")
25+
include("api.jl")
26+
end
27+
28+
let prefs = Implementations.setup_non_failing()
29+
global const python = prefs.python
30+
global const inprocess = prefs.inprocess
31+
global const conda = prefs.conda
32+
global const python_fullpath = prefs.python_fullpath
33+
global const libpython = prefs.libpython
34+
global const python_version = prefs.python_version
35+
global const PYTHONHOME = prefs.PYTHONHOME
36+
end
37+
38+
const pyprogramname = python_fullpath
39+
const pyversion_build = python_version
40+
41+
end # baremodule PyPreferences

PyPreferences.jl/src/api.jl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using Conda
2+
3+
function PyPreferences.status()
4+
# TODO: compare with in-process values
5+
code = """
6+
$(load_pypreferences_code())
7+
PyPreferences.Implementations.status_inprocess()
8+
"""
9+
cmd = include_stdin_cmd()
10+
open(pipeline(cmd; stdout = stdout, stderr = stderr); write = true) do io
11+
write(io, code)
12+
end
13+
return
14+
end
15+
16+
function PyPreferences.use_system(python::AbstractString = "python3")
17+
"""
18+
Use python from a provided executable or path (defaults to `python3`).
19+
"""
20+
return Implementations.set(python = python)
21+
end
22+
23+
function PyPreferences.use_conda()
24+
"""
25+
Use Python provided by Conda.jl
26+
"""
27+
Conda.add("numpy")
28+
return Implementations.set(conda = true)
29+
end
30+
31+
#=
32+
function use_jll()
33+
end
34+
=#
35+
36+
function PyPreferences.use_inprocess()
37+
return Implementations.set(inprocess = true)
38+
end
39+
40+
function PyPreferences.instruction_message()
41+
return """
42+
PyPreferences.jl is not configured properly. Run:
43+
using Pkg
44+
Pkg.add("PyPreferences")
45+
using PyPreferences
46+
@doc PyPreferences
47+
for usage.
48+
"""
49+
end
50+
51+
52+
function PyPreferences.assert_configured()
53+
if (
54+
PyPreferences.python === nothing ||
55+
PyPreferences.python_fullpath === nothing ||
56+
PyPreferences.libpython === nothing ||
57+
PyPreferences.python_version === nothing ||
58+
PyPreferences.PYTHONHOME === nothing
59+
)
60+
error(PyPreferences.instruction_message())
61+
end
62+
end

0 commit comments

Comments
 (0)