pygo is a Go application designed to automate the management of Python environments, both locally and globally. Its primary functionality includes creating and managing Python environments, and automatically sourcing the environment when the program runs. Additionally, it sets up directories for source code (src) and tests (tests) during the setup process.
Project uses golang cli package as a base and also relies on python libraries:
- Automatic Python Environment Management: pygo simplifies the process of managing Python environments, allowing users to create and switch between local and global environments.
- Environment Sourcing: The application automatically sources the designated Python environment when the program is executed, ensuring that the correct environment settings are applied.
- Directory Setup: Upon setup, pygo creates the necessary directories (
srcandtests) for organizing source code and test files. - Pip Handler: After setup, adding and removing python packages becomes seemless expirience.
- Pytest/mypy included: Following good programing practice, tests are running under
pygo testand not only manually written tests are checked, but optional static type as well (withmypylibrary).
- Download or Clone the Repository:
git clone https://github.com/ReiterAdam/pygo.git - Build the Application:
Navigate to the project directory and build the application using the
go buildcommand:cd pygo && go build - Move the Executable:
Move the generated executable (
pygo) to a directory included in your system's PATH for easy access:mv pygo /usr/local/bin
-
Setup Python Environment: Create your project directory and nevigate there. Then, to set up a Python environment, use the following command with required flag (
--type localor--type global):pygo setup --type localThis command will create
.venvdirectory that contains python virtual environment and basic structure for your project:
.
├── src
│ ├── __init__.py
│ └── main.py
└── tests
└── __init__.py
If flag --type global is used, then global virtual environment is created in path ~/.pygo/.venv
-
Run Your Program:
After setting up the environment, simply run your program using the
pygo runcommand in projects root directory:pygo runThis command sources an existing environment (flag--typehas valuelocalby default) and runssrc/main.py. If you want to provide command line arguments for your program, it is also supported:pygo run arg1 arg2 -
Test Your Program:
If you want to test your program, you need to write your tests in tests directory. For example, you could create file
test_basic.pystarting with linefrom src.main import <your function>to import your function fromsrc/main.py.Then run test from project root directory with:
pygo testThis command sources existing environment (flag--typehas valuelocalby default) and runspytest tests/. While the command is running, it also kicks a type checking usingmypylibrary. While static typing is purely optional, this library ensures, that no type has been mistaken without even running project code. -
Manage external libraries:
Adding external library to your python envirionment happens with command:
pygo add <library name>You can also remove some package from your virtual environment with command:pygo remove <library name>You also type more than one package name (just like inpip). Note, similary to other commands,addandremovewill try to use flag--type localby default and usage of global virtual environment must be exceptionaly written with--type global
Contributions to pygo are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository.
This project is licensed under the MIT License - see the LICENSE file for details.