Skip to content

Commit f4233c3

Browse files
committed
WIP
1 parent 69c1403 commit f4233c3

File tree

10 files changed

+260
-85
lines changed

10 files changed

+260
-85
lines changed

.github/workflows/pr-check.yml

Lines changed: 104 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ jobs:
2828
- os: windows-latest
2929
target: x86_64-pc-windows-msvc
3030
run_cli: "yes"
31-
- os: windows-latest
32-
target: aarch64-pc-windows-msvc
33-
run_cli: "no"
3431
- os: ubuntu-latest
3532
target: x86_64-unknown-linux-musl
3633
run_cli: "yes"
@@ -212,6 +209,15 @@ jobs:
212209
- feature: ci-poetry-custom
213210
os: ubuntu-latest
214211
target: x86_64-unknown-linux-musl
212+
- feature: ci-poetry-global
213+
os: windows-latest
214+
target: x86_64-pc-windows-msvc
215+
- feature: ci-poetry-project
216+
os: windows-latest
217+
target: x86_64-pc-windows-msvc
218+
- feature: ci-poetry-custom
219+
os: windows-latest
220+
target: x86_64-pc-windows-msvc
215221
steps:
216222
- name: Checkout
217223
uses: actions/checkout@v4
@@ -225,16 +231,33 @@ jobs:
225231

226232
- name: Set Python 3.12 to PATH
227233
if: startsWith( matrix.feature, 'ci-poetry')
234+
id: setupPython312
228235
uses: actions/setup-python@v5
229236
with:
230237
python-version: "3.12"
231238

232239
- name: Set Python 3.11 to PATH
233240
if: startsWith( matrix.feature, 'ci-poetry')
241+
id: setupPython311
234242
uses: actions/setup-python@v5
235243
with:
236244
python-version: "3.11"
237245

246+
- name: Python 3.12 Path
247+
if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'windows')
248+
run: echo "PYTHON_3_12_PATH=${{ steps.setupPython312.outputs.python-path }}" >> $GITHUB_ENV
249+
shell: bash
250+
251+
- name: Python 3.12 Path
252+
if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'windows')
253+
run: echo $PYTHON_3_12_PATH
254+
shell: bash
255+
256+
- name: Python 3.11 Path
257+
if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'windows')
258+
run: echo "PYTHON_3_11_PATH=${{ steps.setupPython311.outputs.python-path }}" >> $GITHUB_ENV
259+
shell: bash
260+
238261
- name: Install Poetry (envs globally)
239262
if: startsWith( matrix.feature, 'ci-poetry-global')
240263
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b
@@ -260,6 +283,12 @@ jobs:
260283
virtualenvs-path: ~/my-custom-path
261284
installer-parallel: true
262285

286+
- name: Petry exe
287+
if: startsWith( matrix.feature, 'ci-poetry')
288+
run: which poetry
289+
shell: bash
290+
291+
263292
- name: Petry config
264293
if: startsWith( matrix.feature, 'ci-poetry')
265294
run: poetry config --list
@@ -272,13 +301,23 @@ jobs:
272301
shell: bash
273302

274303
- name: Petry virtual env setup 3.12
275-
if: startsWith( matrix.feature, 'ci-poetry')
276-
run: poetry env use python3.12
304+
if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'ubuntu')
305+
run: poetry env use 3.12
306+
shell: bash
307+
308+
- name: Petry virtual env setup 3.12
309+
if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'windows')
310+
run: poetry env use $PYTHON_3_12_PATH
277311
shell: bash
278312

279313
- name: Petry virtual env setup 3.11
280-
if: startsWith( matrix.feature, 'ci-poetry')
281-
run: poetry env use python3.11
314+
if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'ubuntu')
315+
run: poetry env use 3.11
316+
shell: bash
317+
318+
- name: Petry virtual env setup 3.11
319+
if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'windows')
320+
run: poetry env use $PYTHON_3_11_PATH
282321
shell: bash
283322

284323
- name: Petry list envs
@@ -366,67 +405,67 @@ jobs:
366405
shell: bash
367406

368407
- name: Find Environments
369-
run: cargo run --release --target ${{ matrix.target }} -- find -v
408+
run: cargo run --release --target ${{ matrix.target }}
370409
shell: bash
371410

372411
- name: Run Tests
373412
run: cargo test --frozen --features ${{ matrix.feature }} -- --nocapture
374413
shell: bash
375414

376-
builds:
377-
name: Builds
378-
runs-on: ${{ matrix.os }}
379-
strategy:
380-
fail-fast: false
381-
matrix:
382-
include:
383-
- os: windows-latest
384-
target: x86_64-pc-windows-msvc
385-
- os: windows-latest
386-
target: aarch64-pc-windows-msvc
387-
- os: ubuntu-latest
388-
target: x86_64-unknown-linux-musl
389-
run_cli: "yes"
390-
# - os: ubuntu-latest
391-
# target: aarch64-unknown-linux-gnu
392-
# - os: ubuntu-latest
393-
# target: arm-unknown-linux-gnueabihf
394-
- os: macos-latest
395-
target: x86_64-apple-darwin
396-
run_cli: "yes"
397-
- os: macos-14
398-
target: aarch64-apple-darwin
399-
run_cli: "yes"
400-
# - os: ubuntu-latest
401-
# target: x86_64-unknown-linux-gnu
402-
# - os: ubuntu-latest
403-
# target: aarch64-unknown-linux-musl
404-
steps:
405-
- name: Checkout
406-
uses: actions/checkout@v4
407-
408-
- name: Rust Tool Chain setup
409-
uses: dtolnay/rust-toolchain@stable
410-
with:
411-
toolchain: stable
412-
targets: ${{ matrix.target }}
413-
414-
- name: Cargo Fetch
415-
run: cargo fetch
416-
shell: bash
417-
418-
- name: Run Tests
419-
# We do not want to run all features, CI is only for tests with Python
420-
# Thats a separate job.
421-
run: cargo test --frozen
422-
shell: bash
423-
424-
- name: Build
425-
run: cargo build --release --target ${{ matrix.target }}
426-
shell: bash
427-
428-
- name: Upload Artifact
429-
uses: actions/upload-artifact@v4
430-
with:
431-
name: pet-${{ matrix.target }}
432-
path: target/${{ matrix.target }}/release/pet*
415+
# builds:
416+
# name: Builds
417+
# runs-on: ${{ matrix.os }}
418+
# strategy:
419+
# fail-fast: false
420+
# matrix:
421+
# include:
422+
# - os: windows-latest
423+
# target: x86_64-pc-windows-msvc
424+
# - os: windows-latest
425+
# target: aarch64-pc-windows-msvc
426+
# - os: ubuntu-latest
427+
# target: x86_64-unknown-linux-musl
428+
# run_cli: "yes"
429+
# # - os: ubuntu-latest
430+
# # target: aarch64-unknown-linux-gnu
431+
# # - os: ubuntu-latest
432+
# # target: arm-unknown-linux-gnueabihf
433+
# - os: macos-latest
434+
# target: x86_64-apple-darwin
435+
# run_cli: "yes"
436+
# - os: macos-14
437+
# target: aarch64-apple-darwin
438+
# run_cli: "yes"
439+
# # - os: ubuntu-latest
440+
# # target: x86_64-unknown-linux-gnu
441+
# # - os: ubuntu-latest
442+
# # target: aarch64-unknown-linux-musl
443+
# steps:
444+
# - name: Checkout
445+
# uses: actions/checkout@v4
446+
447+
# - name: Rust Tool Chain setup
448+
# uses: dtolnay/rust-toolchain@stable
449+
# with:
450+
# toolchain: stable
451+
# targets: ${{ matrix.target }}
452+
453+
# - name: Cargo Fetch
454+
# run: cargo fetch
455+
# shell: bash
456+
457+
# - name: Run Tests
458+
# # We do not want to run all features, CI is only for tests with Python
459+
# # Thats a separate job.
460+
# run: cargo test --frozen
461+
# shell: bash
462+
463+
# - name: Build
464+
# run: cargo build --release --target ${{ matrix.target }}
465+
# shell: bash
466+
467+
# - name: Upload Artifact
468+
# uses: actions/upload-artifact@v4
469+
# with:
470+
# name: pet-${{ matrix.target }}
471+
# path: target/${{ matrix.target }}/release/pet*

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pet-mac-commandlinetools/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ impl Locator for MacCmdLineTools {
106106
symlinks.sort();
107107
symlinks.dedup();
108108

109+
// Find other exes that are symlinks to the same exe in /Library/Developer/CommandLineTools/usr/bin
110+
for exe in find_executables("/Library/Developer/CommandLineTools/usr/bin") {
111+
if !symlinks.contains(&exe) {
112+
if let Some(symlink) = resolve_symlink(&exe) {
113+
if symlinks.contains(&symlink) {
114+
symlinks.push(exe);
115+
}
116+
}
117+
}
118+
}
119+
109120
if prefix.is_none() {
110121
// We would have identified the symlinks by now.
111122
// Look for the one with the path `/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9`

crates/pet-poetry/src/environment_locations.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::{
1515

1616
use crate::{
1717
config::Config, env_variables::EnvVariables, environment::create_poetry_env,
18-
pyproject_toml::PyProjectToml,
18+
manager::PoetryManager, pyproject_toml::PyProjectToml,
1919
};
2020

2121
lazy_static! {
@@ -26,6 +26,7 @@ lazy_static! {
2626
pub fn list_environments(
2727
env: &EnvVariables,
2828
project_dirs: &[PathBuf],
29+
manager: Option<PoetryManager>,
2930
) -> Option<Vec<PythonEnvironment>> {
3031
if project_dirs.is_empty() {
3132
return None;
@@ -76,7 +77,9 @@ pub fn list_environments(
7677
.unwrap_or_default();
7778
// Look for .venv as well, in case we create the virtual envs in the local project folder.
7879
if name.starts_with(&virtualenv_prefix) || name.starts_with(".venv") {
79-
if let Some(env) = create_poetry_env(&virtual_env, project_dir.clone(), None) {
80+
if let Some(env) =
81+
create_poetry_env(&virtual_env, project_dir.clone(), manager.clone())
82+
{
8083
envs.push(env);
8184
}
8285
}

crates/pet-poetry/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,14 @@ impl Poetry {
105105
managers: vec![],
106106
environments: vec![],
107107
};
108-
if let Some(manager) = manager {
108+
if let Some(manager) = &manager {
109109
result.managers.push(manager.to_manager());
110110
}
111111
if let Ok(values) = self.project_dirs.lock() {
112112
let project_dirs = values.clone();
113113
drop(values);
114-
let envs = list_environments(&self.env_vars, &project_dirs.clone()).unwrap_or_default();
114+
let envs = list_environments(&self.env_vars, &project_dirs.clone(), manager)
115+
.unwrap_or_default();
115116
result.environments.extend(envs.clone());
116117
}
117118

crates/pet-poetry/src/manager.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
use log::trace;
45
use pet_core::manager::{EnvManager, EnvManagerType};
56
use std::{env, path::PathBuf};
67

@@ -35,8 +36,10 @@ impl PoetryManager {
3536
if let Some(poetry_home) = &env_variables.poetry_home {
3637
if std::env::consts::OS == "windows" {
3738
search_paths.push(poetry_home.join("bin").join("poetry.exe"));
39+
search_paths.push(poetry_home.join("venv").join("bin").join("poetry.exe"));
3840
}
3941
search_paths.push(poetry_home.join("bin").join("poetry"));
42+
search_paths.push(poetry_home.join("venv").join("bin").join("poetry"));
4043
}
4144
if std::env::consts::OS == "windows" {
4245
if let Some(app_data) = env_variables.app_data.clone() {
@@ -71,6 +74,10 @@ impl PoetryManager {
7174
app_data.join("Python").join("scripts").join("poetry"), // https://python-poetry.org/docs/#installing-with-the-official-installer
7275
);
7376
}
77+
search_paths.push(
78+
// Found after installing on Windows via github actions.
79+
home.join(".local").join("bin").join("poetry"),
80+
);
7481
} else if std::env::consts::OS == "macos" {
7582
search_paths.push(
7683
// https://python-poetry.org/docs/#installing-with-the-official-installer
@@ -111,9 +118,16 @@ impl PoetryManager {
111118
if executable.is_file() {
112119
return Some(PoetryManager { executable });
113120
}
121+
if std::env::consts::OS == "windows" {
122+
let executable = each.join("poetry.exe");
123+
if executable.is_file() {
124+
return Some(PoetryManager { executable });
125+
}
126+
}
114127
}
115128
}
116129
}
130+
trace!("Poetry exe not found");
117131
None
118132
}
119133
pub fn to_manager(&self) -> EnvManager {

crates/pet/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ log = "0.4.21"
3737
clap = { version = "4.5.4", features = ["derive", "cargo"] }
3838
serde = { version = "1.0.152", features = ["derive"] }
3939
serde_json = "1.0.93"
40+
env_logger = "0.10.2"
4041

4142
[dev-dependencies]
4243
regex = "1.10.4"

crates/pet/src/locators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn find_symlinks(executable: &PathBuf) -> Option<Vec<PathBuf>> {
179179
}
180180

181181
#[cfg(windows)]
182-
fn find_symlinks(executable: &PathBuf) -> Option<Vec<PathBuf>> {
182+
fn find_symlinks(_executable: &PathBuf) -> Option<Vec<PathBuf>> {
183183
// In windows we will need to spawn the Python exe and then get the exes.
184184
// Lets wait and see if this is necessary.
185185
None

0 commit comments

Comments
 (0)