Skip to content

Commit

Permalink
docs: update setup.py docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Jul 22, 2023
1 parent 21f07fb commit f763d9a
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 160 deletions.
10 changes: 5 additions & 5 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ see the arXiv importers in `arxiv.py`. To add a new importer
- (Optional) Instead of the `fetch` method, you can also implement the `fetch_data`
and / or `fetch_files` methods separately.

The importer is then registered with `papis` by adding it to `setup.py`. In the
`entry_points` argument under `"papis.importer"` add
The importer is then registered with `papis` by adding it to `pyproject.toml`.
In the `project.entry_points."papis.importer"` section add
```
myimporter=papis.myservice:Importer
myimporter = "papis.myservice:Importer"
```
or see the existing examples.

Expand All @@ -137,5 +137,5 @@ from a remote location. They can be implemented in a very similar way:
- (Optional) Implement the `Downloader.get_document_url` method to return an
URL from which a document (e.g. PDF file) can be downloaded.

The downloader can then be added to the `"papis.downloader"` key in `setup.py`,
similarly to an importer.
The downloader can then be added to the `project.entry-points."papis.downloader"`
section, similarly to an importer.
13 changes: 6 additions & 7 deletions doc/source/hooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ hook like
2 Writing hooks as a developer
------------------------------

To add a hook as a plugin writer or a developer
you can just add the ``entry_point`` to the ``setup.py``
file, for instance for the ``on_edit_done`` hook you would write
To add a hook as a plugin writer or a developer you can just add the *entrypoint*
to the ``pyproject.toml`` file. For instance for the ``on_edit_done`` hook you
would write

.. code:: python
.. code:: toml
"papis.hook.on_edit_done" : [
"my_hook_name=path.to.my:function,
]
[project.entry-points."papis.hook.on_edit_done"]
my_hook_name = "path.module:function"
143 changes: 62 additions & 81 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,48 @@ Installation
Using pip
---------

The easiest way of installing papis is using the ``PyPi`` repositories and
the package manager ``pip3``, just open a terminal and type in
The easiest way of installing papis is using the ``PyPI`` repositories and
the ``pip`` package manager. Open a terminal and type in

::
.. code:: sh
pip3 install papis
pip install papis
If you are on GNU/Linux like systems you might need to type ``sudo``
If you are on GNU/Linux-like systems you might need to type ``sudo`` to install
papis globally like

::
.. code:: sh
sudo pip3 install papis
sudo pip install papis
or if you prefer installing it locally then simply type
If you prefer installing it locally then simply type

::
.. code:: sh
pip3 install --user papis
pip install --user papis
You can also **update** papis with ``pip``

::
.. code:: sh
pip3 install --upgrade papis
pip install --upgrade papis
Archlinux
---------
Arch Linux
----------

- The package `papis` is also found in the archlinux repositories
- The ``papis`` package is found in the Arch Linux AUR repository
`here <https://aur.archlinux.org/packages/papis/>`__.
- If you want to use the git version of ``papis`` instead
refer to `papis-git <https://aur.archlinux.org/packages/papis-git/>`__ package.
Thanks `Julian <https://julianhauser.com/>`__!.
Thanks to `Joshua <https://jpellis.me/>`__ for maintaining this packages!.
- If you want to use the git version of ``papis`` instead, you can try
the `papis-git <https://aur.archlinux.org/packages/papis-git/>`__ package.
Thanks to `Julian <https://julianhauser.com/>`__ for maintaining this packages!.

You can install either one with your favorite AUR helper, e.g.

.. code:: sh
yay -S papis
NixOS
-----
Expand All @@ -52,115 +60,88 @@ If you are running `NixOS <https://nixos.org/>`__ or you have the
`nix <https://github.com/NixOS/nix>`__ package manager installed, you can install
papis by running:

::
.. code:: sh
nix-env -i papis
nix-env -i papis
If you like papis, just clone the repository
For the development version, just clone the repository

::
.. code:: sh
git clone git@github.com:papis/papis.git
cd papis
git clone git@github.com:papis/papis.git
cd papis
and start hacking it with:
and start hacking it with

::
.. code:: sh
nix-shell --expr 'with import <nixpkgs> {}; papis.overrideDerivation (drv: { src = ./.; })'
nix-shell --expr 'with import <nixpkgs> {}; papis.overrideDerivation (drv: { src = ./.; })'
This command will provide you a shell with all the dependencies required.


From source
-----------

First of all you have to get the code, open a terminal and hit
To install papis from source, you can clone the repository using

::
.. code:: sh
git clone https://github.com/papis/papis.git
git clone https://github.com/papis/papis.git
or download the
`zip file <https://github.com/papis/papis/archive/refs/heads/main.zip>`__.

Go inside of the ``papis`` source folder and you can install it in a standard
fashion. The general command that you have to use is the ``setup.py`` script:

Go inside of the ``papis`` source folder and you can install it with ``python3``.

The general command that you have to hit is by using the ``setup.py`` script:

.. code:: python
python3 setup.py install
Again, if you want to install it locally because you don't have administrative
rights on your computer you simply type
.. code:: sh
.. code:: python
python setup.py install
python3 setup.py install --user
If you want to install it locally because you don't have administrative
rights on your computer you can simply type

If you want to work on the code, you can alternatively hit

.. code:: python
python3 setup.py develop --user
.. code:: sh
python setup.py install --user
.. warning::

If you install the package locally, the program ``papis`` will be installed
by default into your ``~/.local/bin`` directory, so that you will have to
set your ``PATH`` accordingly.

One way of doing this in ``bash`` shells (``Linux`` and the like, also
``Ubuntu`` on Windows or ``cygwin``) is by adding the following line to your
``~/.bashrc`` file
::

export PATH=$PATH:$HOME/.local/bin

If you install the package locally, the program ``papis`` will be installed
by default into your ``~/.local/bin`` directory, so that you will have to
set your ``PATH`` accordingly.

Requirements
------------
One way of doing this in Bash shells (Linux, Ubuntu on Windows or Cygwin) is
by adding the following line to your ``~/.bashrc`` file::

Papis needs the following packages that are sometimes not installed with the
system ``python3`` distribution

::

python3-setuptools

However if you have a general enough python distribution they should be
installed.
.. code:: sh
export PATH=$PATH:$HOME/.local/bin
Running tests
-------------

In order to run the necessary tests to submit a pull request,
make sure that the following commands pass

In order to run the necessary tests to submit a pull request, make sure that
the following commands pass

::
.. code:: sh
python -m pytest papis/ tests/ --cov=papis
python -m mypy papis
python -m flake8 papis
python -m pytest papis/ tests/ --cov=papis
python -m mypy papis
python -m flake8 papis
for it, make sure that you have ``pytest``, ``flake8`` and ``mypy``
installed.

You can make sure that you have everything you need to run the tests
by doing in the root directory

::
.. code:: sh
pip install .[develop]
pip install .[develop]
this command installs the necessary dependencies for developing
and running the tests. Look inside of the file ``setup.py`` for
and running the tests. Look inside of the ``pyproject.toml`` file for
further information.

You can also look at the folder ``tools`` for scripts used in the
Expand Down
20 changes: 6 additions & 14 deletions doc/source/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,17 @@ For example, the ``yaml`` exporter in ``papis.yaml`` is defined as
allow_unicode=True)
return str(string)
and declared in ``setup.py`` as
and declared in ``pyproject.toml`` as

.. code:: python
.. code:: toml
setup(
...
entry_points={
"papis.exporter": [
...
"yaml=papis.yaml:exporter",
...
],
...
)
[project.entry-points."papis.exporter"]
yaml = "papis.yaml:exporter"
where ``yaml`` is the name of the entrypoint, ``papis.yaml`` is the module
in which it is located and ``exporter`` is the callable used to invoke the
plugin, i.e. the format is ``<name>=<module>:<callable>``. The exporter can be
retrieved by name using
plugin, i.e. the format is ``<name> = "<module>:<callable>"``. The exporter can
be retrieved by name using

.. code:: python
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ develop = [
"types-requests",
"types-tqdm",
]
docs = [
"sphinx>=4",
"sphinx-click",
"sphinx_rtd_theme",
]
optional = [
"Whoosh>=2.7.4",
]
Expand Down Expand Up @@ -214,6 +219,14 @@ platforms = ["linux", "osx", "win32"]
[tool.setuptools.package-data]
papis = ["py.typed"]

[tool.setuptools.data-files]
"share/applications" = ["contrib/papis.desktop"]
"share/bash-completion/completions" = ["scripts/shell_completion/click/bash/papis.bash"]
"share/doc/papis" = ["README.rst", "CHANGELOG.md", "AUTHORS", "LICENSE"]
"share/fish/vendor_completions.d" = ["scripts/shell_completion/click/fish/papis.fish"]
# "share/man/man1" = [""]
"share/zsh/site-functions" = ["scripts/shell_completion/click/zsh/_papis"]

[tool.pytest.ini_options]
addopts = [
"--doctest-modules",
Expand Down
44 changes: 1 addition & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,3 @@
#
# you can install this to a local test virtualenv like so:
# virtualenv venv
# ./venv/bin/pip install --editable .
# ./venv/bin/pip install --editable .[dev] # with dev requirements, too

import os
import sys
import glob

from setuptools import setup

if sys.platform == "win32":
data_files = []
else:
# NOTE: see the documentation for 'bash-completion' at
# https://github.com/scop/bash-completion/blob/master/README.md#faq
bash_completion_dir = os.environ.get(
"PAPIS_BASH_COMPLETION_DIR", "share/bash-completion/completions")
# NOTE: see the documentation for 'fish' at
# https://fishshell.com/docs/current/completions.html#where-to-put-completions
fish_completion_dir = os.environ.get(
"PAPIS_FISH_COMPLETION_DIR", "share/fish/vendor_completions.d")
# NOTE: 'site-functions' is included by default since zsh 5.0.7, see
# https://zsh.sourceforge.io/releases.html
zsh_completion_dir = os.environ.get(
"PAPIS_ZSH_COMPLETION_DIR", "share/zsh/site-functions")

data_files = [
("share/doc/papis", [
"README.rst",
"CHANGELOG.md",
"AUTHORS",
"LICENSE",
]),

(bash_completion_dir, ["scripts/shell_completion/click/bash/papis.bash"]),
(fish_completion_dir, ["scripts/shell_completion/click/fish/papis.fish"]),
(zsh_completion_dir, ["scripts/shell_completion/click/zsh/_papis"]),

("share/man/man1", glob.glob("doc/build/man/*")),
("share/applications", ["contrib/papis.desktop"]),
]

setup(data_files=data_files)
setup()

0 comments on commit f763d9a

Please sign in to comment.