File: installation.md

package info (click to toggle)
primecountpy 0.1.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 184 kB
  • sloc: python: 55; makefile: 18
file content (96 lines) | stat: -rw-r--r-- 2,259 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Installation, testings, documentation 

Assume you have cloned the repository from GitHub, or
installed the package source from an archive, e.g. from [PyPI](https://pypi.org/project/primecountpy/).

## testing:

1) Install primecount C++ library
```
cd /tmp/
git clone https://github.com/kimwalisch/primecount
cd primecount
cmake . -DBUILD_SHARED_LIBS=ON
make -j
sudo make install
sudo ldconfig # linux only
```

Note that `primecount` may be available as a system-wide package on your
system, and then one can install it and avoid building it from source.  E.g. on
Fedora Linux (version 34 or newer) one just has to run 
```
sudo dnf install primecount primecount-devel`
```

2) in this repo, do
```
pip install . --user
```
3)

`python3`
and
```
>>> import primecountpy as primecount
>>> primecount.pi(1000)
```


## Building dependencies without root

set the desired location, e.g.
```
export WDIR=$HOME/tmp
```

install libprimesieve as follows:
```
cd primesieve
cmake -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$WDIR .
make -j  install     # no sudo!
```
install primecount as follows
```
cmake -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON \
       -DCMAKE_INSTALL_PREFIX=$WDIR \
      -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE  -DCMAKE_INSTALL_RPATH=$WDIR \
      -DCMAKE_SKIP_BUILD_RPATH=FALSE  -DBUILD_LIBPRIMESIEVE=OFF  \
      -DCMAKE_FIND_ROOT_PATH=$WDIR/lib/cmake  \
      -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY .
make -j install # no sudo!
```

After this, build/install the package with `pip`
```
pip3 install -e . --prefix=~/.local --global-option=build_ext  --global-option="--library-dirs=$WDIR" --global-option="--rpath=$WDIR"
```

At this point, you can test it with `pytest` (see below for details on `pytest`)

```
pytest --doctest-cython primecountpy -v
```

## Testing with pytest

install pre-requisites:

```
pip3 install pytest pytest-cython
```

Clean up, and build in-place (with system-wide install of primecount).

```
git clean -fdx
pip install -e . 
pytest --doctest-cython primecountpy -v
```

## Documentation

Documentation is built with Sphinx, and automatically (on push to GitHub git repo)
re-built and updates. 

To build documentation locally, run `make html` in `docs/` subdirectory.