Comments (10)
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 install
into 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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
- KS240 gets discovered but will not authenticate HOT 43
- Document device features HOT 2
- Be more lax on unknown SMART* devices
- Extend cli to allow defining --child across all relevant commands HOT 2
- __init__() missing 1 required positional argument: 'backend' HOT 2
- Add units to features and convert emeter to use features
- Simplify request id generator for AesTransport
- Improve feature/module testing and coverage for SMART devices HOT 1
- Update documentation for new interfaces
- [META] 0.7 series - module support for SMART devices, support for introspectable device features and refactoring the library HOT 1
- Klap protocol needs to retry after 403 error HOT 1
- Cannot add Tapo Plug P110 to Home Assistant 2024.2.3 - Error in debug mode HOT 6
- child device component_nego and module queries for dump_devinfo HOT 3
- Error when trying to discover new Tapo P110 plug HOT 8
- TAPO P100 (hw 1.0.0, sw 1.1.3) EU plug with 0.6.2.1 Kasa results JSON_DECODE_FAIL_ERROR HOT 5
- TP-Kasa Ks240 smart Switch DOES NOT WORK HOT 1
- Handle child-embedded module data
- Handle modules supported only by children
- "Unclosed client session" Trying to set brightness on Tapo Bulb HOT 1
- HS220's with 1.0.10 firmware without Internet Access HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-kasa.