Skip to content

Commit 25ae1f0

Browse files
authored
fix: remove python six requirement (#5785)
1 parent 500d751 commit 25ae1f0

File tree

4 files changed

+59
-66
lines changed

4 files changed

+59
-66
lines changed

packages/doctor/src/doctor.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ export class Doctor implements NativeScriptDoctor.IDoctor {
220220
);
221221

222222
if (sysInfoData.xcodeVer && sysInfoData.cocoaPodsVer) {
223-
const isCocoaPodsWorkingCorrectly = await this.sysInfo.isCocoaPodsWorkingCorrectly();
223+
const isCocoaPodsWorkingCorrectly =
224+
await this.sysInfo.isCocoaPodsWorkingCorrectly();
224225
result = result.concat(
225226
this.processSysInfoItem({
226227
item: isCocoaPodsWorkingCorrectly,
@@ -259,14 +260,6 @@ export class Doctor implements NativeScriptDoctor.IDoctor {
259260
EOL +
260261
`Error while validating Python packages. Error is: ${sysInfoData.pythonInfo.installationErrorMessage}`,
261262
platforms: [Constants.IOS_PLATFORM_NAME],
262-
}),
263-
this.processSysInfoItem({
264-
item: sysInfoData.pythonInfo.isSixPackageInstalled,
265-
infoMessage: `The Python 'six' package is found.`,
266-
warningMessage: `The Python 'six' package not found.`,
267-
additionalInformation:
268-
"This package is required by the Debugger library (LLDB) for iOS. You can install it by first making sure you have pip3 installed and then running 'pip3 install six' from the terminal.",
269-
platforms: [Constants.IOS_PLATFORM_NAME],
270263
})
271264
);
272265

packages/doctor/src/sys-info.ts

+14-20
Original file line numberDiff line numberDiff line change
@@ -493,21 +493,15 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
493493
async (): Promise<NativeScriptDoctor.IPythonInfo> => {
494494
if (this.hostInfo.isDarwin) {
495495
try {
496-
await this.childProcess.exec(`python3 -c "import six"`);
496+
await this.childProcess.exec(`python3 --version`);
497497
} catch (error) {
498-
// error.code = 1 so the Python is present, but we don't have six.
499-
if (error.code === 1) {
500-
return { isInstalled: true, isSixPackageInstalled: false };
501-
}
502-
503498
return {
504499
isInstalled: false,
505-
isSixPackageInstalled: false,
506500
installationErrorMessage: error.message,
507501
};
508502
}
509503

510-
return { isInstalled: true, isSixPackageInstalled: true };
504+
return { isInstalled: true };
511505
}
512506

513507
return null;
@@ -678,9 +672,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
678672
return this.getValueForProperty(
679673
() => this.commonSysInfoCache,
680674
async (): Promise<NativeScriptDoctor.ICommonSysInfoData> => {
681-
const result: NativeScriptDoctor.ICommonSysInfoData = Object.create(
682-
null
683-
);
675+
const result: NativeScriptDoctor.ICommonSysInfoData =
676+
Object.create(null);
684677

685678
// os stuff
686679
result.platform = platform();
@@ -708,8 +701,10 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
708701
result.xcodeprojLocation = await this.getXcodeprojLocation();
709702
result.itunesInstalled = await this.isITunesInstalled();
710703
result.cocoaPodsVer = await this.getCocoaPodsVersion();
711-
result.isCocoaPodsWorkingCorrectly = await this.isCocoaPodsWorkingCorrectly();
712-
result.isCocoaPodsUpdateRequired = await this.isCocoaPodsUpdateRequired();
704+
result.isCocoaPodsWorkingCorrectly =
705+
await this.isCocoaPodsWorkingCorrectly();
706+
result.isCocoaPodsUpdateRequired =
707+
await this.isCocoaPodsUpdateRequired();
713708
result.pythonInfo = await this.getPythonInfo();
714709

715710
return result;
@@ -723,9 +718,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
723718
return this.getValueForProperty(
724719
() => this.androidSysInfoCache,
725720
async (): Promise<NativeScriptDoctor.IAndroidSysInfoData> => {
726-
const result: NativeScriptDoctor.IAndroidSysInfoData = Object.create(
727-
null
728-
);
721+
const result: NativeScriptDoctor.IAndroidSysInfoData =
722+
Object.create(null);
729723

730724
result.dotNetVer = await this.hostInfo.dotNetVersion();
731725
result.javacVersion = await this.getJavaCompilerVersion();
@@ -737,7 +731,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
737731
result.androidInstalled = await this.isAndroidInstalled();
738732
result.monoVer = await this.getMonoVersion();
739733
result.gradleVer = await this.getGradleVersion();
740-
result.isAndroidSdkConfiguredCorrectly = await this.isAndroidSdkConfiguredCorrectly();
734+
result.isAndroidSdkConfiguredCorrectly =
735+
await this.isAndroidSdkConfiguredCorrectly();
741736

742737
return result;
743738
}
@@ -749,9 +744,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
749744
regExp: RegExp
750745
): Promise<string> {
751746
let javaExecutableVersion: string = null;
752-
const javaExecutablePath = this.getJavaExecutablePathFromJavaHome(
753-
javaExecutableName
754-
);
747+
const javaExecutablePath =
748+
this.getJavaExecutablePathFromJavaHome(javaExecutableName);
755749
if (javaExecutablePath) {
756750
javaExecutableVersion = await this.getVersionOfJavaExecutable(
757751
javaExecutablePath,

packages/doctor/test/sys-info.ts

+23-27
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function createChildProcessResults(
113113
"tns --version": childProcessResult.nativeScriptCliVersion,
114114
emulator: { shouldThrowError: false },
115115
"which git": childProcessResult.git,
116-
'python3 -c "import six"': childProcessResult.pythonInfo,
116+
"python3 --version": childProcessResult.pythonInfo,
117117
};
118118
}
119119

@@ -164,9 +164,8 @@ function mockSysInfo(
164164
isLinux: !hostInfoOptions.isDarwin && !hostInfoOptions.isWindows,
165165
winreg,
166166
};
167-
const childProcessResultDictionary = createChildProcessResults(
168-
childProcessResult
169-
);
167+
const childProcessResultDictionary =
168+
createChildProcessResults(childProcessResult);
170169
const childProcess = {
171170
exec: async (command: string) => {
172171
return getResultFromChildProcess(
@@ -558,7 +557,8 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
558557
null
559558
);
560559
const adbVersion = await sysInfo.getAdbVersion();
561-
const isAndroidSdkConfiguredCorrectly = await sysInfo.isAndroidSdkConfiguredCorrectly();
560+
const isAndroidSdkConfiguredCorrectly =
561+
await sysInfo.isAndroidSdkConfiguredCorrectly();
562562
assert.deepEqual(adbVersion, null);
563563
assert.deepEqual(isAndroidSdkConfiguredCorrectly, undefined);
564564
});
@@ -583,7 +583,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
583583
const pythonInfo = await sysInfo.getPythonInfo();
584584
assert.deepEqual(pythonInfo, null);
585585
});
586-
it("should return {isInstalled: true, isSixPackageInstalled: true} when python is correctly installed on Mac", async () => {
586+
it("should return {isInstalled: true} when python is correctly installed on Mac", async () => {
587587
childProcessResult.pythonInfo = { result: "" };
588588
sysInfo = mockSysInfo(
589589
childProcessResult,
@@ -593,10 +593,9 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
593593
const pythonInfo = await sysInfo.getPythonInfo();
594594
assert.deepEqual(pythonInfo, {
595595
isInstalled: true,
596-
isSixPackageInstalled: true,
597596
});
598597
});
599-
it("should return {isInstalled: false, isSixPackageInstalled: false} when python check throws an error", async () => {
598+
it("should return {isInstalled: false} when python check throws an error", async () => {
600599
childProcessResult.pythonInfo = { shouldThrowError: true };
601600
sysInfo = mockSysInfo(
602601
childProcessResult,
@@ -606,27 +605,25 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
606605
const pythonInfo = await sysInfo.getPythonInfo();
607606
assert.deepEqual(pythonInfo, {
608607
isInstalled: false,
609-
isSixPackageInstalled: false,
610608
installationErrorMessage:
611-
'This one throws error. (python3 -c "import six")',
612-
});
613-
});
614-
it("should return {isInstalled: true, isSixPackageInstalled: false} when python is installed but six package is not", async () => {
615-
childProcessResult.pythonInfo = {
616-
shouldThrowError: true,
617-
errorCode: 1,
618-
};
619-
sysInfo = mockSysInfo(
620-
childProcessResult,
621-
{ isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" },
622-
null
623-
);
624-
const pythonInfo = await sysInfo.getPythonInfo();
625-
assert.deepEqual(pythonInfo, {
626-
isInstalled: true,
627-
isSixPackageInstalled: false,
609+
"This one throws error. (python3 --version)",
628610
});
629611
});
612+
// it("should return {isInstalled: true} when python is installed but six package is not", async () => {
613+
// childProcessResult.pythonInfo = {
614+
// shouldThrowError: true,
615+
// errorCode: 1,
616+
// };
617+
// sysInfo = mockSysInfo(
618+
// childProcessResult,
619+
// { isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" },
620+
// null
621+
// );
622+
// const pythonInfo = await sysInfo.getPythonInfo();
623+
// assert.deepEqual(pythonInfo, {
624+
// isInstalled: true,
625+
// });
626+
// });
630627
});
631628

632629
const testData: ICLIOutputVersionTestCase[] = [
@@ -823,7 +820,6 @@ ${expectedCliVersion}`;
823820
assert.deepEqual(result.isCocoaPodsUpdateRequired, false);
824821
assert.deepEqual(result.pythonInfo, {
825822
isInstalled: false,
826-
isSixPackageInstalled: false,
827823
installationErrorMessage:
828824
"Cannot read properties of undefined (reading 'shouldThrowError')",
829825
});

packages/doctor/typings/interfaces.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ declare module NativeScriptDoctor {
209209
* @param {string} runtimeVersion @optional The runtime version against which the validation is executed. In case this parameter is passed, it takes precedence over the projectDir argument.
210210
* @return {Promise<boolean>} true if local build can be executed for the provided platform.
211211
*/
212-
canExecuteLocalBuild(platform: string, projectDir?: string, runtimeVersion?: string): Promise<boolean>;
212+
canExecuteLocalBuild(
213+
platform: string,
214+
projectDir?: string,
215+
runtimeVersion?: string
216+
): Promise<boolean>;
213217

214218
/**
215219
* Executes all checks for the current environment and returns the warnings from each check.
@@ -363,7 +367,10 @@ declare module NativeScriptDoctor {
363367
dotNetVer?: string;
364368
}
365369

366-
interface ISysInfoData extends ICommonSysInfoData, IiOSSysInfoData, IAndroidSysInfoData { }
370+
interface ISysInfoData
371+
extends ICommonSysInfoData,
372+
IiOSSysInfoData,
373+
IAndroidSysInfoData {}
367374

368375
/**
369376
* Describes warning returned from @nativescript/doctor check.
@@ -438,11 +445,6 @@ declare module NativeScriptDoctor {
438445
*/
439446
isInstalled: boolean;
440447

441-
/**
442-
* Determines whether python six package is installed
443-
*/
444-
isSixPackageInstalled: boolean;
445-
446448
/**
447449
* Error message from installation check
448450
*/
@@ -487,7 +489,11 @@ declare module NativeScriptDoctor {
487489
* @param {string} runtimeVersion @optional The runtime version against which the validation is executed. In case this parameter is passed, it takes precedence over the projectDir argument.
488490
* @return {NativeScriptDoctor.IWarning[]} An array of errors from the validation checks. If there are no errors will return [].
489491
*/
490-
validateJavacVersion(installedJavaVersion: string, projectDir?: string, runtimeVersion?: string): NativeScriptDoctor.IWarning[];
492+
validateJavacVersion(
493+
installedJavaVersion: string,
494+
projectDir?: string,
495+
runtimeVersion?: string
496+
): NativeScriptDoctor.IWarning[];
491497

492498
/**
493499
* Returns the path to the adb which is located in ANDROID_HOME.
@@ -506,14 +512,18 @@ declare module NativeScriptDoctor {
506512
* @param {ITargetValidationOptions} options The targetSdk to be validated and the project directory - used to determine the Android Runtime version.
507513
* @return {NativeScriptDoctor.IWarning[]} An array of errors from the validation checks. If there are no errors will return [].
508514
*/
509-
validateMinSupportedTargetSdk(options: ITargetValidationOptions): NativeScriptDoctor.IWarning[];
515+
validateMinSupportedTargetSdk(
516+
options: ITargetValidationOptions
517+
): NativeScriptDoctor.IWarning[];
510518

511519
/**
512520
* Validates if the provided targetSdk is lower that the maximum supported target SDK.
513521
* @param {ITargetValidationOptions} options The targetSdk to be validated and the project directory - used to determine the Android Runtime version.
514522
* @return {NativeScriptDoctor.IWarning[]} An array of errors from the validation checks. If there are no errors will return [].
515523
*/
516-
validataMaxSupportedTargetSdk(options: ITargetValidationOptions): NativeScriptDoctor.IWarning[];
524+
validataMaxSupportedTargetSdk(
525+
options: ITargetValidationOptions
526+
): NativeScriptDoctor.IWarning[];
517527

518528
/**
519529
* Returns the path to the emulator executable.

0 commit comments

Comments
 (0)