Move metadata to setup.cfg; also use this for pytest configuration

This makes it possible to run pytest in the root directory.  It also lets us store metadata such as the current version number, preventing us from having this in several different places, and allowing us to phase out parsing dtool/PandaVersion.pp.
This commit is contained in:
rdb 2017-11-03 19:34:02 +01:00
parent 40aa65249b
commit e0a3788636
4 changed files with 51 additions and 22 deletions

View File

@ -367,7 +367,8 @@ if VERSION is None:
if RUNTIME:
VERSION = PLUGIN_VERSION
else:
VERSION = ParsePandaVersion("dtool/PandaVersion.pp")
# Take the value from the setup.cfg file.
VERSION = GetMetadataValue('version')
if WHLVERSION is None:
WHLVERSION = VERSION

View File

@ -12,9 +12,11 @@ from distutils import sysconfig
if sys.version_info >= (3, 0):
import pickle
import _thread as thread
import configparser
else:
import cPickle as pickle
import thread
import ConfigParser as configparser
SUFFIX_INC = [".cxx",".cpp",".c",".h",".I",".yxx",".lxx",".mm",".rc",".r"]
SUFFIX_DLL = [".dll",".dlo",".dle",".dli",".dlm",".mll",".exe",".pyd",".ocx"]
@ -2849,6 +2851,21 @@ def CopyPythonTree(dstdir, srcdir, lib2to3_fixers=[], threads=0):
##
########################################################################
cfg_parser = None
def GetMetadataValue(key):
global cfg_parser
if not cfg_parser:
# Parse the metadata from the setup.cfg file.
cfg_parser = configparser.ConfigParser()
cfg_parser.read('setup.cfg')
value = cfg_parser.get('metadata', key)
if key == 'classifiers':
value = value.strip().split('\n')
return value
# This function is being phased out.
def ParsePandaVersion(fn):
try:
f = open(fn, "r")

View File

@ -20,7 +20,7 @@ import tempfile
import subprocess
from distutils.sysconfig import get_config_var
from optparse import OptionParser
from makepandacore import ColorText, LocateBinary, ParsePandaVersion, GetExtensionSuffix, SetVerbose, GetVerbose
from makepandacore import ColorText, LocateBinary, ParsePandaVersion, GetExtensionSuffix, SetVerbose, GetVerbose, GetMetadataValue
from base64 import urlsafe_b64encode
@ -103,16 +103,15 @@ Tag: {0}-{1}-{2}
"""
METADATA = {
"license": "BSD",
"name": "Panda3D",
"license": GetMetadataValue('license'),
"name": GetMetadataValue('name'),
"metadata_version": "2.0",
"generator": "makepanda",
"summary": "Panda3D is a game engine, a framework for 3D rendering and "
"game development for Python and C++ programs.",
"summary": GetMetadataValue('description'),
"extensions": {
"python.details": {
"project_urls": {
"Home": "https://www.panda3d.org/"
"Home": GetMetadataValue('url'),
},
"document_names": {
"license": "LICENSE.txt"
@ -120,25 +119,13 @@ METADATA = {
"contacts": [
{
"role": "author",
"email": "etc-panda3d@lists.andrew.cmu.edu",
"name": "Panda3D Team"
"name": GetMetadataValue('author'),
"email": GetMetadataValue('author_email'),
}
]
}
},
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: C++",
"Programming Language :: Python",
"Topic :: Games/Entertainment",
"Topic :: Multimedia",
"Topic :: Multimedia :: Graphics",
"Topic :: Multimedia :: Graphics :: 3D Rendering"
]
"classifiers": GetMetadataValue('classifiers'),
}
PANDA3D_TOOLS_INIT = """import os, sys

24
setup.cfg Normal file
View File

@ -0,0 +1,24 @@
[metadata]
name = Panda3D
version = 1.10.0
url = https://www.panda3d.org/
description = Panda3D is a framework for 3D rendering and game development for Python and C++ programs.
license = Modified BSD License
license_file = LICENSE
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: End Users/Desktop
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: C++
Programming Language :: Python
Topic :: Games/Entertainment
Topic :: Multimedia
Topic :: Multimedia :: Graphics
Topic :: Multimedia :: Graphics :: 3D Rendering
author = Panda3D Team
author_email = etc-panda3d@lists.andrew.cmu.edu
[tool:pytest]
testpaths = tests