@@ -882,6 +882,132 @@ describe('Build Executor', () => {
882
882
expect ( output . success ) . toBe ( true ) ;
883
883
} ) ;
884
884
885
+ it ( 'should build python project with local dependencies that specify a "from" directory' , async ( ) => {
886
+ fsMock ( {
887
+ 'apps/app/.venv/pyvenv.cfg' : 'fake' ,
888
+ 'apps/app/app/index.py' : 'print("Hello from app")' ,
889
+ 'apps/app/poetry.lock' : dedent `
890
+ [[package]]
891
+ name = "dep1"
892
+ version = "1.0.0"
893
+ description = "Dep1"
894
+ category = "main"
895
+ optional = false
896
+ python-versions = "^3.8"
897
+ develop = false
898
+
899
+ [package.source]
900
+ type = "directory"
901
+ url = "../../libs/dep1"
902
+ ` ,
903
+ 'apps/app/pyproject.toml' : dedent `
904
+ [tool.poetry]
905
+ name = "app"
906
+ version = "1.0.0"
907
+ [[tool.poetry.packages]]
908
+ include = "app"
909
+
910
+ [tool.poetry.dependencies]
911
+ python = "^3.8"
912
+ dep1 = { path = "../../libs/dep1" }
913
+ ` ,
914
+
915
+ 'libs/dep1/src/dep1/index.py' : 'print("Hello from dep1")' ,
916
+ 'libs/dep1/pyproject.toml' : dedent `
917
+ [tool.poetry]
918
+ name = "dep1"
919
+ version = "1.0.0"
920
+
921
+ [[tool.poetry.packages]]
922
+ include = "dep1"
923
+ from = "src"
924
+
925
+ [tool.poetry.dependencies]
926
+ python = "^3.8"
927
+ ` ,
928
+ } ) ;
929
+
930
+ spawnSyncMock . mockImplementation ( ( _ , args , opts ) => {
931
+ if ( args [ 0 ] == 'build' ) {
932
+ spawnBuildMockImpl ( opts ) ;
933
+ } else if ( args [ 0 ] == 'export' && opts . cwd === 'apps/app' ) {
934
+ writeFileSync (
935
+ join ( buildPath , 'requirements.txt' ) ,
936
+ dedent `
937
+ dep1 @ file://${ process . cwd ( ) } /libs/dep1
938
+ `
939
+ ) ;
940
+ }
941
+ return { status : 0 } ;
942
+ } ) ;
943
+
944
+ const options : BuildExecutorSchema = {
945
+ ignorePaths : [ '.venv' , '.tox' , 'tests/' ] ,
946
+ silent : false ,
947
+ outputPath : 'dist/apps/app' ,
948
+ keepBuildFolder : true ,
949
+ devDependencies : false ,
950
+ lockedVersions : true ,
951
+ bundleLocalDependencies : true ,
952
+ } ;
953
+
954
+ const output = await executor ( options , {
955
+ cwd : '' ,
956
+ root : '.' ,
957
+ isVerbose : false ,
958
+ projectName : 'app' ,
959
+ workspace : {
960
+ version : 2 ,
961
+ npmScope : 'nxlv' ,
962
+ projects : {
963
+ app : {
964
+ root : 'apps/app' ,
965
+ targets : { } ,
966
+ } ,
967
+ dep1 : {
968
+ root : 'libs/dep1' ,
969
+ targets : { } ,
970
+ } ,
971
+ } ,
972
+ } ,
973
+ } ) ;
974
+
975
+ expect ( checkPoetryExecutableMock ) . toHaveBeenCalled ( ) ;
976
+ expect ( activateVenvMock ) . toHaveBeenCalledWith ( '.' ) ;
977
+ expect ( existsSync ( buildPath ) ) . toBeTruthy ( ) ;
978
+ expect ( existsSync ( `${ buildPath } /app` ) ) . toBeTruthy ( ) ;
979
+ expect ( existsSync ( `${ buildPath } /dep1` ) ) . toBeTruthy ( ) ;
980
+ expect ( existsSync ( `${ buildPath } /dist/app.fake` ) ) . toBeTruthy ( ) ;
981
+ expect ( spawnSyncMock ) . toHaveBeenCalledWith ( 'poetry' , [ 'build' ] , {
982
+ cwd : buildPath ,
983
+ shell : false ,
984
+ stdio : 'inherit' ,
985
+ } ) ;
986
+
987
+ const projectTomlData = parse (
988
+ readFileSync ( `${ buildPath } /pyproject.toml` ) . toString ( 'utf-8' )
989
+ ) as PyprojectToml ;
990
+
991
+ expect ( projectTomlData . tool . poetry . packages ) . toStrictEqual ( [
992
+ {
993
+ include : 'app' ,
994
+ } ,
995
+ {
996
+ include : 'dep1' ,
997
+ } ,
998
+ ] ) ;
999
+
1000
+ expect ( projectTomlData . tool . poetry . dependencies ) . toStrictEqual ( {
1001
+ python : '^3.8' ,
1002
+ } ) ;
1003
+
1004
+ expect ( projectTomlData . tool . poetry . group . dev . dependencies ) . toStrictEqual (
1005
+ { }
1006
+ ) ;
1007
+
1008
+ expect ( output . success ) . toBe ( true ) ;
1009
+ } ) ;
1010
+
885
1011
it ( 'should build python project with local dependencies and extras' , async ( ) => {
886
1012
fsMock ( {
887
1013
'apps/app/.venv/pyvenv.cfg' : 'fake' ,
0 commit comments