pyportal
When you have scripts like below
# /myscripts/utils.py
def my_func():
print("hello!")
# /myscripts/data_analysis.py
def show_df(df):
print(df)
import pyportal
pyportal.path = ['/myscripts'] # OR, configure global path in environemnt variable (see below)
import pyportal.utils.file as U
U.my_func()
from pyportal.data_analysis.file import show_df
show_df()
Installation
pip install pyportal
Import from a commit
# Commit 1
# /myscripts/utils.py
def my_func():
print("version 1")
# Commit 2, timestamp 20251231235959
# /myscripts/utils.py
def my_func():
print("version 2")
# ...
# Commit 10, timestamp 20261231235959
# /myscripts/utils.py
def my_func():
print("version 10")
import pyportal
import pyportal.utils.v20251231235959 as U
U.my_func()
# prints "version 2"
import pyportal.utils.v20261231235959 as U2
U2.my_func()
# prints "version 10"
pyportal path
Set it up globally on your computer or locally in a script.
Configure globally in environment variable PYPORTAL_PATH, separated by a semicolon:
PYPORTAL_PATH = "/myscript1;/home/var/mylibrary"
Temporarily set/update portal path in code:
import pyportal
pyportal.path.insert(0, "/search/this/folder/first")
Automatically reload imports
Reload matching modules imported by scripts loaded through PyPortal:
import pyportal
pyportal.auto_reloads(pattern=["autoreview.*"], verbose=True)
import pyportal.autoreview.reactors.fleet.A.file as A
When A is imported again, a cached matching import such as
autoreview.reactors.base is removed from Python's module cache before A imports
it. With verbose=True, PyPortal prints the importing script and reloaded module.
Doc
import pyportal.[path_to_file].[version]
[path_to_file]: can be the script name or path.import pyportal.utils.file : import the FIRST script or package found under the path. Modules are folders that contain __init__.py. utils can be a path pointing to a script or package, like pyportal.utils.network.file, if relative path utils/network exists under one of the paths.
[version]: file or vyyyymmddHHMMSS. The latter is v + the timestamp of the commit.
Import from commit only works if the folder is a git repo. The timestamp of the commit will be shown when you use .file to import a file form a repo, you just need to copy and paste the version, replacing the .file with vYOURVERSION to lock it.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyportal-1.0.3.tar.gz.
File metadata
- Download URL: pyportal-1.0.3.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61d719f1aa606009378b16b447bbdc93b0fcbd0ce74944c8d5f7ef2f30a147d1
|
|
| MD5 |
6f2702689595b949efbd0a5f2915869b
|
|
| BLAKE2b-256 |
b736320f6d60abd47306e9899058843db7b60d3b08832912949f6d5e15063be9
|
File details
Details for the file pyportal-1.0.3-py3-none-any.whl.
File metadata
- Download URL: pyportal-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb6c56e83cbede1f196042be0a2e60efd277ce58c465e29a748dcad32bbe54a8
|
|
| MD5 |
6ba2841454f236c241f92baff44d10d6
|
|
| BLAKE2b-256 |
1c56ad60e99a5d9fa10881db445ee0cb34f1de8f507eaede124f795a62a49e8f
|