I am new to Github, Linux and Python and I have very little experience with command line commands. It was a very long time since I changed from DOS to Windows so I would like to use a GUI for development.
I have tried to follow the instructions in your turtorial but have only found a short instruction on how to setup PyCharm. The rest is based on comman line commands.
I managed to create a plugin base catalog in the c:\Devel catalog using cookiecutter but when I should push it to Github I got lost. I manually created a repository on Github, having to insert all the data again which I alredy typed in when creating the plugin with cookiecutter. What is the correct way to do it using PyCharm?
Some more detailed instructions on how to devellop plugins using PyCharm instead of command line would be much appreciated.
Sorry if I wasn't clear about what I wated. I'm only used to develop applications on WIndows using Visual Studio and other Windows based IDEs so CLI is not my cup of tea. CLI do not offer any sytax help while typing so you need to know exacly what to type. It may be easy for you but unfortunately not for me.
So I would like to have instructions using PyCharm GUI commands (or other IDE) replacing all of the CLI commands described in the tutorial.
I can understand your desire to use a GUI for development but I don't believe the elimination of all CLI commands is an accomplishable (or desirable) goal. Using (and troubleshooting) Linux and OctoPrint is going to require some CLI commands. OctoPrint and Python as well, I suspect although I've never used PyCharm myself.
The question I would ask is If I want to develop plugins using PyCharm, is there (or could there be) a tutorial on how to do that..
@foosel will correct me if I'm wrong, but I think her development environment is PyCharm on Windows with OctoPrint installed on that same system. Perhaps others that use PyCharm can describe their development environment.
I have PyCharm pro setup for development. I think I might tend to agree with @b-morgan when he says that you cannot get away from all CLI commands.
The key ones are installing packages, specifically OctoPrint and your plugin in editable mode. Those are the main CLI commands, once you've done that, creating a run/debug config, as well as all git operations can be performed from the PyCharm IDE. I would say it is a case of 'setup & install with commands' and then continue with the GUI after that.
Look for the tab named 'Git' on the bottom row of tabs. Maybe you want to find a 'Git in PyCharm' tutorial or something, since some of the operations are a bit hidden. There's nothing special to OctoPrint plugins, and git, so anything should do.
I've tried to figure out how PyCharm works and found File->Settings-Project->Python Interpreter. When I click the dropdown at the top I will see the following dialog
This makes me think about the virtual environment I was told to setup.
Is this required? Can't I use this setting instead? The Python 3.8 seems to be installed with the installation of PyCharm so now it looks as if I have two of them installed.
All installed packages are listed and you also have the possibility to install more.
Here I ran into a problem. I need the Bright-Pi driver from https://github.com/PiSupply/Bright-Pi.
I tried to install it using the + at the top corner of the package listing, but it is refused with the following error message
(had to remove the picture due to restrictions on this site, but it says ERROR: Could not find a version that satisfies the requirement brightpi (from version none))
Do I need to use a CLI comman instead and what would that be or should I point to a specific folder/file in the package?
In the PyCharm GUI, there is a terminal section you could type it in. Honestly, I would just type it to save yourself the time. It only has to be done once. But I will break it down:
pip install -e .[develop,plugins,docs]
pip install : Install the package using pip
-e : in editable mode (so you can make changes to OctoPrint / change git branches without reinstalling
. the dot means 'install this current folder', so if you have the OctoPrint project open, it will install that.
[...] the parameters in the brackets are passed to OctoPrint's setup.py to install with:
develop - install some development CLI tools
plugins - install plugin development tools (such as running octoprint dev plugin:new to create the plugin template for you
docs install the tools for building the docs. Only works on Python 3.
I am not sure you will find a substitute for them, and if I were you I would try and open the 'terminal' tab at the bottom of the interface & run the command. It can't be broken down into separate steps easily, since it is all 'install' but with options.
Yes, sure I can type the command. The thing is, I want to know what I am doing.
Editing mode (so you can make changes ...) is still a bit fuzzy.
The .
My prompt is: (venv3) C:\Users\Lars\PycharmProjects\OctoPrint>
Does this mean current directory is
C:\Users\Lars\PycharmProjects\OctoPrint
or
C:\Users\Lars\PycharmProjects\OctoPrint\venv3
[develop,plugins,docs]
Does this mean it will install the packages listed in develop, plugins and docs
:
Additional requirements for optional install options
EXTRA_REQUIRES = dict(
# Dependencies for developing OctoPrint
develop=[
# Testing dependencies - SEE ALSO tox.ini
"mock>=3.0.5,<4",
"pytest==4.6.10",
"pytest-doctest-custom>=1.0.0,<2",
"ddt",
# linter
"flake8",
# profiler
"pyinstrument",
],
# Dependencies for developing OctoPrint plugins
plugins=[
"cookiecutter>=1.7.2,<1.8"
],
# Dependencies for building the documentation - Python 3 required!
docs=[
"sphinx>=3,<4",
"sphinxcontrib-httpdomain",
"sphinxcontrib-mermaid",
"sphinx_rtd_theme",
"readthedocs-sphinx-ext"
],
What are you trying to develop? If you want to contribute to OctoPrint, you need to be able to edit the files, to test out your changes.
Correct with that one, the (venv3) is showing which virtual environment is activated, which you selected in 'Project Interpreter'
You are exactly right, it installs those additional dependencies so that the tools can work. As well as the rest of them for installation of OctoPrint. So it is 'standard' + the options. If you don't want them, don't install them.
Nothing, it is just installing OctoPrint + dependencies
Charlie,
I checked out the link you posted a couple of days ago and I realized that I did follow these instructions some time ago without realizing that they actually replaces most of the CLI commands inluding
pip install -e .[develop,plugins,docs].
Unfortunately the instructions for the "Add Run/Debug configuration" probably are created for an older version of PyCharm. The Project parameter do no longer exsist in the dialog so I cannot insert that.
I also added the "Before launch" commands as recommended.
When I try to run the "Octoprint server" I will get:
Error running 'Clean build directory': Executable is not specified.
Apologies for not getting back to you sooner on this one
The idea of it being 'editable' comes down to some knowledge of how python packages work, and imports. When you use import octoprint or something in a file, Python looks for installed packages to read. By making it an editable install, it means you can change something, and it will automatically know to look in your source code, rather than in the site-packages directory.
I don't personally use the specified 'before launch' commands, since most of my development is done with deployment to remote machines, on the network. I personally would not worry about the clean build directory, or updating dependencies, since it is not something most people need to look at. My setup works fine without these commands.
No problem, I'm greatful for your help and thanks for your patience.
I have now removed the "Before launch" commands but now it can't find module OctoPrint, in fact when I click on ... it can't find any module.
I am using PyCharm Comunity 2020.2 so my dialog do not exactly match the description.
I however did try an other setting, selecting to run Script Run instead of module OctoPrint and it seems to work. Is this OK or will it fail in some way later? What will be the difference?
I also tried to run the OctoPrint docs configuration but it also complanes: No module named sphinx.cmd build.
Do I have to register "modules" in some way?
I also have a question about the --debug parameter.
I have two buttons to start the program/server; the Run button and the Debug button. Isn't this defining if I want to run in debug mode or not, so why the --debug parameter?
I'm not entirely sure about the problems with finding the modules, and the selecting 'Script Run' should not cause problems if it works, after all it is just getting the server up and running.
And the guide may be for PyCharm Professional, since that's what I know Gina is using (who probably wrote the instructions), as am I and I think I can see most of the fields.
The difference between the parameter --debug and pressing 'Debug' button:
The parameter is passed to OctoPrint to set it's logging level. Normally, it is at INFO level, when --debug is passed it is set to logging DEBUG level. This is only for the logging that is either printed to the console or saved to octoprint.log
Pressing Pycharm's 'debug' button connects it's interactive debugger, which allows you to set breakpoints and pause the code, to check it is running right. There's a lot of functionality there, I would recommend some research into how to use a python debugger effectively.