Skip to content

Commit 3b8c95c

Browse files
committed
Adding precommit hook, updating READMEN.rst and index.rst docs
1 parent b0ab1e7 commit 3b8c95c

5 files changed

Lines changed: 328 additions & 182 deletions

File tree

CHANGELOG.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog for autopypath
33
========================
44

5-
0.9.0-beta.1 (2026-01-19)
5+
0.9.1 (2026-01-22)
66
------------------------
7-
- Initial beta release for version 0.9.0 to PyPI
7+
- Added pre-commit Git hooks for code quality checks and formatting on commit.
8+
- Updated index.rst and README.rst documentation.
9+
- Bumped version to 0.9.1.
10+
11+
0.9.0 (2026-01-21)
12+
------------------------
13+
- Initial release for version 0.9.0 to PyPI

README.rst

Lines changed: 105 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ autopypath
33

44
.. Badges
55
6-
.. image:: https://github.com/JerilynFranz/python-autopypath/actions/workflows/build.yml/badge.svg
6+
.. image:: https://github.com/JerilynFranz/python-autopypath/actions/workflows/build.yml/badge.svg?branch=main
77
:target: https://github.com/JerilynFranz/python-autopypath/actions/workflows/build.yml
88
:alt: Build Status
99

10-
.. image:: https://coveralls.io/repos/github/JerilynFranz/python-autopypath/badge.svg
10+
.. image:: https://coveralls.io/repos/github/JerilynFranz/python-autopypath/badge.svg?branch=main
1111
:target: https://coveralls.io/github/JerilynFranz/python-autopypath
1212
:alt: Coverage Status
1313

@@ -31,127 +31,139 @@ autopypath
3131
:target: https://github.com/astral-sh/ruff
3232
:alt: Ruff
3333

34-
Table of Contents
35-
-----------------
34+
What is autopypath?
35+
-------------------
3636

37-
- `Usage <https://python-autopypath.readthedocs.io/en/latest/usage.html>`_
38-
- `Configuration <https://python-autopypath.readthedocs.io/en/latest/configuration.html>`_
39-
- `Contributing <https://python-autopypath.readthedocs.io/en/latest/contributing.html>`_
40-
- `Code of Conduct <https://python-autopypath.readthedocs.io/en/latest/code_of_conduct.html>`_
41-
- `Index <https://python-autopypath.readthedocs.io/en/latest/genindex.html>`_
42-
- `Module Index <https://python-autopypath.readthedocs.io/en/latest/py-modindex.html>`_
37+
**autopypath** is a library that simplifies the management of the Python module
38+
search path (`sys.path`) for testing and development environments.
4339

