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

Use pbr rather than direct easy install #1312

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ cover
.coverage
dist
upgrade/
.venv
build/

# Ignore the IDE files
.idea
22 changes: 22 additions & 0 deletions bin/gnocchi-api
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
from gnocchi.cli import api

if __name__ == '__main__':
sys.exit(api.api())
else:
application = api.wsgi()

1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'sphinxcontrib.httpdomain',
'sphinx.ext.autodoc',
'reno.sphinxext',
'pbr.sphinxext',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[build-system]
requires = ["setuptools", "setuptools_scm", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
requires = ["pbr>=5.7.0", "setuptools>=51.0.0"]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ceph_alternative =
prometheus =
python-snappy
protobuf>=3.19.0
amqp1:
amqp1 =
python-qpid-proton>=0.17.0
doc =
sphinx
Expand Down
88 changes: 3 additions & 85 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,91 +15,9 @@
# limitations under the License.

import setuptools
import sys

from setuptools.command import develop
from setuptools.command import easy_install
from setuptools.command import install_scripts


# NOTE(sileht): We use a template to set the right
# python version in the sheban
SCRIPT_TMPL = """
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
from gnocchi.cli import api

if __name__ == '__main__':
sys.exit(api.api())
else:
application = api.wsgi()
"""


PY3 = sys.version_info >= (3,)


class local_install_scripts(install_scripts.install_scripts):
def run(self):
# NOTE(tobias-urdin): Always install_scripts so that we get
# gnocchi-api otherwise it's left out when installing with pip.
self.no_ep = False
install_scripts.install_scripts.run(self)
# NOTE(sileht): Build wheel embed custom script as data, and put sheban
# in script of the building machine. To workaround that build_scripts
# on bdist_whell return '#!python' and then during whl install it's
# replaced by the correct interpreter. We do the same here.
bs_cmd = self.get_finalized_command('build_scripts')
executable = getattr(bs_cmd, 'executable', easy_install.sys_executable)
try:
script = easy_install.get_script_header(
"", executable) + SCRIPT_TMPL
except AttributeError:
script = easy_install.ScriptWriter.get_header(
"", executable) + SCRIPT_TMPL
if PY3:
script = script.encode('ascii')
self.write_script("gnocchi-api", script, 'b')


class local_develop(develop.develop):
def install_wrapper_scripts(self, dist):
develop.develop.install_wrapper_scripts(self, dist)
if self.exclude_scripts:
return
try:
script = easy_install.get_script_header("") + SCRIPT_TMPL
except AttributeError:
script = easy_install.ScriptWriter.get_header("") + SCRIPT_TMPL
if PY3:
script = script.encode('ascii')
self.write_script("gnocchi-api", script, 'b')


cmdclass = {
'develop': local_develop,
'install_scripts': local_install_scripts,
}

try:
from sphinx import setup_command
cmdclass['build_sphinx'] = setup_command.BuildDoc
except ImportError:
pass


setuptools.setup(
cmdclass=cmdclass,
py_modules=[],
)
setup_requires=['pbr'],
pbr=True,
scripts=['bin/gnocchi-api'])
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ deps =
doc8
setenv = GNOCCHI_TEST_DEBUG=1
commands = doc8 --ignore-path doc/source/rest.rst,doc/source/comparison-table.rst doc/source
pifpaf -g GNOCCHI_INDEXER_URL run postgresql -- python setup.py build_sphinx -W
pifpaf -g GNOCCHI_INDEXER_URL run postgresql -- sphinx-build -W doc/source doc/build

[testenv:docs-gnocchi-web]
basepython = python3
Expand All @@ -144,7 +144,7 @@ deps = {[testenv:docs]deps}
setuptools
commands =
/bin/rm -rf doc/build/html
pifpaf -g GNOCCHI_INDEXER_URL run postgresql -- python setup.py build_sphinx
pifpaf -g GNOCCHI_INDEXER_URL run postgresql -- sphinx-build doc/source doc/build/html

[doc8]
ignore-path = doc/source/rest.rst,doc/source/comparison-table.rst