Giter Site home page Giter Site logo

libpy's Introduction

libpy

An experiment on Python environments

Usage

In python.edn change the sample path to your environment path. It must be a base path, such as:

/home/username/miniconda3/envs/myenv

After this you can use leiningen as usual by adding python to your commands.

lein python run # or any other task

Explanation

This simply exploits a leiningen plugin (lein-with-env-vars) to load the PYTHONHOME env variable before doing anything else.

This lets us have access to the path at runtime and with this we can prepend it to the usual :java-library-path. It must be prepended (even better if completely overwritten, and after initialization reset to the initial state), otherwise we might end up finding other Python versions along the usual path.

Moreover, some environments on some systems have everything inside the bin and lib folders, while others have the python binaries inside the base path. So /my/python/path/lib and /my/python/path/bin are generated and added in order after the base path, but before the default :java-library-path.

At this point the Python session was getting lost because for some reason when started like this it doesn't get the current env, so the VM was starting, but it couldn't load anything and it was breaking. Be aware that this breaks because Python tries looking for itself within PYTHONHOME, but if the latter is empty than it falls back to /usr/local (source: https://docs.python.org/3.7/using/cmdline.html#envvar-PYTHONHOME).

This fact means that you might start the VM from your wanted environment, Python gets loaded from /usr/local if it can be found there and then everything breaks when you try to import things from your environment.

With lein-with-env-vars + some code before initialize! we can be (somewhat) sure to start everything from the wanted folder.

libpy's People

Contributors

alanmarazzi avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.