- atom-python-run package
- Contents
- Prerequisite
- Features
- Compatibility
- Documentation
- Issues
- Development
- I think this package is bad news.
- Настройка Atom от GitHub для работы с PHP, Python и некоторыми другими языками программирования
- Linter
- Пакет Script: запуск программ из Atom
- Python
- Swift
- Терминал
- Script
- Installation
- Atom can’t find node | ruby | python | my socks
- Usage
- Command and shortcut reference
- Replacements
- Development
- Quick and dirty setup
- I already cloned it!
- Workflow
- I think this package is bad news.
atom-python-run package
Run your python (.py) source file using F5 or F6 !
Contents
Prerequisite
- Atom Text Editor (nightly or latest stable release)
- Python 2 and/or 3
- Add Python (and any other interpreters) to the PATH environment variable.
Features
- Using python
- Almost the same console with python IDLE, which provides syntax error and runtime error messages.
- CodeBlocks debug console style
- Shows return value and execution time
- It is a rough time based on real time rather than CPU kernel / user time
- Shows return value and execution time
Compatibility
Cross Platform Compatible
- Runs on Windows, Mac OS X, and Linux
True Arbitrary Execution
- Global python is the default interpreter
- Execute using any interpreter
- Pass options to the given interpreter
- Pass arguments to the program to be executed
- Note: If you have problems executing, you can install a global version of latest python2.7.x (even if you have python3.x.x installed). Please report any python3 issues if you want to avoid installing a global python2 version.
Documentation
This project has been documented in a fair amount of detail over time. This documentation can be found in the Wiki.
Everyone should take the time to reveiw the Wiki README at the bare minimum. It details an overview on how to handle issues, use different versions, and includes links to primary sections of the Wiki.
Everyone should also take the time to review the Wiki section How do I use atom-python-run?. It covers everything from installation, to configuration, logging, and much more. You just might be surprised by what you can do with atom-python-run.
You should have the basics after having covered both the README and How Do I use atom-python-run? sections. Most FAQ’s can be resolved by simply reading them. The guides provided should allow us to help you with what ever issue you’re facing.
NOTE: Be sure to read the Wiki and the Wiki README before reporting an issue or making a pull request. A lot of time has been put in to it to help you the user (or dev) get started and on your way.
Issues
- Before newing an issue, check to see if someone else is experiencing any related issues.
- Check to see if any issues that were closed resemble your issue and re-open it addressing that you’re experiencing a similar issue.
- Provide details about your issue, such as errors and/or logs.
- Provide reproduction steps (we can’t help you if we don’t know how to reproduce the error!).
Development
If you’re a developer and are interested in this project you can find this repos API’s in the Wiki. More specifically, you’ll want to take a look at How does the cp module work? and How does the terminal.js module work? sections of the Wiki.
You can also just read the key source files
- cp (cp is written in python)
- terminal.js
- atom-python-run.js
- New an issue if you have any idea of new features.
This is a package for Atom
I think this package is bad news.
Good catch. Let us know what about this package looks wrong to you, and we’ll investigate right away.
Настройка Atom от GitHub для работы с PHP, Python и некоторыми другими языками программирования
Изначально считаем что у Вас установлена поддерживаемая операционная система, Node.JS и Atom. В примерах мы работаем в OpenSUSE (13.1) в нём (и вообще в дистрибутивах *nix) уже «из коробки» обычно есть не только Python но PHP и другие языки программирования. Так же исправно работает на Ubuntu (>12.04). Если у Вас Windows 7 или 8, а раньше Вы с ними (языками) не работали то их предварительно необходимо скачать и установить.
Примечание: перед началом работы желательно запускать Atom под root.
опыт показывает — работает стабильнее
Linter
Идеология Atom к подсветке в том, что основным пакетом для работы с синтаксисом и его анализа будет Linter, который является верхним уровнем в API для других линтеров кода. Это сделано для прекращения «войны между плагинами» (The idea is to stop the linter plugins war, by providing a top level API for linters to parse and display errors in the Atom editor). Тем не менее, не все сторонние разработчики придерживаются этой идеологии и пишут свои плагины.
- linter-php , для PHP `php -l`
- linter-phpcs , для PHP, `phpc`
- linter-phpmd , для PHP, `phpmd`
- linter-pylint , для Python, `pylint`
- linter-pyflakes , для python, `pyflakes`
- linter-pep8, для python, `pep8`
- linter-flake8, для python, `flake8`
- linter-javac , для Java, `javac`
- linter-jshint , для JavaScript and JSON, `jshint`
- linter-jscs , для JavaScript, `jscs`
- linter-scss-lint , для SASS/SCSS, `scss-lint`
- linter-coffeelint , для CoffeeScript, `coffeelint`
- linter-csslint , для CSS, `csslint`
- linter-rubocop , для Ruby and Ruby on Rails, `rubocop`
- linter-tslint , для Typescript, `tslint`
- linter-xmllint , для XML, `xmllint`
- linter-shellcheck , для Bash, `shellcheck`
- linter-scalac , для Scala, `scalac`
- linter-clang , для C / C++, `clang`
- linter-ruby , для ruby, `ruby -wc`
- linter-lua , для Lua, `luac -p`
Пакет Script: запуск программ из Atom
Script — пакет для запуска кода в atom.
Установка пакета Script, возможна из командной строки:
или меню
Packages->Settings View->Install->Packages
Каждый язык работает, при наличии предварительно установленного компилятора / интерпритатора.
Пакет Script обновляется довольно часто. Например поддержка Swift появилась менее двух недель назад. Так что скорее всего в ближайшее время появится поддержка новых языков.
Для запуска программы необходимо выбрать
Packages—>Script—>Run
Дополнительные опции можно найти в документации либо на страницах Atom`а или проекта.
Для функционирования должен быть создан рабочий каталог.
Путь к нему нужно прописать здесь:
Packages—>Script—>Configure Script—>Current Working Directory
Заявку разработчикам на поддержку нового языка можно оставить здесь (отвечают быстро)
И немного юмора от разработчиков пакета Script,
у которых, судя по всему, спрашивают всё на свете:
первод: Атом не может найти Нод | Руби | Питон | Мои носки
Python
Поддержка подсветки этого языка идёт изначально. Пакеты для работы с синтаксисом и отладки:
Linter + Language Python + Linter Python Pep8 + Script
Script запускает код на Python, а Linter и Linter Python Pep8 покажут синтаксические ошибки.
Возможно Вам, для работы с Python также поможет Atom Python Debugger.
Подсветка ошибок и запуск после установки будут выглядеть так:
Swift
Терминал
Для запуска исполняемого кода С, C++, Java иногда проще использовать сторонний пакет (не пакет Atom, а пакет вашего дистрибутива), который запускается через терминал, поскольку сам Atom поддерживает большое количество языков. Если Atom выступает в качестве редактора кода, a терминал рядом запускает его — это очень удобно для нас, поскольку терминал не имеет такое преимущество редактирования, как Atom.
Для запуска терминала в окне Atom установите пакет Term. Для запуска терминала в окне Atom выбрать
Packages—>Command Palette—>Toggle и Term
с нужными параметрами.
В заключении ещё один интересный кликабельный анимационный gif от разработчиков script, ссылки.
Script
Run code in Atom!
Run scripts based on file name, a selection of code, or by line number.
Currently supported grammars are:
Grammar | File Based | Selection Based | Required Package | Required in PATH | Notes |
---|---|---|---|---|---|
Assembly (NASM) | Yes | Yes | language-x86-64-assembly | nasm , binutils | |
1C (BSL) | Yes | language-1c-bsl | oscript | ||
Ansible | Yes | language-ansible | ansible-playbook | ||
AutoHotKey | Yes | Yes | language-autohotkey | AutoHotKey.exe | |
AppleScript | Yes | Yes | language-applescript | osascript | |
Babel ES6 JS | Yes | Yes | language-babel | node | |
Bash | Yes | Yes | Runs if your SHELL or #! line is bash . | ||
Bats (Bash Automated Test System) | Yes | Yes | language-bats | bats | |
Windows Batch ( cmd.exe ) | Yes | language-batch/file | |||
Behat | Yes | behat-atom | behat | ||
BuckleScript | Yes | Yes | bs-platform | bsc | |
C | Yes | Yes | xcrun clang / cc | Available only on macOS and Linux. | |
C# | Yes | Yes | csc.exe | ||
C# Script | Yes | Yes | scriptcs | ||
C++ | Yes | Yes | xcrun clang++ / g++ | Available only on macOS and Linux. Run with -std=c++14 . | |
Clojure | Yes | Yes | lein exec | Requires Leiningen with the lein-exec plugin. | |
CoffeeScript (Literate) | Yes | Yes | coffee | ||
Crystal | Yes | Yes | language-crystal-actual | crystal | |
Cucumber (Gherkin) | Yes | language-gherkin | cucumber | ||
D | Yes | Yes | language-d | rdmd | |
Dart | Yes | Yes | dartlang | dart | |
DOT (Graphviz) | Yes | Yes | language-dot | dot | |
Elixir | Yes | Yes | language-elixir | elixir | |
Erlang | Yes | language-erlang | erl | Limited selection based runs only (see #70). | |
F* | Yes | atom-fstar | fstar | ||
F# | Yes | language-fsharp | fsharpi / fsi.exe | ||
Fish | Yes | Yes | language-fish-shell | fish | |
Forth | Yes | language-forth | gforth | ||
Fortran | Yes | language-fortran | gfortran | ||
Gnuplot | Yes | language-gnuplot-atom | gnuplot | ||
Go | Yes | go | |||
Groovy | Yes | Yes | language-groovy | groovy | |
Haskell (Literate) | Yes | Yes | language-haskell | runhaskell / ghc | |
HTML | Yes | Opens the current HTML file in your default browser. | |||
Hy | Yes | Yes | language-hy | hy.exe | |
IcedCoffeeScript | Yes | Yes | language-iced-coffee-script | iced | |
Inno Setup | Yes | language-innosetup | ISCC.exe | ||
Idris | Yes | language-idris | idris | ||
io | Yes | Yes | atom-language-io | io | |
Java | Yes | *\jdk1.x.x_xx\bin | Project directory should be the source directory; subfolders imply packaging. | ||
Javascript | Yes | Yes | node | ||
JavaScript for Automation (JXA) | Yes | Yes | language-javascript-jxa | osascript -l JavaScript | Available on macOS only. |
Jolie | Yes | language-jolie | jolie | ||
Julia | Yes | Yes | language-julia | julia | |
Kotlin | Yes | Yes | language-kotlin | kotlinc | |
LAMMPS | Yes | language-lammps | lammps | Available only on macOS and Linux. | |
LaTeX | Yes | language-latex | latexmk | ||
LilyPond | Yes | atlilypond | lilypond | ||
Lisp | Yes | Yes | language-lisp | sbcl | Selection based runs are limited to a single line. |
LiveScript | Yes | Yes | language-livescript | lsc | |
Lua | Yes | Yes | language-lua[-wow] | lua | |
Makefile | Yes | Yes | |||
MATLAB | Yes | Yes | language-matlab | matlab | |
MIPS | Yes | language-mips | spim | ||
MongoDB | Yes | Yes | language-mongodb | mongo | |
MoonScript | Yes | Yes | language-moonscript | moon | |
NCL | Yes | Yes | language-ncl | ncl | Scripts must end with an exit command for file based runs. |
newLISP | Yes | Yes | language-newlisp | newlisp | |
Nim[Script] | Yes | language-nim | nim | ||
NSIS | Yes | Yes | language-nsis | makensis | |
Objective-C[++] | Yes | xcrun clang [ ++ ] | Available on macOS only. | ||
OCaml | Yes | language-ocaml | ocaml | ||
Octave | Yes | Yes | language-matlab | octave | |
Oz | Yes | Yes | language-oz | ozc | |
Pandoc Markdown | Yes | language-pfm | panzer | ||
Pascal | Yes | Yes | language-pascal | fpc | |
Perl | Yes | Yes | |||
PHP | Yes | Yes | |||
PostgreSQL | Yes | Yes | language-pgsql | psql | Connects as user PGUSER to database PGDATABASE . Both default to your operating system’s USERNAME , but can be set in the process environment or in Atom’s init file: process.env.PGUSER = |
POV-Ray | Yes | atom-language-povray | povengine / povray | ||
PowerShell | Yes | Yes | language-powershell | powershell | |
Processing | Yes | processing-language | processing-java | ||
Prolog | Yes | language-prolog | swipl | Scripts must contain a rule with the head main (e.g. main:- parent(X,lucas),writeln(X). ). The script is executed with the goal main and exits after the first result is found. The output is produced by the writeln/1 predicates. | |
PureScript | Yes | language-purescript | pulp | ||
Python | Yes | Yes | |||
R | Yes | Yes | language-r | Rscript | |
Racket | Yes | Yes | language-racket | racket | |
Raku | Yes | Yes | raku | ||
Reason | Yes | Yes | language-reason | rebuild | |
Ren’Py | Yes | No | language-renpy | renpy | Runs your project at the root of the current file. |
Robot Framework | Yes | No | language-robot-framework | robot | The output location depends on the CWD behaviour which can be altered in settings. |
RSpec | Yes | Yes | language-rspec | rspec | |
Ruby | Yes | Yes | |||
Ruby on Rails | Yes | Yes | |||
Rust | Yes | language-rust | rustc | ||
Sage | Yes | Yes | language-sage | sage | |
Sass/SCSS | Yes | sass | |||
Scala | Yes | Yes | language-scala | scala | |
Scheme | Yes | Yes | langauge-scheme | guile | |
Shell Script | Yes | Yes | SHELL | Runs according to your default SHELL , or #! line. | |
Standard ML | Yes | language-sml | sml | ||
Stata | Yes | Yes | language-stata | stata | |
Swift | Yes | language-swift | swift | ||
Tcl | Yes | Yes | language-tcltk | tclsh | |
TypeScript | Yes | Yes | ts-node | ||
VBScript | Yes | Yes | language-vbscript | cscript | |
Zsh | Yes | Yes | Runs if your SHELL or #! line is zsh . |
NOTE: Some grammars may require you to install a custom language package.
You only have to add a few lines in a PR to support another.
Installation
apm install script
Search for script within package search in the Settings View.
Atom can’t find node | ruby | python | my socks
Make sure to launch Atom from the console/terminal. This gives atom all your useful environment variables. Additionally, make sure to run it with the project path you need. For example, use
to get it to run with the current directory as the default place to run scripts from.
Usage
Make sure to run atom from the command line to get full access to your environment variables. Running Atom from the icon will launch using launchctl’s environment.
Script: Run will perform a «File Based» run when no text is selected (default).
Script: Run while text is selected will perform a «Selection Based» run executing just the highlighted code.
Script: Run by Line Number to run using the specified line number. Note that if you select an entire line this number could be off by one due to the way Atom detects numbers while text is selected.
Script: Configure Script should be used to configure command options, program arguments, and environment variables overrides. Environment variables may be input into the options view in the form VARIABLE_NAME_ONE=value;VARIABLE_NAME_TWO=»other value»;VARIABLE_NAME_3=’test’ .
Also, in this dialog you can save options as a profile for future use. For example, you can add two profiles, one for python2.7 and another for python3 and run scripts with a specified profile, which will be more convinient than entering options every time you want to switch python versions.
If you want to use Python3 by default, you can open Atom Settings, Atom→Preferences→Open Config Folder , and open .atom/packages/script/lib/grammars/python.coffee , Changing python to python3 under ‘Selection Based’ and ‘File Based’ , saving it.
Script: Run with profile allows you to run scripts with saved profiles. Profiles can be added in Script: Run Options dialog.
Script: Kill Process will kill the process but leaves the pane open.
Script: Close View closes the pane and kills the process.
To kill everything, click the close icon in the upper right and just go back to coding.
Script: Copy Run Results copies everything written to the output pane to the clipboard, allowing you to paste it into the editor.
Command and shortcut reference
Command | macOS | Linux/Windows | Notes |
---|---|---|---|
Script: Run | cmd-i | shift-ctrl-b | If text is selected a «Selection Based» is used instead of a «File Based» run |
Script: Run by Line Number | shift-cmd-j | shift-ctrl-j | If text is selected the line number will be the last |
Script: Run Options | shift-cmd-i | shift-ctrl-alt-o | Runs the selection or whole file with the given options |
Script: Run with profile | shift-cmd-k | shift-ctrl-alt-b | Runs the selection or whole file with the specified profile |
Script: Close View | esc or ctrl-w | esc | Closes the script view window |
Script: Kill Process | ctrl-c | ctrl-q | Kills the current script process |
Replacements
The following parameters will be replaced in any entry in args (command and program arguments). They should all be enclosed in curly brackets <>
— Full path to the currently active file in Atom. E.g. /home/rgbkrk/atom-script/lib/script.coffee — Full path to the folder where the currently active file is. E.g. /home/rgbkrk/atom-script/lib — Full name and extension of active file. E.g., script.coffee — Name of active file WITHOUT extension. E.g., script — Full path to the root of the project. This is normally the path Atom has as root. E.g /home/rgbkrk/atom-script
Parameters are compatible with atom-build package.
Development
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit.
As for coding and contributing, rely on the atom contributing guidelines. They’re pretty solid.
Quick and dirty setup
apm develop script
This will clone the script repository to
/github unless you set the ATOM_REPOS_HOME environment variable.
I already cloned it!
If you cloned it somewhere else, you’ll want to use apm link —dev within the package directory, followed by apm install to get dependencies.
Workflow
After pulling upstream changes, make sure to run apm update .
To start hacking, make sure to run atom —dev from the package directory. Cut a branch while you’re working then either submit a Pull Request when done or when you want some feedback!
I think this package is bad news.
Good catch. Let us know what about this package looks wrong to you, and we’ll investigate right away.