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 Mar 12, 2024
1 parent 2367569 commit c5128b4
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 128 deletions.
10 changes: 5 additions & 5 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,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 @@ -162,5 +162,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.
25 changes: 13 additions & 12 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
("index", "papis.tex", "papis Documentation", "Alejandro Gallo", "manual"),
("index", "{}.tex".format(project), "{} Documentation".format(project),
papis.__author__, "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -252,13 +253,13 @@
# (source start file, name, description, authors, manual section).
man_pages = [
("configuration", "papis-config-settings", "Papis configuration",
["Alejandro Gallo"], 1),
[papis.__author__], 1),
("library_structure", "papis-library-structure", "Papis library structure",
["Alejandro Gallo"], 1),
[papis.__author__], 1),
("info_file", "papis-info-file", "Papis info.yaml file",
["Alejandro Gallo"], 1),
[papis.__author__], 1),
("database_structure", "papis-database-structure", "Papis database structure",
["Alejandro Gallo"], 1),
[papis.__author__], 1),
]

for entry in os.scandir("commands"):
Expand All @@ -267,7 +268,7 @@
"commands/{}".format(name),
"papis-{}".format(name),
"{} command".format(name),
["Alejandro Gallo"],
[papis.__author__],
1,
))

Expand All @@ -280,8 +281,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
("index", "papis", "papis Documentation",
"Alejandro Gallo", "papis", "One line description of project.",
("index", project, "{} Documentation".format(project),
papis.__author__, project, "One line description of project.",
"Miscellaneous"),
]

Expand All @@ -300,9 +301,9 @@
# -- Options for Epub output {{{1 --------------------------------------------

# Bibliographic Dublin Core info.
epub_title = "papis"
epub_author = "Alejandro Gallo"
epub_publisher = "Alejandro Gallo"
epub_copyright = "2017, Alejandro Gallo"
epub_title = project
epub_author = papis.__author__
epub_publisher = papis.__author__
epub_copyright = copyright
# A list of files that should not be packed into the epub file.
epub_exclude_files = ["search.html"]
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"
142 changes: 62 additions & 80 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,22 +60,22 @@ 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.

Expand Down Expand Up @@ -104,92 +112,66 @@ until an official recipe in the main Guix repositories is published.
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:: python
python3 setup.py install --user
.. code:: sh
If you want to work on the code, you can alternatively hit
python setup.py install
.. code:: python
If you want to install it locally because you don't have administrative
rights on your computer you can simply type

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.

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

Requirements
------------

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 @@ -27,25 +27,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
25 changes: 15 additions & 10 deletions tools/update-pypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@
set -ex

DIST_DIR=dist
DIST_ENV=distenv

# create a virtual environment for the build
rm -rf "$DIST_ENV"
python -m venv --system-site-packages "$DIST_ENV"
source "$DIST_ENV/bin/activate"

rm -rf distenv
virtualenv -p python3 distenv
source ./distenv/bin/activate
pip install .
pip install '.[develop,docs]'
# install build dependencies
python -m pip install --upgrade pip setuptools wheel build twine
python -m pip install .
python -m pip install .[docs]

echo "Updating man pages"
# build package
echo 'Updating man pages'
rm -rf doc/build/
make -C doc man ENV=distenv
make -C doc man ENV="$DIST_ENV"

rm -rf ${DIST_DIR}
rm -rf doc/build/man/_static/
python3 setup.py sdist
python -m build --sdist --skip-dependency-check --no-isolation .

pip install twine
read -p "Do you want to push? (y/N)" -n 1 -r
# upload to pypi
read -p 'Do you want to push to PyPI? (y/N)' -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
twine upload ${DIST_DIR}/*.tar.gz
Expand Down

0 comments on commit c5128b4

Please sign in to comment.