Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PyPI packaging #71

Merged
merged 5 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*~
*.pyc
*.py[cod]
*.exe
*.asc
venv*/
Expand All @@ -9,11 +9,16 @@ venv*/
.coverage*
reports/
.scannerwork/
packages/sshaudit/LICENSE
packages/sshaudit/README.md
packages/sshaudit/sshaudit.py
packages/parts/
packages/prime/
packages/snap/
packages/stage/
packages/ssh-audit_*.snap

# PyPI packaging
/build/
/dist/
*.egg-info/
*.egg

# Snap packaging
/parts/
/prime/
/snap/
/stage/
/ssh-audit_*.snap
11 changes: 11 additions & 0 deletions Makefile.pypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
all:
python3 setup.py sdist bdist_wheel

uploadtest:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

uploadprod:
twine upload dist/*

clean:
rm -rf build/ dist/ src/*.egg-info/
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/notes.txt → PACKAGING
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $ virtualenv -p /usr/bin/python3 /tmp/pypi_upload
$ cd /tmp/pypi_upload; source bin/activate
$ pip3 install twine
$ cp -R path/to/ssh-audit .
$ cd ssh-audit/packages
$ cd ssh-audit
$ make -f Makefile.pypi
$ make -f Makefile.pypi uploadtest

Expand All @@ -22,7 +22,7 @@ $ pip3 install --index-url https://test.pypi.org/simple ssh-audit
To upload to production server:

$ cd /tmp/pypi_upload; source bin/activate
$ cd ssh-audit/pypi
$ cd ssh-audit
$ make -f Makefile.pypi uploadprod


Expand Down
1 change: 0 additions & 1 deletion packages/MANIFEST.in

This file was deleted.

14 changes: 0 additions & 14 deletions packages/Makefile.pypi

This file was deleted.

58 changes: 0 additions & 58 deletions packages/setup.py

This file was deleted.

4 changes: 0 additions & 4 deletions packages/sshaudit/__main__.py

This file was deleted.

7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
requires = [
"setuptools>=40.8.0",
"wheel"
]
build-backend = "setuptools.build_meta"
44 changes: 44 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[metadata]
name = ssh-audit
version = attr: ssh_audit.ssh_audit.VERSION
author = Joe Testa
author_email = jtesta@positronsecurity.com
description = An SSH server & client configuration security auditing tool
long_description = file: README.md
long_description_content_type = text/markdown
license_file = LICENSE
url = https://github.com/jtesta/ssh-audit
project_urls =
Source Code = https://github.com/jtesta/ssh-audit
Bug Tracker = https://github.com/jtesta/ssh-audit/issues
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Security
Topic :: Security :: Cryptography

[options]
packages = find:
package_dir =
= src
python_requires = >=3.5,<4

[options.packages.find]
where = src

[options.package_data]
ssh_audit = policies/*

[options.entry_points]
console_scripts =
ssh-audit = ssh_audit.ssh_audit:main
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import re
import sys
from setuptools import setup

print_warning = False
m = re.search(r'^VERSION\s*=\s*\'v(\d\.\d\.\d)\'', open('src/ssh_audit/ssh_audit.py').read(), re.M)
if m is None:
# If we failed to parse the stable version, see if this is the development version.
m = re.search(r'^VERSION\s*=\s*\'v(\d\.\d\.\d-dev)\'', open('src/ssh_audit/ssh_audit.py').read(), re.M)
if m is None:
print("Error: could not parse VERSION variable from ssh_audit.py.")
sys.exit(1)
else: # Continue with the development version, but print a warning later.
print_warning = True

version = m.group(1)
print("\n\nPackaging ssh-audit v%s...\n\n" % version)

# see setup.cfg
setup()

if print_warning:
print("\n\n !!! WARNING: development version detected (%s). Are you sure you want to package this version? Probably not...\n" % version)
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/ssh_audit/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ssh_audit.ssh_audit import main
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading