@@ -3,6 +3,7 @@ use std::path::PathBuf;
33use anyhow:: Result ;
44
55use crate :: file_manager:: save_file_with_content;
6+ use crate :: project_info:: ProjectManager ;
67
78fn build_actions_python_test_versions ( github_action_python_test_versions : & [ String ] ) -> String {
89 github_action_python_test_versions
@@ -245,7 +246,7 @@ pub fn save_ci_testing_linux_only_file(
245246 source_dir : & str ,
246247 min_python_version : & str ,
247248 github_action_python_test_versions : & [ String ] ,
248- use_pyo3 : bool ,
249+ project_manager : & ProjectManager ,
249250 project_root_dir : & Option < PathBuf > ,
250251) -> Result < ( ) > {
251252 let file_path = match project_root_dir {
@@ -255,18 +256,17 @@ pub fn save_ci_testing_linux_only_file(
255256 ) ,
256257 None => format ! ( "{project_slug}/.github/workflows/testing.yml" ) ,
257258 } ;
258- let content = if use_pyo3 {
259- create_ci_testing_linux_only_file_pyo3 (
259+ let content = match project_manager {
260+ ProjectManager :: Maturin => create_ci_testing_linux_only_file_pyo3 (
260261 source_dir,
261262 min_python_version,
262263 github_action_python_test_versions,
263- )
264- } else {
265- create_ci_testing_linux_only_file (
264+ ) ,
265+ ProjectManager :: Poetry => create_ci_testing_linux_only_file (
266266 source_dir,
267267 min_python_version,
268268 github_action_python_test_versions,
269- )
269+ ) ,
270270 } ;
271271
272272 save_file_with_content ( & file_path, & content) ?;
@@ -509,7 +509,7 @@ pub fn save_ci_testing_multi_os_file(
509509 source_dir : & str ,
510510 min_python_version : & str ,
511511 github_action_python_test_versions : & [ String ] ,
512- use_pyo3 : bool ,
512+ project_manager : & ProjectManager ,
513513 project_root_dir : & Option < PathBuf > ,
514514) -> Result < ( ) > {
515515 let file_path = match project_root_dir {
@@ -519,18 +519,17 @@ pub fn save_ci_testing_multi_os_file(
519519 ) ,
520520 None => format ! ( "{project_slug}/.github/workflows/testing.yml" ) ,
521521 } ;
522- let content = if use_pyo3 {
523- create_ci_testing_multi_os_file_pyo3 (
522+ let content = match project_manager {
523+ ProjectManager :: Maturin => create_ci_testing_multi_os_file_pyo3 (
524524 source_dir,
525525 min_python_version,
526526 github_action_python_test_versions,
527- )
528- } else {
529- create_ci_testing_multi_os_file (
527+ ) ,
528+ ProjectManager :: Poetry => create_ci_testing_multi_os_file (
530529 source_dir,
531530 min_python_version,
532531 github_action_python_test_versions,
533- )
532+ ) ,
534533 } ;
535534
536535 save_file_with_content ( & file_path, & content) ?;
@@ -589,17 +588,16 @@ updates:
589588
590589pub fn save_dependabot_file (
591590 project_slug : & str ,
592- use_pyo3 : bool ,
591+ project_manager : & ProjectManager ,
593592 project_root_dir : & Option < PathBuf > ,
594593) -> Result < ( ) > {
595594 let file_path = match project_root_dir {
596595 Some ( root) => format ! ( "{}/{project_slug}/.github/dependabot.yml" , root. display( ) ) ,
597596 None => format ! ( "{project_slug}/.github/dependabot.yml" ) ,
598597 } ;
599- let content = if use_pyo3 {
600- create_dependabot_file_pyo3 ( )
601- } else {
602- create_dependabot_file ( )
598+ let content = match project_manager {
599+ ProjectManager :: Maturin => create_dependabot_file_pyo3 ( ) ,
600+ ProjectManager :: Poetry => create_dependabot_file ( ) ,
603601 } ;
604602
605603 save_file_with_content ( & file_path, & content) ?;
@@ -750,7 +748,7 @@ jobs:
750748pub fn save_pypi_publish_file (
751749 project_slug : & str ,
752750 python_version : & str ,
753- use_pyo3 : bool ,
751+ project_manager : & ProjectManager ,
754752 project_root_dir : & Option < PathBuf > ,
755753) -> Result < ( ) > {
756754 let file_path = match project_root_dir {
@@ -760,10 +758,9 @@ pub fn save_pypi_publish_file(
760758 ) ,
761759 None => format ! ( "{project_slug}/.github/workflows/pypi_publish.yml" ) ,
762760 } ;
763- let content = if use_pyo3 {
764- create_pypi_publish_file_pyo3 ( python_version)
765- } else {
766- create_pypi_publish_file ( python_version)
761+ let content = match project_manager {
762+ ProjectManager :: Maturin => create_pypi_publish_file_pyo3 ( python_version) ,
763+ ProjectManager :: Poetry => create_pypi_publish_file ( python_version) ,
767764 } ;
768765
769766 save_file_with_content ( & file_path, & content) ?;
@@ -968,7 +965,7 @@ jobs:
968965 "3.10" . to_string ( ) ,
969966 "3.11" . to_string ( ) ,
970967 ] ,
971- false ,
968+ & ProjectManager :: Poetry ,
972969 & Some ( base) ,
973970 )
974971 . unwrap ( ) ;
@@ -1114,7 +1111,7 @@ jobs:
11141111 "3.10" . to_string ( ) ,
11151112 "3.11" . to_string ( ) ,
11161113 ] ,
1117- true ,
1114+ & ProjectManager :: Maturin ,
11181115 & Some ( base) ,
11191116 )
11201117 . unwrap ( ) ;
@@ -1234,7 +1231,7 @@ jobs:
12341231 "3.10" . to_string ( ) ,
12351232 "3.11" . to_string ( ) ,
12361233 ] ,
1237- false ,
1234+ & ProjectManager :: Poetry ,
12381235 & Some ( base) ,
12391236 )
12401237 . unwrap ( ) ;
@@ -1382,7 +1379,7 @@ jobs:
13821379 "3.10" . to_string ( ) ,
13831380 "3.11" . to_string ( ) ,
13841381 ] ,
1385- true ,
1382+ & ProjectManager :: Maturin ,
13861383 & Some ( base) ,
13871384 )
13881385 . unwrap ( ) ;
@@ -1419,7 +1416,7 @@ updates:
14191416 let project_slug = "test-project" ;
14201417 create_dir_all ( base. join ( format ! ( "{project_slug}/.github" ) ) ) . unwrap ( ) ;
14211418 let expected_file = base. join ( format ! ( "{project_slug}/.github/dependabot.yml" ) ) ;
1422- save_dependabot_file ( project_slug, false , & Some ( base) ) . unwrap ( ) ;
1419+ save_dependabot_file ( project_slug, & ProjectManager :: Poetry , & Some ( base) ) . unwrap ( ) ;
14231420
14241421 assert ! ( expected_file. is_file( ) ) ;
14251422
@@ -1460,7 +1457,7 @@ updates:
14601457 let project_slug = "test-project" ;
14611458 create_dir_all ( base. join ( format ! ( "{project_slug}/.github" ) ) ) . unwrap ( ) ;
14621459 let expected_file = base. join ( format ! ( "{project_slug}/.github/dependabot.yml" ) ) ;
1463- save_dependabot_file ( project_slug, true , & Some ( base) ) . unwrap ( ) ;
1460+ save_dependabot_file ( project_slug, & ProjectManager :: Maturin , & Some ( base) ) . unwrap ( ) ;
14641461
14651462 assert ! ( expected_file. is_file( ) ) ;
14661463
@@ -1506,7 +1503,13 @@ jobs:
15061503 let project_slug = "test-project" ;
15071504 create_dir_all ( base. join ( format ! ( "{project_slug}/.github/workflows" ) ) ) . unwrap ( ) ;
15081505 let expected_file = base. join ( format ! ( "{project_slug}/.github/workflows/pypi_publish.yml" ) ) ;
1509- save_pypi_publish_file ( project_slug, python_version, false , & Some ( base) ) . unwrap ( ) ;
1506+ save_pypi_publish_file (
1507+ project_slug,
1508+ python_version,
1509+ & ProjectManager :: Poetry ,
1510+ & Some ( base) ,
1511+ )
1512+ . unwrap ( ) ;
15101513
15111514 assert ! ( expected_file. is_file( ) ) ;
15121515
@@ -1628,7 +1631,13 @@ jobs:
16281631 let project_slug = "test-project" ;
16291632 create_dir_all ( base. join ( format ! ( "{project_slug}/.github/workflows" ) ) ) . unwrap ( ) ;
16301633 let expected_file = base. join ( format ! ( "{project_slug}/.github/workflows/pypi_publish.yml" ) ) ;
1631- save_pypi_publish_file ( project_slug, python_version, true , & Some ( base) ) . unwrap ( ) ;
1634+ save_pypi_publish_file (
1635+ project_slug,
1636+ python_version,
1637+ & ProjectManager :: Maturin ,
1638+ & Some ( base) ,
1639+ )
1640+ . unwrap ( ) ;
16321641
16331642 assert ! ( expected_file. is_file( ) ) ;
16341643
0 commit comments