Skip to content

Commit b3d9e00

Browse files
codexByron
authored andcommitted
Merge smmap into the GitPython repository
git-subtree-dir: smmap git-subtree-mainline: faf3c09 git-subtree-split: 8ce61ad
2 parents faf3c09 + 8ce61ad commit b3d9e00

32 files changed

Lines changed: 2626 additions & 0 deletions

smmap/.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
source = smmap
3+
4+
; to make nosetests happy
5+
[report]
6+
omit =
7+
*/yaml*
8+
*/tests/*
9+
*/python?.?/*
10+
*/site-packages/nose/*

smmap/.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on: [push, pull_request, workflow_dispatch]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.13t"]
16+
include:
17+
- experimental: false
18+
- os: ubuntu-latest
19+
- python-version: "3.7"
20+
os: ubuntu-22.04
21+
22+
runs-on: ${{ matrix.os }}
23+
24+
continue-on-error: ${{ matrix.experimental }}
25+
26+
steps:
27+
- uses: actions/checkout@v7
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v6
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
allow-prereleases: ${{ matrix.experimental }}
33+
- name: Install project
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install .
37+
- name: Lint with flake8
38+
run: |
39+
pip install flake8
40+
# stop the build if there are Python syntax errors or undefined names
41+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
42+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
43+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
44+
- name: Test
45+
run: |
46+
pip install pytest
47+
ulimit -n 48
48+
ulimit -n
49+
pytest -v

smmap/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.pyc
2+
build/
3+
.coverage
4+
coverage
5+
cover/
6+
dist/
7+
MANIFEST
8+
.tox
9+
*.egg-info
10+
.noseids
11+
*.sublime-workspace
12+
/env/

smmap/LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (C) 2010, 2011 Sebastian Thiel and contributors
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions
6+
are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
15+
* Neither the name of the async project nor the names of
16+
its contributors may be used to endorse or promote products derived
17+
from this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+

smmap/MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Include the license file
2+
include LICENSE

smmap/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: all clean release force_release
2+
3+
all:
4+
@grep -Ee '^[a-z].*:' Makefile | cut -d: -f1 | grep -vF all
5+
6+
clean:
7+
rm -rf build/ dist/ .eggs/ .tox/
8+
9+
force_release: clean
10+
./build-release.sh
11+
twine upload dist/*
12+
git push --tags origin master

smmap/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## Motivation
2+
3+
When reading from many possibly large files in a fashion similar to random access, it is usually the fastest and most efficient to use memory maps.
4+
5+
Although memory maps have many advantages, they represent a very limited system resource as every map uses one file descriptor, whose amount is limited per process. On 32 bit systems, the amount of memory you can have mapped at a time is naturally limited to theoretical 4GB of memory, which may not be enough for some applications.
6+
7+
8+
## Limitations
9+
10+
* **System resources (file-handles) are likely to be leaked!** This is due to the library authors reliance on a deterministic `__del__()` destructor.
11+
* The memory access is read-only by design.
12+
13+
14+
## Overview
15+
16+
![Python package](https://github.com/gitpython-developers/smmap/workflows/Python%20package/badge.svg)
17+
18+
Smmap wraps an interface around mmap and tracks the mapped files as well as the amount of clients who use it. If the system runs out of resources, or if a memory limit is reached, it will automatically unload unused maps to allow continued operation.
19+
20+
To allow processing large files even on 32 bit systems, it allows only portions of the file to be mapped. Once the user reads beyond the mapped region, smmap will automatically map the next required region, unloading unused regions using a LRU algorithm.
21+
22+
Although the library can be used most efficiently with its native interface, a Buffer implementation is provided to hide these details behind a simple string-like interface.
23+
24+
For performance critical 64 bit applications, a simplified version of memory mapping is provided which always maps the whole file, but still provides the benefit of unloading unused mappings on demand.
25+
26+
27+
28+
## Prerequisites
29+
30+
* Python 3.7+
31+
* OSX, Windows or Linux
32+
33+
The package was tested on all of the previously mentioned configurations.
34+
35+
## Installing smmap
36+
37+
[![Documentation Status](https://readthedocs.org/projects/smmap/badge/?version=latest)](https://readthedocs.org/projects/smmap/?badge=latest)
38+
39+
Its easiest to install smmap using the [pip](http://www.pip-installer.org/en/latest) program:
40+
41+
```bash
42+
$ pip install smmap
43+
```
44+
45+
As the command will install smmap in your respective python distribution, you will most likely need root permissions to authorize the required changes.
46+
47+
If you have downloaded the source archive, the package can be installed by running the `setup.py` script:
48+
49+
```bash
50+
$ python setup.py install
51+
```
52+
53+
It is advised to have a look at the **Usage Guide** for a brief introduction on the different database implementations.
54+
55+
56+
57+
## Homepage and Links
58+
59+
The project is home on github at https://github.com/gitpython-developers/smmap .
60+
61+
The latest source can be cloned from github as well:
62+
63+
* git://github.com/gitpython-developers/smmap.git
64+
65+
66+
For support, please use the git-python mailing list:
67+
68+
* http://groups.google.com/group/git-python
69+
70+
71+
Issues can be filed on github:
72+
73+
* https://github.com/gitpython-developers/smmap/issues
74+
75+
A link to the pypi page related to this repository:
76+
77+
* https://pypi.org/project/smmap/
78+
79+
80+
## License Information
81+
82+
*smmap* is licensed under the New BSD License.
83+

smmap/SECURITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Security Policy
2+
3+
See [GitPython](https://github.com/gitpython-developers/GitPython/blob/main/SECURITY.md). Vulnerabilities found in `smmap` can be reported there.

smmap/build-release.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#
3+
# This script builds a release. If run in a venv, it auto-installs its tools.
4+
# You may want to run "make release" instead of running this script directly.
5+
6+
set -eEu
7+
8+
function release_with() {
9+
$1 -m build --sdist --wheel
10+
}
11+
12+
if test -n "${VIRTUAL_ENV:-}"; then
13+
deps=(build twine) # Install twine along with build, as we need it later.
14+
echo "Virtual environment detected. Adding packages: ${deps[*]}"
15+
pip install --quiet --upgrade "${deps[@]}"
16+
echo 'Starting the build.'
17+
release_with python
18+
else
19+
function suggest_venv() {
20+
venv_cmd='python -m venv env && source env/bin/activate'
21+
printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd"
22+
}
23+
trap suggest_venv ERR # This keeps the original exit (error) code.
24+
echo 'Starting the build.'
25+
release_with python3 # Outside a venv, use python3.
26+
fi

0 commit comments

Comments
 (0)