Skip to content

Commit

Permalink
fix DEVGUIDE.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Aug 3, 2023
1 parent 173eed6 commit 685aad0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 50 deletions.
25 changes: 12 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,39 +312,38 @@ Process management
>>> p = psutil.Process(7055)
>>> p
psutil.Process(pid=7055, name='python3', status='running', started='09:04:44')
>>> p.pid
7055
>>> p.name()
'python3'
>>> p.exe()
'/usr/bin/python3'
>>> p.cwd()
'/home/giampaolo'
>>> p.cmdline()
['/usr/bin/python', 'main.py']
['/usr/bin/python3', 'main.py']
>>>
>>> p.pid
7055
>>> p.ppid()
7054
>>> p.children(recursive=True)
[psutil.Process(pid=29835, name='python3', status='sleeping', started='11:45:38'),
psutil.Process(pid=29836, name='python3', status='waking', started='11:43:39')]
>>>
>>> p.parent()
psutil.Process(pid=4699, name='bash', status='sleeping', started='09:06:44')
>>> p.parents()
[psutil.Process(pid=4699, name='bash', started='09:06:44'),
psutil.Process(pid=4689, name='gnome-terminal-server', status='sleeping', started='0:06:44'),
psutil.Process(pid=1, name='systemd', status='sleeping', started='05:56:55')]
>>> p.children(recursive=True)
[psutil.Process(pid=29835, name='python3', status='sleeping', started='11:45:38'),
psutil.Process(pid=29836, name='python3', status='waking', started='11:43:39')]
>>>
>>> p.status()
'running'
>>> p.username()
'giampaolo'
>>> p.create_time()
1267551141.5019531
>>> p.terminal()
'/dev/pts/0'
>>>
>>> p.username()
'giampaolo'
>>> p.uids()
puids(real=1000, effective=1000, saved=1000)
>>> p.gids()
Expand Down Expand Up @@ -384,14 +383,14 @@ Process management
[pconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED'),
pconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status='CLOSING')]
>>>
>>> p.num_threads()
4
>>> p.num_fds()
8
>>> p.threads()
[pthread(id=5234, user_time=22.5, system_time=9.2891),
pthread(id=5237, user_time=0.0707, system_time=1.1)]
>>>
>>> p.num_threads()
4
>>> p.num_fds()
8
>>> p.num_ctx_switches()
pctxsw(voluntary=78, involuntary=19)
>>>
Expand Down
69 changes: 32 additions & 37 deletions docs/DEVGUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Build, setup and running tests
psutil makes extensive use of C extension modules, meaning a C compiler is
required, see
`install instructions <https://github.com/giampaolo/psutil/blob/master/INSTALL.rst>`__.

Once you have a compiler installed:
Once you have a compiler installed run:

.. code-block:: bash
Expand All @@ -28,22 +27,30 @@ Once you have a compiler installed:
make test-parallel # faster
make test-memleaks
make test-coverage
make lint # Python (PEP8) and C linters
make lint-all # Run Python and C linter
make fix-all # Fix linting erors
make uninstall
make help
- if you're working on a new feature and you wish to compile & test it "on the
- To run a specific unit test:

.. code-block:: bash
make test ARGS=psutil.tests.test_system.TestDiskAPIs
- If you're working on a new feature and you wish to compile & test it "on the
fly" from a test script, this is a quick & dirty way to do it:

.. code-block:: bash
make test TSCRIPT=test_script.py # on UNIX
make test test_script.py # on Windows
- do not use ``sudo``. ``make install`` installs psutil as a limited user in
- Do not use ``sudo``. ``make install`` installs psutil as a limited user in
"edit" mode, meaning you can edit psutil code on the fly while you develop.

- if you want to target a specific Python version:
- If you want to target a specific Python version:

.. code-block:: bash
Expand All @@ -53,7 +60,7 @@ Once you have a compiler installed:
Coding style
------------

- python code strictly follows `PEP-8`_ styling guides and this is enforced by
- Oython code strictly follows `PEP-8`_ styling guides and this is enforced by
a commit GIT hook installed via ``make install-git-hooks`` which will reject
commits if code is not PEP-8 complieant.
- C code should follow `PEP-7`_ styling guides.
Expand All @@ -74,63 +81,51 @@ Adding a new API

Typically, this is what you do:

- define the new API in `psutil/__init__.py`_.
- write the platform specific implementation in ``psutil/_ps{platform}.py``
- Define the new API in `psutil/__init__.py`_.
- Write the platform specific implementation in ``psutil/_ps{platform}.py``
(e.g. `psutil/_pslinux.py`_).
- if the change requires C code, write the C implementation in
- If the change requires C code, write the C implementation in
``psutil/_psutil_{platform}.c`` (e.g. `psutil/_psutil_linux.c`_).
- write a generic test in `psutil/tests/test_system.py`_ or
- Write a generic test in `psutil/tests/test_system.py`_ or
`psutil/tests/test_process.py`_.
- if possible, write a platform-specific test in
- If possible, write a platform-specific test in
``psutil/tests/test_{platform}.py`` (e.g. `psutil/tests/test_linux.py`_).
This usually means testing the return value of the new API against
a system CLI tool.
- update the doc in ``doc/index.py``.
- update `HISTORY.rst`_ and `CREDITS`_ files.
- make a pull request.
- Update the doc in ``docs/index.py``.
- Update `HISTORY.rst`_ and `CREDITS`_ files.
- Make a pull request.

Make a pull request
-------------------

- fork psutil (go to https://github.com/giampaolo/psutil and click on "fork")
- git clone the fork locally: ``git clone [email protected]:YOUR-USERNAME/psutil.git``
- create a branch:``git checkout -b new-feature``
- commit your changes: ``git commit -am 'add some feature'``
- push the branch: ``git push origin new-feature``
- create a new PR via the GitHub web interface and sign-off your work (see
- Fork psutil (go to https://github.com/giampaolo/psutil and click on "fork")
- Git clone the fork locally: ``git clone [email protected]:YOUR-USERNAME/psutil.git``
- Create a branch:``git checkout -b new-feature``
- Commit your changes: ``git commit -am 'add some feature'``
- Push the branch: ``git push origin new-feature``
- Create a new PR via the GitHub web interface and sign-off your work (see
`CONTRIBUTING.md`_ guidelines)

Continuous integration
----------------------

Unit tests are automatically run on every ``git push`` on **Linux**, **macOS**,
**Windows** and **FreeBSD** by using:

- `Github Actions`_ (Linux, macOS, Windows)
- `Appveyor`_ (Windows)

.. image:: https://img.shields.io/github/workflow/status/giampaolo/psutil/CI?label=Linux%2C%20macOS%2C%20FreeBSD
:target: https://github.com/giampaolo/psutil/actions?query=workflow%3ACI

.. image:: https://img.shields.io/appveyor/ci/giampaolo/psutil/master.svg?maxAge=3600&label=Windows
:target: https://ci.appveyor.com/project/giampaolo/psutil

OpenBSD, NetBSD, AIX and Solaris does not have continuous test integration.
**Windows**, **FreeBSD**, **NetBSD**, **OpenBSD**.
AIX and Solaris does not have continuous test integration.

Documentation
-------------

- doc source code is written in a single file: `/docs/index.rst`_.
- doc source code is written in a single file: ``docs/index.rst``.
- doc can be built with ``make setup-dev-env; cd docs; make html``.
- public doc is hosted at https://psutil.readthedocs.io
- public doc is hosted at https://psutil.readthedocs.io.

.. _`appveyor.yml`: https://github.com/giampaolo/psutil/blob/master/appveyor.yml
.. _`Appveyor`: https://ci.appveyor.com/project/giampaolo/psuti
.. _`coveralls.io`: https://coveralls.io/github/giampaolo/psuti
.. _`CREDITS`: https://github.com/giampaolo/psutil/blob/master/CREDITS
.. _`CONTRIBUTING.md`: https://github.com/giampaolo/psutil/blob/master/CONTRIBUTING.md
.. _`doc/index.rst`: https://github.com/giampaolo/psutil/blob/master/doc/index.rst
.. _`Github Actions`: https://github.com/giampaolo/psutil/actions
.. _`HISTORY.rst`: https://github.com/giampaolo/psutil/blob/master/HISTORY.rst
.. _`make.bat`: https://github.com/giampaolo/psutil/blob/master/make.bat
.. _`Makefile`: https://github.com/giampaolo/psutil/blob/master/Makefile
Expand Down

0 comments on commit 685aad0

Please sign in to comment.