Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No example #1

Open
StellaLupus opened this issue Sep 24, 2024 · 7 comments
Open

No example #1

StellaLupus opened this issue Sep 24, 2024 · 7 comments

Comments

@StellaLupus
Copy link

There is no example how to use this library by importing plugin.
Example from main readme and from kpy-sample (which uses local library) not working

@Martmists-GH
Copy link
Owner

What do you mean when you say it's not working? Are there compilation errors, runtime errors, or something else?

@StellaLupus
Copy link
Author

For now I got error from setup.py:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied

I will add PR for how-to when it will work)

@StellaLupus
Copy link
Author

StellaLupus commented Sep 24, 2024

After build or run setup.py there is no "generated" folder
Here is my build.gradle.kts:

build.gradle.kts
import com.martmists.kpy.plugin.PythonVersion
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import java.util.*

plugins {
  alias(libs.plugins.kotlin.multiplatform)
  alias(libs.plugins.kpy)
}

val targetName = "native"

kotlin {
  jvm()
  val hostOs = System.getProperty("os.name")
  val isMingwX64 = hostOs.startsWith("Windows")
  val isArm64 = System.getProperty("os.arch") == "aarch64"
  val nativeTarget = when {
      hostOs == "Mac OS X" && !isArm64 -> macosX64(targetName)
      hostOs == "Linux" && !isArm64 -> linuxX64(targetName)
      hostOs == "Mac OS X" && isArm64 -> macosArm64(targetName)
      hostOs == "Linux" && isArm64 -> linuxArm64(targetName)
      isMingwX64 -> mingwX64(targetName)
      else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
  }

  sourceSets {
      val commonMain by getting {
          dependencies {
          }
      }
      val commonTest by getting {
          dependencies {
          }
      }
  }

  nativeTarget.apply {
      val main by compilations.getting {

      }

      binaries {
          staticLib {
              @OptIn(ExperimentalKotlinGradlePluginApi::class)
              compilerOptions {
                  optIn = listOf(
                      "kotlinx.cinterop.ExperimentalForeignApi",
                  )
              }
          }
      }
  }
}

kpy {
  target = targetName
  generateStubs = true
  pyVersion = PythonVersion.Py310
  moduleName = rootProject.name
  version = rootProject.version

}

@Martmists-GH
Copy link
Owner

For now I got error from setup.py:

Are you installing it with python setup.py install or pip install .? The latter might not work because of the somewhat recently introduced build isolation.

@StellaLupus
Copy link
Author

StellaLupus commented Sep 25, 2024

When I run pip install . I got error:

Error
{'packages': [], 'package_dir': {'': 'D:\\WorkSL\x07ngrydata\\library\x08uild/generated/ksp/native/nativeMain/resources'}}
    running bdist_wheel
    error: error in 'egg_base' option: 'D:\WorkSLngrydata\libraryuild/generated/ksp/native/nativeMain/resources' does not exist or is not a directory
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel

And there no build/generated/ksp... folder. What should I run to generate?

@Martmists-GH
Copy link
Owner

run pip install . --no-build-isolation should do the trick I believe

@StellaLupus
Copy link
Author

StellaLupus commented Sep 25, 2024

run pip install . --no-build-isolation should do the trick I believe

Same error. There no generated folder.
Perhaps I have the wrong build script, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants