Skip to content

Commit

Permalink
fix: remove python six requirement (#5785)
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 committed Feb 1, 2024
1 parent 500d751 commit 25ae1f0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 66 deletions.
11 changes: 2 additions & 9 deletions packages/doctor/src/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ export class Doctor implements NativeScriptDoctor.IDoctor {
);

if (sysInfoData.xcodeVer && sysInfoData.cocoaPodsVer) {
const isCocoaPodsWorkingCorrectly = await this.sysInfo.isCocoaPodsWorkingCorrectly();
const isCocoaPodsWorkingCorrectly =
await this.sysInfo.isCocoaPodsWorkingCorrectly();
result = result.concat(
this.processSysInfoItem({
item: isCocoaPodsWorkingCorrectly,
Expand Down Expand Up @@ -259,14 +260,6 @@ export class Doctor implements NativeScriptDoctor.IDoctor {
EOL +
`Error while validating Python packages. Error is: ${sysInfoData.pythonInfo.installationErrorMessage}`,
platforms: [Constants.IOS_PLATFORM_NAME],
}),
this.processSysInfoItem({
item: sysInfoData.pythonInfo.isSixPackageInstalled,
infoMessage: `The Python 'six' package is found.`,
warningMessage: `The Python 'six' package not found.`,
additionalInformation:
"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.",
platforms: [Constants.IOS_PLATFORM_NAME],
})
);

Expand Down
34 changes: 14 additions & 20 deletions packages/doctor/src/sys-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,21 +493,15 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
async (): Promise<NativeScriptDoctor.IPythonInfo> => {
if (this.hostInfo.isDarwin) {
try {
await this.childProcess.exec(`python3 -c "import six"`);
await this.childProcess.exec(`python3 --version`);
} catch (error) {
// error.code = 1 so the Python is present, but we don't have six.
if (error.code === 1) {
return { isInstalled: true, isSixPackageInstalled: false };
}

return {
isInstalled: false,
isSixPackageInstalled: false,
installationErrorMessage: error.message,
};
}

return { isInstalled: true, isSixPackageInstalled: true };
return { isInstalled: true };
}

return null;
Expand Down Expand Up @@ -678,9 +672,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
return this.getValueForProperty(
() => this.commonSysInfoCache,
async (): Promise<NativeScriptDoctor.ICommonSysInfoData> => {
const result: NativeScriptDoctor.ICommonSysInfoData = Object.create(
null
);
const result: NativeScriptDoctor.ICommonSysInfoData =
Object.create(null);

// os stuff
result.platform = platform();
Expand Down Expand Up @@ -708,8 +701,10 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
result.xcodeprojLocation = await this.getXcodeprojLocation();
result.itunesInstalled = await this.isITunesInstalled();
result.cocoaPodsVer = await this.getCocoaPodsVersion();
result.isCocoaPodsWorkingCorrectly = await this.isCocoaPodsWorkingCorrectly();
result.isCocoaPodsUpdateRequired = await this.isCocoaPodsUpdateRequired();
result.isCocoaPodsWorkingCorrectly =
await this.isCocoaPodsWorkingCorrectly();
result.isCocoaPodsUpdateRequired =
await this.isCocoaPodsUpdateRequired();
result.pythonInfo = await this.getPythonInfo();

return result;
Expand All @@ -723,9 +718,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
return this.getValueForProperty(
() => this.androidSysInfoCache,
async (): Promise<NativeScriptDoctor.IAndroidSysInfoData> => {
const result: NativeScriptDoctor.IAndroidSysInfoData = Object.create(
null
);
const result: NativeScriptDoctor.IAndroidSysInfoData =
Object.create(null);

result.dotNetVer = await this.hostInfo.dotNetVersion();
result.javacVersion = await this.getJavaCompilerVersion();
Expand All @@ -737,7 +731,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
result.androidInstalled = await this.isAndroidInstalled();
result.monoVer = await this.getMonoVersion();
result.gradleVer = await this.getGradleVersion();
result.isAndroidSdkConfiguredCorrectly = await this.isAndroidSdkConfiguredCorrectly();
result.isAndroidSdkConfiguredCorrectly =
await this.isAndroidSdkConfiguredCorrectly();

return result;
}
Expand All @@ -749,9 +744,8 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
regExp: RegExp
): Promise<string> {
let javaExecutableVersion: string = null;
const javaExecutablePath = this.getJavaExecutablePathFromJavaHome(
javaExecutableName
);
const javaExecutablePath =
this.getJavaExecutablePathFromJavaHome(javaExecutableName);
if (javaExecutablePath) {
javaExecutableVersion = await this.getVersionOfJavaExecutable(
javaExecutablePath,
Expand Down
50 changes: 23 additions & 27 deletions packages/doctor/test/sys-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function createChildProcessResults(
"tns --version": childProcessResult.nativeScriptCliVersion,
emulator: { shouldThrowError: false },
"which git": childProcessResult.git,
'python3 -c "import six"': childProcessResult.pythonInfo,
"python3 --version": childProcessResult.pythonInfo,
};
}

Expand Down Expand Up @@ -164,9 +164,8 @@ function mockSysInfo(
isLinux: !hostInfoOptions.isDarwin && !hostInfoOptions.isWindows,
winreg,
};
const childProcessResultDictionary = createChildProcessResults(
childProcessResult
);
const childProcessResultDictionary =
createChildProcessResults(childProcessResult);
const childProcess = {
exec: async (command: string) => {
return getResultFromChildProcess(
Expand Down Expand Up @@ -558,7 +557,8 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
null
);
const adbVersion = await sysInfo.getAdbVersion();
const isAndroidSdkConfiguredCorrectly = await sysInfo.isAndroidSdkConfiguredCorrectly();
const isAndroidSdkConfiguredCorrectly =
await sysInfo.isAndroidSdkConfiguredCorrectly();
assert.deepEqual(adbVersion, null);
assert.deepEqual(isAndroidSdkConfiguredCorrectly, undefined);
});
Expand All @@ -583,7 +583,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
const pythonInfo = await sysInfo.getPythonInfo();
assert.deepEqual(pythonInfo, null);
});
it("should return {isInstalled: true, isSixPackageInstalled: true} when python is correctly installed on Mac", async () => {
it("should return {isInstalled: true} when python is correctly installed on Mac", async () => {
childProcessResult.pythonInfo = { result: "" };
sysInfo = mockSysInfo(
childProcessResult,
Expand All @@ -593,10 +593,9 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
const pythonInfo = await sysInfo.getPythonInfo();
assert.deepEqual(pythonInfo, {
isInstalled: true,
isSixPackageInstalled: true,
});
});
it("should return {isInstalled: false, isSixPackageInstalled: false} when python check throws an error", async () => {
it("should return {isInstalled: false} when python check throws an error", async () => {
childProcessResult.pythonInfo = { shouldThrowError: true };
sysInfo = mockSysInfo(
childProcessResult,
Expand All @@ -606,27 +605,25 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)`),
const pythonInfo = await sysInfo.getPythonInfo();
assert.deepEqual(pythonInfo, {
isInstalled: false,
isSixPackageInstalled: false,
installationErrorMessage:
'This one throws error. (python3 -c "import six")',
});
});
it("should return {isInstalled: true, isSixPackageInstalled: false} when python is installed but six package is not", async () => {
childProcessResult.pythonInfo = {
shouldThrowError: true,
errorCode: 1,
};
sysInfo = mockSysInfo(
childProcessResult,
{ isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" },
null
);
const pythonInfo = await sysInfo.getPythonInfo();
assert.deepEqual(pythonInfo, {
isInstalled: true,
isSixPackageInstalled: false,
"This one throws error. (python3 --version)",
});
});
// it("should return {isInstalled: true} when python is installed but six package is not", async () => {
// childProcessResult.pythonInfo = {
// shouldThrowError: true,
// errorCode: 1,
// };
// sysInfo = mockSysInfo(
// childProcessResult,
// { isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" },
// null
// );
// const pythonInfo = await sysInfo.getPythonInfo();
// assert.deepEqual(pythonInfo, {
// isInstalled: true,
// });
// });
});

const testData: ICLIOutputVersionTestCase[] = [
Expand Down Expand Up @@ -823,7 +820,6 @@ ${expectedCliVersion}`;
assert.deepEqual(result.isCocoaPodsUpdateRequired, false);
assert.deepEqual(result.pythonInfo, {
isInstalled: false,
isSixPackageInstalled: false,
installationErrorMessage:
"Cannot read properties of undefined (reading 'shouldThrowError')",
});
Expand Down
30 changes: 20 additions & 10 deletions packages/doctor/typings/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ declare module NativeScriptDoctor {
* @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.
* @return {Promise<boolean>} true if local build can be executed for the provided platform.
*/
canExecuteLocalBuild(platform: string, projectDir?: string, runtimeVersion?: string): Promise<boolean>;
canExecuteLocalBuild(
platform: string,
projectDir?: string,
runtimeVersion?: string
): Promise<boolean>;

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

interface ISysInfoData extends ICommonSysInfoData, IiOSSysInfoData, IAndroidSysInfoData { }
interface ISysInfoData
extends ICommonSysInfoData,
IiOSSysInfoData,
IAndroidSysInfoData {}

/**
* Describes warning returned from @nativescript/doctor check.
Expand Down Expand Up @@ -438,11 +445,6 @@ declare module NativeScriptDoctor {
*/
isInstalled: boolean;

/**
* Determines whether python six package is installed
*/
isSixPackageInstalled: boolean;

/**
* Error message from installation check
*/
Expand Down Expand Up @@ -487,7 +489,11 @@ declare module NativeScriptDoctor {
* @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.
* @return {NativeScriptDoctor.IWarning[]} An array of errors from the validation checks. If there are no errors will return [].
*/
validateJavacVersion(installedJavaVersion: string, projectDir?: string, runtimeVersion?: string): NativeScriptDoctor.IWarning[];
validateJavacVersion(
installedJavaVersion: string,
projectDir?: string,
runtimeVersion?: string
): NativeScriptDoctor.IWarning[];

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

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

/**
* Returns the path to the emulator executable.
Expand Down

0 comments on commit 25ae1f0

Please sign in to comment.