Pyforce
Python wrapper for Perforce p4 command-line client.
Features
- Python wrapper for the
p4command using marshal. - Built with Pydantic.
- Fully typed.
- Built for scripting.
Installation
python -m pip install pyforce-p4
Quickstart
import pyforce
connection = pyforce.Connection(host="localhost:1666", user="foo", client="my-client")
# Create a new file in our client
file = "/home/foo/my-client/bar.txt"
fp = open(file, "w")
fp.write("bar")
fp.close()
# Run 'p4 add', open our file for addition to the depot
_, infos = pyforce.add(connection, [file])
print(infos[0])
"""
ActionInfo(
action='add',
client_file='/home/foo/my-client/bar.txt',
depot_file='//my-depot/my-stream/bar.txt',
file_type='text',
work_rev=1
)
"""
# Run 'p4 submit', submitting our local file
pyforce.p4(connection, ["submit", "-d", "Added bar.txt", file])
# Run 'p4 fstat', listing all files in depot
fstats = list(pyforce.fstat(connection, ["//..."]))
print(fstats[0])
"""
FStat(
client_file='/home/foo/my-client/bar.txt',
depot_file='//my-depot/my-stream/bar.txt',
head=HeadInfo(
action=<Action.ADD: 'add'>,
change=2,
revision=1,
file_type='text',
time=datetime.datetime(2024, 3, 29, 13, 56, 57, tzinfo=datetime.timezone.utc),
mod_time=datetime.datetime(2024, 3, 29, 13, 56, 11, tzinfo=datetime.timezone.utc)
),
have_rev=1,
is_mapped=True,
others_open=None
)
"""
Pyforce has functions for the most common p4 commands
but can execute more complexe commands with pyforce.p4.
For example, pyforce doesn't have a function to create a new client workspace,
here is how to create one using pyforce.p4.
import pyforce
connection = pyforce.Connection(port="localhost:1666", user="foo")
# Create client
command = ["client", "-o", "-S", "//my-depot/my-stream", "my-client"]
data = pyforce.p4(connection, command)[0]
data["Root"] = "/home/foo/my-client"
pyforce.p4(connection, ["client", "-i"], stdin=data)
# Get created client
client = pyforce.get_client(connection, "my-client")
print(client)
"""
Client(
name='my-client',
host='5bb1735f73fc',
owner='foo',
root=PosixPath('/home/foo/my-client'),
stream='//my-depot/my-stream',
type=<ClientType.STANDARD: 'writeable'>,
views=[View(left='//my-depot/my-stream/...', right='//my-client/...')]
)
"""
Documentation
See pyforce documentation for more details.
Contributing
For guidance on setting up a development environment and contributing to pyforce, see the Contributing section.
Metadata
Release files for pyforce-p4 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyforce_p4-0.1.1.tar.gz | 22.0 kB | Without provenance | Details for pyforce_p4-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyforce_p4-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pyforce_p4-0.1.1-py3-none-any.whl |
Total release size: 36.7 kB
Release files / pyforce_p4-0.1.1.tar.gz
| Download URL | pyforce_p4-0.1.1.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6156b694285cb16c1d009e03ecb9616aee9393ff373f4ad1960d6ac67ee1d905
|
|
BLAKE2b-256 checksum How to use checksums |
fd1bb7433858a3aee9629ba514f3a81e4b898fcbb7b056eda7f3654744b7d2f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / pyforce_p4-0.1.1-py3-none-any.whl
| Download URL | pyforce_p4-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7efb4799aee7c57f0fef658ddf0fc98a2b067d655c0b0d7c1f758148f51827d1
|
|
BLAKE2b-256 checksum How to use checksums |
db31a5da88aecfb01d19aecae90b1fcda4f05bf3a6dfb30f07654e45a3a0e1ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for pyforce-p4 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.