Skip to content

Commit 79729a6

Browse files
akaszynskigreschd
andauthored
Add documentation for external pypi (#65)
* in progress * finalize docs * remove duplicate label * Update doc/source/guidelines/private_packaging.rst Co-authored-by: Dominik Gresch <[email protected]> * add note regarding forked repos Co-authored-by: Dominik Gresch <[email protected]>
1 parent b0ee74d commit 79729a6

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

doc/source/guidelines/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ functionalities such as logging, data transfer, and application APIs.
1818
logging
1919
service_abstraction
2020
test_practices
21+
private_packaging
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.. _private_dependencies:
2+
3+
4+
Hosting Private Dependencies
5+
============================
6+
There will be cases in which it is necessary to host and pull packages that are
7+
not ready to be hosted to the public `PyPI`_. For example, if a PyAnsys library
8+
requires auto-generated gRPC interface files from an as-of-yet private feature
9+
or service, this package should be hosted on a private PyPI repository.
10+
11+
Ansys has a private repository at `PyAnsys PyPI`_, and access is controlled via
12+
a secret PAT, specified in the GitHub secret ``PYANSYS_PYPI_PRIVATE_PAT`` which
13+
is only available to repositories within the `PyAnsys`_.
14+
15+
.. note::
16+
Forked GitHub repositories do not have access to GitHub secrets. This is
17+
designed to protect against PRs that could potentially scrape tokens from
18+
our CI/CD.
19+
20+
21+
Upload
22+
------
23+
Packages can be uploaded to the private repository with the following short
24+
bash script. If you are operating out of a GitHub CI pipeline, email the
25+
PyAnsys Core team at [email protected] for the PAT,
26+
``PYANSYS_PYPI_PRIVATE_PAT``.
27+
28+
Assuming you are already in a Python repository containing your wheels and/or
29+
source distribution within the ``dist`` directory:
30+
31+
.. code::
32+
33+
pip install build twine pip -U
34+
35+
REPOSITORY_URL="https://pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/upload"
36+
python -m twine upload dist/* \
37+
-p $PYANSYS_PYPI_PRIVATE_PAT \
38+
-u PAT \
39+
--repository-url $REPOSITORY-URL
40+
41+
Alternatively, you can use environment variables instead of CLI arguments for twine.
42+
43+
.. code::
44+
45+
export TWINE_USERNAME=PAT
46+
export TWINE_PASSWORD=$PYANSYS_PYPI_PRIVATE_PAT
47+
export TWINE_REPOSITORY_URL="https://pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/upload"
48+
49+
python -m twine upload dist/*
50+
51+
52+
Download
53+
--------
54+
To download the Python package from the `PyAnsys PyPI`_, use the following:
55+
56+
.. code::
57+
58+
INDEX_URL=https://[email protected]/pyansys/_packaging/pyansys/pypi/simple/
59+
pip install ansys-<product/tool>-<library> --index-url $INDEX_URL --no-dependencies
60+
61+
.. warning::
62+
Take care to always use the ``--index-url`` switch rather than the
63+
``--extra-index-url`` switch. As noted in the `pip Documentation`_, the
64+
``--index-url`` switch changes the Python Package Index, and forces ``pip``
65+
to only use packages from that package index.
66+
67+
Our package index uses PyPI upstream, and therefore other users cannot
68+
inject packages from PyPI that would supersede our packages, even if they
69+
are of a higher version.
70+
71+
This is not the case if you use ``--extra-index-url``, which adds rather
72+
than replaces the default package index. For security do not use
73+
``--extra-index-url``.
74+
75+
76+
.. _PyPI: https://pypi.org/
77+
.. _PyAnsys PyPI: https://pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi
78+
.. _PyAnsys: https://github.com/pyansys
79+
.. _pip Documentation: https://pip.pypa.io/en/stable/cli/pip_install/

0 commit comments

Comments
 (0)