Skip to content

Python implementation of kscript #232

Closed

Description

@hanslovsky

I would like to create a Python implementation of kscript for ease of use on Windows machines without cygwin or other solutions and easy distribution through PyPI and conda.

As far as I can tell, the relevant bash code for kscript lives in src/kscript. I searched this repo for "env bash" and a few more files showed up (on commit ba74b62):

  • misc/experimental/kscriptJarStub
  • misc/experimental/kscriptD
  • test/resources/custom_dsl/mydsl
  • misc/kshell_launcher/kshell_kts.sh
  • misc/docker_tests.sh
  • test/test_suite.sh
  • src/main/kotlin/kscript/app/AppHelpers.kt

I assume that anything with test or experimental in it would not be relevant for a Python implementation (for now), leaving only kshell_kts.sh and AppHelpers.

Is AppHelpers.packageKscript intended to be run on the client machine? If yes, the use of bash may be prohibitive for a Python implementation of kscript.

Other issues are:

  • Should a Python implementation live in a separate repository or within the kscript main repository?
  • Potential name clashes of the python kscript executable with the existing kscript bash script

Possibly related: #36

Activity

  1. holgerbrandl commented on Jul 1, 2019

    @holgerbrandl
    Collaborator

    Indeed, you could ignore experimental and misc. You need to widen your search by also including evalBash because kscript is actually launching a few shell processes internally to compile code etc.

    Feel welcome to reimplement it, but for windows compatibility, you just need a bash shell (like git-bash) and bash on the PATH. This works for me, and if it does not for you, I'd consider it a bug that we should address.

    Yes, packaging is intended to run on the client machine. See https://github.com/holgerbrandl/kscript#deploy-scripts-as-standalone-binaries

    kscript is a shell tool. I'm not sure how to remove its dependency on the shell without rewriting it. So a python version should deserve an own repo imho. And to prevent user confusion a different name for the executable would clearly help.

  2. hanslovsky commented on Jul 2, 2019

    @hanslovsky
    ContributorAuthor

    Feel welcome to reimplement it, but for windows compatibility, you just need a bash shell (like git-bash) and bash on the PATH. This works for me, and if it does not for you, I'd consider it a bug that we should address.

    I am a Linux user and not too familiar with Windows, but I would still like to make code available for use on Windows. I will investigate if git-bash is a viable solution in practice. A little overhead on the client side for installation is preferable to a complete re-implementation in Python, especially as git-bash is available on conda. I will look into it and report my decision

  3. holgerbrandl commented on Jul 2, 2019

    @holgerbrandl
    Collaborator

    I think the best approach for better platform interop would be to refactor ìnteral evalBash away. Next, the shell launcher itself could be easily reimplemented in any scripting lang and we could potentially even bundle it with the current installation bundles.

    Another approach for better platform compatibility would be to use the kotlin compiler api (see #205).

  4. holgerbrandl commented on Sep 2, 2019

    @holgerbrandl
    Collaborator

    I'm closing this ticket because it does not seem an issue with kscript itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions