Skip to main content

A package to author, build, and deploy PreTeXt projects.

Project description

PreTeXt-CLI

A package for authoring and building PreTeXt documents.

Documentation and examples for authors/publishers

Most documentation for PreTeXt authors and publishers is available at:

Authors and publishers may also find the examples catalog useful as well:

We have a few notes below (TODO: publish these in the Guide).

Installation

Installing Python

PreTeXt-CLI requires the Python version specified in pyproject.toml.

To check your version, type this into your terminal or command prompt:

python -V

If your version is 2.x, try this instead (and if so, either replace all future references to python in these instructions with python3).

python3 -V

If you don't have a compatible Python available, try one of these:

Installing PreTeXt-CLI

Once you've confirmed that you're using a valid version of Python, just run (replacing python with python3 if necessary):

python -m pip install --user pretextbook

(It's also possible you may get an error like error: invalid command 'bdist_wheel' — good news, you can ignore it!)

After installation, try to run:

pretext --help

If that works, great! Otherwise, it likely means that Python packages aren't available on your “PATH”. In that case, replace all pretext commands with python -m pretext instead:

python -m pretext --help

Either way, you're now ready to use the CLI, the --help option will explain how to use all the different subcommands like pretext new and pretext build.

Upgrading PreTeXt-CLI

If you have an existing installation and you want to upgrade to a more recent version, you can run:

python -m pip install --upgrade pretextbook

Custom XSL

Custom XSL is not encouraged for most authors, but (for example) developers working bleeding-edge XSL from core PreTeXt may want to call XSL different from that which is shipped with a fixed version of the CLI. This may be accomplished by adding an <xsl/> element to your target with a relative (to project.ptx) or absolute path to the desired XSL. (Note: this XSL must only import other XSL files in the same directory or within subdirectories.)

For example:

<target name="html">
  <format>html</format>
  <source>source/main.ptx</source>
  <publication>publication/publication.ptx</publication>
  <output-dir>output/html</output-dir>
  <xsl>../pretext/xsl/pretext-html.xsl</xsl>
</target>

If your custom XSL file needs to import the XSL shipped with the CLI (e.g. pretext-common.xsl), then use the @pretext-href attribute in your custom XSL's <xsl:import/> as follows:

<xsl:import pretext-href="pretext-common.xsl"/>

The CLI will treat this as follows:

<xsl:import href="/path/to/cli/xsl/on/your/disk/pretext-common.xsl"/>

Development

Note. The remainder of this documentation is intended only for those interested in contributing to the developement of this project. Anyone who simply wishes to use the PreTeXt-CLI can stop reading here.

From the "Clone or Download" button on GitHub, copy the REPO_URL into the below command to clone the project.

git clone [REPO_URL]
cd pretext-cli

Using a valid Python installation

Developers and contributors must install a version of Python that matching the requirements in pyproject.toml.

Using pyenv and poetry (Mac/Linux)

The pyenv tool for Linux automates the process of running the correct version of Python when working on this project (even if you have other versions of Python installed on your system).

Run the following, replacing PYTHON_VERSION with your desired version.

pyenv install PYTHON_VERSION

Then follow these instructions to install poetry.

Then you should be able to install dependencies into a virtual environment with this command.

poetry install

Then to use the in-development package, you can either enter a poetry shell:

pretext --version # returns system version
poetry shell
pretext --version # returns version being developed
exit
pretext --version # returns system version

Or use the runner (as long as you remain within the package directory):

pretext --version             # returns system version
poetry run pretext --version  # returns version being developed

If you run echo 'alias pr="poetry run"' >> ~/.bashrc then restart your shell, this becomes less of a mouthful:

pretext --version     # returns system version
pr pretext --version  # returns version being developed

Steps on Windows

In windows, you can either use the bash shell and follow the directions above, or try pyenv-win. In the latter case, make sure to follow all the installation instructions, including the Finish the installation. Then proceed to follow the directions above to install a version of python matching .pyproject.toml. Finally, you may then need to manually add that version of python to your path.

Updating dependencies

To add dependencies for the package, run

poetry add DEPENDENCY-NAME

If someone else has added a dependency:

poetry install

Syncing untracked updates

Updates to certain files tracked to the repository will need to be rebuilt by each user when pulled from GitHub.

The file pretext/__init__.py tracks the upstream commit of core PreTeXt XSL/Python code we're developing against (from PreTeXtBook/pretext). To grab these updates from upstream, run:

poetry run python scripts/update_core.py

If you instead want to point to a local copy of PreTeXtBook/pretext, try this instead to set up symlinks:

poetry run python scripts/symlink_core.py path/to/pretext

Updates to templates/ must be zipped and moved into pretext/static/templates. This is done automatically by running:

poetry run python scripts/zip_templates.py

Packaging

To check if a successful build is possible:

poetry run python scripts/build_package.py

To publish a new alpha release, first add/commit any changes. Then the following handles bumping versions, publishing to PyPI, and associated Git management.

poetry run python scripts/release_alpha.py

Publishing a stable release is similar:

poetry run python scripts/release_stable.py # patch +0.+0.+1
poetry run python scripts/release_stable.py minor # +0.+1.0
poetry run python scripts/release_stable.py major # +1.0.0

About

PreTeXt-CLI Lead Developers

About PreTeXt

The development of PreTeXt's core is led by Rob Beezer.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pretextbook-0.7.7a5.tar.gz (988.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pretextbook-0.7.7a5-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file pretextbook-0.7.7a5.tar.gz.

File metadata

  • Download URL: pretextbook-0.7.7a5.tar.gz
  • Upload date:
  • Size: 988.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.5 Linux/5.13.0-1023-gcp

File hashes

Hashes for pretextbook-0.7.7a5.tar.gz
Algorithm Hash digest
SHA256 37a5c8ed7fe8fd6ed0a294fd3177b6127549c0f5f1b8baaaa636182ab4775d30
MD5 1be1f0f3d787e193168374f69b21b2a8
BLAKE2b-256 ad4ec3b3090aca000d8238401aff3072b405f32360e5a57e117c5fab0b661bf4

See more details on using hashes here.

File details

Details for the file pretextbook-0.7.7a5-py3-none-any.whl.

File metadata

  • Download URL: pretextbook-0.7.7a5-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.5 Linux/5.13.0-1023-gcp

File hashes

Hashes for pretextbook-0.7.7a5-py3-none-any.whl
Algorithm Hash digest
SHA256 79d214afd2a8d81f9153f1a452c5bf958601b45e4fb64ff6a7b6ed56bbb4ccd1
MD5 18a1a642594493514a716e25aaeb3002
BLAKE2b-256 d9f3bc0e1fc4bff578e4ff9a194577649e2b80ffe6a59e4cb1d1b910f172641f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page