44-
What is autopypath?
45-
--------------------
46-
47-
autopypath is a small library that simplifies the management of the Python module search path (`sys.path` )
48-
for testing and development environments. It automatically finds and adds relevant directories to sys.path
49-
based on configuration files such as `pyproject.toml <https://packaging.python.org/en/latest/guides/writing-pyproject-toml/>`_
50-
in the project's root directory, works
51-
with popular testing frameworks like `pytest <https://docs.pytest.org/en/stable/>`_ and
52-
`unittest <https://docs.python.org/3/library/unittest.html>`_,
53-
and supports standard project structures out of the box as well as custom configurations.
54-
55-
It does *not* use `PYTHONPATH`` from `.env` files because there is no way to reliably parse it
56-
in cross-platform environments and they are not designed for this purpose.
57-
58-
It is not a replacement for `virtual environments <https://docs.python.org/3/library/venv.html>`_ but
59-
rather a tool to dynamically adjust sys.path in tests or scripts on load, making it easier
60-
to work with possibly broken build or development setups where the testing framework cannot be run
61-
because it attempts to import modules that are not yet installed or where other tests cannot be
62-
loaded due to breakage from ongoing development.
63-
64-
It works by detecting the root of the project repository using common version control system markers
65-
(such as `.git <https://git-scm.com/>`_, `.hg <https://www.mercurial-scm.org/>`_, or
66-
`.svn <https://subversion.apache.org/>`_ directories, or a
67-
`pyproject.toml <https://packaging.python.org/en/latest/guides/writing-pyproject-toml/>`_ file,
68-
or a custom configuration file (`autopypath.toml`),
69-
and then adding specified subdirectories (such as `src/`, `src/tests/`, `tests/`, `lib/` or
70-
others defined in configuration files) to `sys.path` at runtime. The detection of the repository root
71-
and the addition of paths to :`sys.path` happens automatically when `autopypath` is imported in a test script.
72-
It is fully customizable via configuration files or parameters.
73-
74-
This allows test scripts
75-
to be executed directly from the command line or an IDE without requiring the entire project to be
76-
built or installed first as long as its dependencies are met.
77-
78-
It is designed to be lightweight and easy to integrate into existing testing setups, providing a
79-
seamless experience for developers working on Python projects and to "*just work*"
80-
without manually worrying about the intricacies of path resolution and IDE or test runner configurations
81-
except for the initial setup.
40+
It automatically detects your project root (via `.git`, `pyproject.toml`, etc.)
41+
and intelligently adds source directories to `sys.path` at runtime.
42+
43+
The Problem it Solves
44+
~~~~~~~~~~~~~~~~~~~~~
45+
46+
In active development, **builds are often broken.**
47+
Standard test runners (like `pytest` or `tox`) often refuse to start if they
48+
cannot import the entire package, or if the package hasn't been re-installed
49+
into the virtual environment after a structural change.
50+
51+
**autopypath allows you to run individual tests or scripts in isolation, even if:**
52+
53+
- The project build is currently broken.
54+
- The package is not installed in the current environment.
55+
- Other parts of the test suite are failing due to ongoing refactoring.
56+
57+
It is not a replacement for `virtual environments <https://docs.python.org/3/library/venv.html>`_,
58+
but a resilience tool. It dynamically fixes "Module Not Found" errors on load, allowing you to
59+
debug a specific file without needing the entire project ecosystem to be in a perfect,
60+
deployable state.
61+
62+
Documentation
63+
-------------
64+
65+
- `Usage <https://python-autopypath.readthedocs.io/en/latest/usage.html>`_
66+
- `Configuration <https://python-autopypath.readthedocs.io/en/latest/configuration.html>`_
67+
- `Contributing <https://python-autopypath.readthedocs.io/en/latest/contributing.html>`_
68+
- `Code of Conduct <https://python-autopypath.readthedocs.io/en/latest/code_of_conduct.html>`_
69+
70+
Installation
71+
------------
72+
73+
Installing from PyPI
74+
~~~~~~~~~~~~~~~~~~~~
75+
76+
.. code-block:: shell
77+
78+
pip install autopypath
79+
80+
Installing from Source
81+
~~~~~~~~~~~~~~~~~~~~~~
82+
83+
.. code-block:: shell
84+
85+
git clone https://github.com/JerilynFranz/python-autopypath.git
86+
cd python-autopypath
87+
pip install .
88+
89+
Development Installation
90+
~~~~~~~~~~~~~~~~~~~~~~~~
91+
92+
For development purposes, you can install `autopypath` in editable mode. To make this easier, a `bootstrap.py` script is provided.
93+
94+
.. code-block:: shell
95+
96+
git clone https://github.com/JerilynFranz/python-autopypath.git
97+
cd python-autopypath
98+
python3 bootstrap.py
99+
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
100+
101+
This script will:
102+
1. Set up the development environment (`uv` sync).
103+
2. Install `autopypath` in editable mode.
104+
3. Install Git hooks for pre-commit checks.
105+
4. Install development tools like `tox`, `sphinx`, and `ruff`.
82106

83107
Usage
84108
-----
85109

86-
This is an example of how to use autopypath in your test scripts
87-
so that a single test can be run directly from the command line or an
88-
IDE without requiring the entire test suite to be executed even
89-
if the project is not fully built or installed as long as its
90-
dependencies are met .
110+
Simply import `autopypath` at the top of your test script. It will
111+
automatically detect the project root and adjust `sys.path` accordingly
112+
(by default adding `src`, `lib`, `src/tests`, and `tests` directories if they exist).
91113

92-
Even if your test script is located deep in a repo test subdirectory, you can still use autopypath
93-
to ensure that the necessary paths are added to `sys.path` without any manual intervention.
114+
It does not add '.' to `sys.path` by default to avoid conflicts with subdirectories
115+
that are NOT intended to be packages, but if you want to include the repo root
116+
directory, you can configure it via `pyproject.toml` or `autopypath.toml`.
94117

95-
Here is an example of how a test script named `my_test_script.py` might look
96-
after integrating autopypath (and assuming the project structure uses a pyproject.toml
97-
or has configured an autopypath.toml file if the project structure is non-standard):
118+
Here is an example `tests/my_test_script.py`:
98119

99120
.. code-block:: python
100121
101-
import autopypath
122+
import autopypath # <--- This line magics the sys.path
102123
import pytest
103124
125+
# Now these imports work without installing the package
104126
import mypackage.my_module
105-
from mypackage.subpackage import my_other_module
106-
107-
### my tests
108-
...
109127
110128
if __name__ == '__main__':
111129
pytest.main([__file__])
112130
113-
It can then be run directly from the CLI or from your IDE *without having to install
114-
the package first*, run the full test suite, or manually mangling `sys.path`, or
115-
`PYTHONPATH <https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH>`_ to
116-
make it work.
131+
You can now run this file directly:
117132

118133
.. code-block:: shell
119134
120-
python my_test_script.py
121-
122-
.. note::
123-
124-
While autopypath is primarily designed to be used in test scripts,
125-
it can also be utilized in other Python scripts where dynamic
126-
adjustment of `sys.path` is needed based on project configuration.
127-
128-
It automatically resolves the paths based on the configuration files and adds
129-
them to `sys.path` before running the tests.
135+
python tests/my_test_script.py
130136
131-
Configuring
132-
-----------
137+
Configuration
138+
-------------
133139

134-
If you already use `pyproject.toml <https://packaging.python.org/en/latest/guides/writing-pyproject-toml/>`_ to define
135-
your project structure, autopypath has first-class support for it and will automatically
136-
detect it and use a ``[tool.autopypath]`` section if present to configure itself.
140+
autopypath automatically detects `pyproject.toml`. You can configure it
141+
by adding a ``[tool.autopypath]`` section.
137142

138-
Example:
143+
**Example `pyproject.toml`:**
139144

140-
.. code-block:: toml
145+
.. code-block:: toml
141146
142147
[tool.autopypath]
143-
paths = ['lib', 'src/tests', '.']
148+
paths = ["lib", "src/tests", ".", "src"]
144149
145-
If you do not use `pyproject.toml <https://packaging.python.org/en/latest/guides/writing-pyproject-toml/>`_ or
146-
want to have a separate configuration file, you can create an `autopypath.toml` file in the root of your project
147-
or in any parent directory containing your scripts to configure autopypath.
150+
If you do not use `pyproject.toml`, you can create an `autopypath.toml` file
151+
either in your root directory or in subdirectories such as `src` or `tests`
152+
and it will be detected automatically. This can be useful for monorepos or
153+
multi-package repositories and allows customization of `sys.path` per sub-project
154+
or for detection of the project root in non-standard layouts.
148155

149-
It is cross-platform and works reliably on Windows, macOS, and Linux.
156+
**Example `autopypath.toml`:**
150157

151-
Example:
152-
153-
.. code-block:: toml
158+
.. code-block:: toml
154159
155160
[tool.autopypath]
161+
paths = ["src", "src/lib", "tests"]
156162
repo_markers = {".git" = "dir"}
157-
paths = ["src", "src/lib", "tests"]
163+
164+
This file can be placed in the root of your project or in any directory
165+
that is a parent of your test scripts (but still inside the repo).
166+
167+
You can use it to customize which directories are added to `sys.path`, or to
168+
specify custom repository markers for detecting the project root as well
169+
as other settings affecting path resolution behavior.

0 commit comments

Comments
 (0)