use the pypi-hosted repository
This commit is contained in:
parent
9daa7fdb21
commit
1c987b9a75
|
|
@ -43,6 +43,7 @@ Vagrant.configure(2) do |config|
|
|||
config.vm.provision :shell, path: 'provision/use-maven-repository-from-gradle.sh'
|
||||
config.vm.provision :shell, path: 'provision/use-nuget-repository.sh'
|
||||
config.vm.provision :shell, path: 'provision/use-npm-repository.sh'
|
||||
config.vm.provision :shell, path: 'provision/use-pypi-repository.sh'
|
||||
config.vm.provision :shell, path: 'provision/summary.sh'
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2023 Rui Lopes
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Hello World
|
||||
|
||||
The Classic Hello World PyPI package.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "hello-world"
|
||||
version = "0.1.0"
|
||||
authors = [
|
||||
{ name="Rui Lopes", email="rgl@example.com" },
|
||||
]
|
||||
description = "Hello World"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.7"
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
"Homepage" = "https://github.com/nexus-vagrant/hello-world-python-package"
|
||||
"Bug Tracker" = "https://github.com/nexus-vagrant/issues"
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
bleach==6.0.0
|
||||
build==0.10.0
|
||||
certifi==2023.7.22
|
||||
cffi==1.15.1
|
||||
charset-normalizer==3.2.0
|
||||
cryptography==41.0.2
|
||||
docutils==0.20.1
|
||||
idna==3.4
|
||||
importlib-metadata==6.8.0
|
||||
jaraco.classes==3.3.0
|
||||
jeepney==0.8.0
|
||||
keyring==24.2.0
|
||||
markdown-it-py==3.0.0
|
||||
mdurl==0.1.2
|
||||
more-itertools==10.0.0
|
||||
packaging==23.1
|
||||
pkginfo==1.9.6
|
||||
pycparser==2.21
|
||||
Pygments==2.15.1
|
||||
pyproject_hooks==1.0.0
|
||||
readme-renderer==40.0
|
||||
requests==2.31.0
|
||||
requests-toolbelt==1.0.0
|
||||
rfc3986==2.0.0
|
||||
rich==13.4.2
|
||||
SecretStorage==3.3.3
|
||||
six==1.16.0
|
||||
tomli==2.0.1
|
||||
twine==4.0.2
|
||||
urllib3==2.0.4
|
||||
webencodings==0.5.1
|
||||
zipp==3.16.2
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
def greet(name):
|
||||
print(f'Hello, {name}!')
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
set -euxo pipefail
|
||||
|
||||
nexus_domain=$(hostname --fqdn)
|
||||
|
||||
rm -rf tmp/hello-world-pypi-package
|
||||
install -d tmp
|
||||
cp -r /vagrant/hello-world-pypi-package tmp
|
||||
cd tmp/hello-world-pypi-package
|
||||
|
||||
# create the venv.
|
||||
apt-get install -y python3-venv
|
||||
rm -rf .venv
|
||||
python3 -m venv .venv
|
||||
set +x && source .venv/bin/activate && set -x
|
||||
|
||||
# create the hello_world package.
|
||||
# see https://packaging.python.org/en/latest/tutorials/packaging-projects/
|
||||
# see https://help.sonatype.com/repomanager3/nexus-repository-administration/formats/pypi-repositories
|
||||
# NB requirements.txt was created as:
|
||||
# python3 -m pip install build twine
|
||||
# python3 -m pip freeze >requirements.txt
|
||||
python3 -m pip install -r requirements.txt
|
||||
python3 -m build --wheel
|
||||
python3 -m pip freeze >.venv/requirements.txt
|
||||
diff -u requirements.txt .venv/requirements.txt || (echo ERROR: requirement.txt is not up-to-date && false)
|
||||
|
||||
# upload.
|
||||
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
|
||||
cat >.venv/twine.conf <<EOF
|
||||
[pypi]
|
||||
repository: https://$nexus_domain/repository/pypi-hosted/
|
||||
username: alice.doe
|
||||
password: password
|
||||
EOF
|
||||
twine upload --non-interactive --config-file .venv/twine.conf dist/*
|
||||
unset CURL_CA_BUNDLE
|
||||
|
||||
# deactivate the venv.
|
||||
set +x && deactivate && set -x
|
||||
|
||||
# use the hello-world package.
|
||||
rm -rf .venv
|
||||
python3 -m venv .venv
|
||||
set +x && source .venv/bin/activate && set -x
|
||||
cat >.venv/pip.conf <<EOF
|
||||
[global]
|
||||
index = https://$nexus_domain/repository/pypi-hosted/pypi
|
||||
index-url = https://$nexus_domain/repository/pypi-hosted/simple
|
||||
cert = /etc/ssl/certs/ca-certificates.crt
|
||||
EOF
|
||||
python3 -m pip install hello-world
|
||||
python3 <<'EOF'
|
||||
import hello_world
|
||||
|
||||
hello_world.greet('World')
|
||||
EOF
|
||||
set +x && deactivate && set -x
|
||||
Loading…
Reference in New Issue