Giter VIP home page Giter VIP logo

Comments (10)

rytilahti avatar rytilahti commented on June 19, 2024 1

Hi and thanks for the report (and testing)!

First things first, it's practically never a good idea to use sudo to install python packages, instead of having virtual environments ready to use. Likewise, it's better to avoid modifying sys.path manually.

Anyway, this is actually one of the things that makes poetry a bit annoying from end user perspective. The idea behind having separate virtual environments is to make sure the installation is always in a workable environment, but this does not play so well with entrypoint scripts (as you noted). One potential way, to my understanding, could be to use https://github.com/pipxproject/pipx to manage the installs (which in turn handles environment separation while still storing the entrypoint scripts, like kasa, in a centralized place).

As soon as we have a release out, it will be simply a fact of pip installing the package wherever wanted. At the moment the same behavior can be achieved by building a wheel and installing it with pip as usual:

$ poetry build
Building python-kasa (0.4.0.dev0)
 - Building sdist
 - Built python-kasa-0.4.0.dev0.tar.gz

 - Building wheel
 - Built python_kasa-0.4.0.dev0-py3-none-any.whl

$ pip install dist/python_kasa-0.4.0.dev0-py3-none-any.whl 

For development setup, you can use virtualenvs.create setting for poetry (https://python-poetry.org/docs/configuration/#virtualenvscreate-boolean) for the specific project by calling:
$ poetry config virtualenvs.create false --local
or globally:
$ poetry config virtualenvs.create false

which allows to install the package with poetry installinto your current environment.

edit: actually, if you have already activated virtual environment, it will be used automatically, so there is no need to change the poetry configuration.

What is your end goal? Are you thinking about changing the code, or just using it? If the latter, the build&install approach is the way to go..

This needs definitely to be documented, so I'm going to reopen this. I'm unsure what is best approach to document, though...

from python-kasa.

xywang84 avatar xywang84 commented on June 19, 2024 1

Hi sorry for the late response to this. Thanks for the information! My use of this was solely as an end user, not sure I'd have too much to contribute as a dev, so my goal was to simply build and install. I didn't even know anything about building a wheel and installing it, and it seems like that last piece you put up would be really helpful to have in the README. Thanks for the responsiveness!

from python-kasa.

rytilahti avatar rytilahti commented on June 19, 2024 1

Yes, the README needs to be made more approachable and it's on my TODO, but until then, I created a pre-release (0.4.0.dev0) which is now available on pypi: https://pypi.org/project/python-kasa/ . So passing --pre to pip will allow installation until a proper release is made:

virtualenv venv
source venv/activate
pip install --pre python-kasa

from python-kasa.

xywang84 avatar xywang84 commented on June 19, 2024

Ok digging into this a little further, it seems like I totally misunderstood what poetry is about (this project is the first time I've ever heard of it, being not well versed at all in the python development world). It seems like it installs everything in:

/home/pi/.cache/pypoetry/virtualenvs/python-kasa-BwJufRoA-py3.7

and creates a virtual environment. So i can seem to be able to run the kasa program in the bin/ directory there. I can load the kasa module if I run python from the directory i cloned git into and ran the poetry install process in. However, running python in any other directory the kasa module is not found. I assume this is by design.

Given this as the case, as someone who isn't well versed in how things should be done, what is the proper way to use the kasa module outside of the directory with the virtual environment?

Thanks.

from python-kasa.

xywang84 avatar xywang84 commented on June 19, 2024

Ok looks like you also have to append $GIT_DIR/python-kasa into your sys.path as well.

I guess the previous install flow made all of this automatic (or maybe it was because I was running those within a miniconda environment in MAC/Linux Subsystem from Windows) but in RPI it seems like you have to add the links yourself.

So based on my experience, kasa executable is in ~/.cache/pypoetry/python-kasa-....-py3.7/bin
And to use python modules, need to add $GIRDIR/python-kasa to your sys.path.

Perhaps it would be helpful to put this in the README to help out more amateur people like me? But there is no bug in the code or install process.

Xiao

from python-kasa.

theyosh avatar theyosh commented on June 19, 2024

Or, is it possible that @rytilahti put the pip package to https://pypi.org/ ? That would make the installation super easy for end users. And make me very happy :D

from python-kasa.

rytilahti avatar rytilahti commented on June 19, 2024

Yes, the plan is obviously to put it in pypi :-)

I'm just waiting for the merge of two PRs (#63, #65) before doing that. The plan I had in my mind is to make a dev0 release on pypi to gather some feedback, and iterate those test releases until we are confident that everything is working smoothly.

from python-kasa.

gerardpc avatar gerardpc commented on June 19, 2024

Dear all,

I have seen that there is some recent discussion regarding the installation process. I am not in a hurry, so if you are you going to upload the package to pypi I can definitely wait. I just wanted to say that it might be a good idea to include a little bit more information on how to setup everything the first time in the general Readme file. I was a bit confused until I saw this thread...

Keep up the good work and thanks!

from python-kasa.

theyosh avatar theyosh commented on June 19, 2024

Same here. For now, I can work with the explanation here to make the local pip package. So there is no hurry from my side.

from python-kasa.

pidg avatar pidg commented on June 19, 2024

Sorry, I deleted my comment as I did get it working using the instructions above :)

Thank you for your work!

from python-kasa.

Related Issues (20)

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.