I have just discovered the pypi web UI have a field 'Bug tracker URL' in edit of egg metadata.
This field exists so I guess it is supported in setup.py but I can't find anything about this using google.
So the question how do I set up this field in my setup.py so when doing a dist release on pypi it can be automaticly filled.
The entry is called bugtrack_url, but it's not being picked up from setup.py.
From context and code I understand it was intended to be used through-the-web on PyPI only, as per-project metadata, and not the usual per-release information.
The field is now considered a legacy field (hardcoded to None) and you instead add such information through the Project-URL list, which you can set in setuptools via the project_urls entry:
project_urls={
'Documentation': 'https://packaging.python.org/tutorials/distributing-packages/',
'Funding': 'https://donate.pypi.org',
'Say Thanks!': 'http://saythanks.io/to/example',
'Source': 'https://github.com/pypa/sampleproject/',
'Tracker': 'https://github.com/pypa/sampleproject/issues',
},
This option was finally added to setuptools in November 2017, and landed in version 38.3.0.
Bug tracker URL on PyPi project
In setup.py use project_urls in the setup :
setup(
...
project_urls={
'Documentation': 'https://readthedocs.io/',
'Funding': 'https://donate.pypi.org',
'Say Thanks!': 'http://saythanks.io/to/example',
'Source': 'https://github.com/pypa/sampleproject/',
'Tracker': 'https://github.com/pypa/sampleproject/issues',
},
...
)
The dict order is kept but listed in reversed on PyPi:
About PyPi bugtracker_url legacy code
pypa/warehouse Issue #233
bugtrack_url: IIRC it was something added by the PyPI maintainers to help projects, but in parallel PEP 345 introduced Project-URL which was intended to cover source code repository, bug tracker, mailing list, etc. If PEP 426 or one of its companion keeps Project-URL (and maybe improves it with defined labels for common sites, e.g. "repository"), then this special case becomes redundant.
And
At the moment, it looks like this is hardcoded to None in their API. I guess they left the field for backwards compatibility when they migrated...
Related
So, I'm trying to create SQL templates with certain parameters would change based on the call. I reviewed many other methods but I found the method using JinjaSql more suitable and readable for the requirement of my module.
I tried creating a class as below (code shortened) to create a templated list of queries.
from jinjasql import JinjaSql
j = JinjaSql(param_style='pyformat')
class QueryTemplate(object):
def highest_pp_team_score(self, tour_name, year):
params = {'tour_name': [], 'year': []}
params['tour_name'].append(tour_name)
params['year'].append(year)
template = """
SELECT
id.match_id,
id.inning,
id.team
FROM
innings_deliveries as id
WHERE
id.name LIKE {{ tour_name }}
AND YEAR(id.start_date) = {{ year }}
"""
query, bind_params = j.prepare_query(template, params)
return query % bind_params
... when I try and run, I get the below error. It's on the import itself.
ImportError: cannot import name 'Markup' from 'jinja2.utils'
After reading about the issue, I couldn't find any resolutions to my case but I did find a thread with similar issue. It needed me to add few lines to the import. Since, the original issue was related to flask, I couldn't implement it to my case.
This is an issue in the library you are using. It has been reported on their issue tracker already, see https://github.com/sripathikrishnan/jinjasql/issues/50
What you could do is to downgrade your Jinja version to the one before 3.1.0 that brought those breaking changes of removing Markup and escape.
If you do have a requirements.txt file to install your dependencies, this is as simple as adding a line in it like
jinja2<3.1.0
And redo a
pip install --requirements requirements.txt
If you don't have such a file but are installing your packages with pip, you could do
pip install --upgrade 'jinja2<3.1.0'
I'm looking at extensions for CKAN, and their entry_points entries look like this:
setup(
#...,
entry_points='''
[ckan.plugins]
template=ckanext.template.plugin:TemplatePlugin
[babel.extractors]
ckan = ckan.lib.extract:extract_ckan
[paste.paster_command]
template=ckanext.template.commands.custom_commands:CustomCommand
''',
#...,
)
I'm trying to upgrade an existing extension that uses CKAN's CLI. The 3rd entry above is for a CLI command. I'm trying to update it for CKAN's latest version that no longer uses Paster, but uses Click instead.
I'm trying to tell how to update [paste.paster_command], but I can't find references to anything else using this entry_points syntax to be certain how to update it. For any reference to setup.py syntax I can find, it looks like below (from Click's documentation, in this case):
setup(
#...,
entry_points={
'console_scripts': [
'yourscript = yourpackage.scripts.yourscript:cli',
],
},
)
The setuptools documentation only references entry_points in relation to setup.cfg. So the examples of entry_points in their docs are unhelpful. Therefore, given what I can find, I have to assume for the triple-quote syntax above that it's just regular Python string formatting, and the square brackets are the "dependency extra". True? If not, what are they? Any reference to this "alternate" string syntax would be appreciated.
Per response from Zharktas on CKAN's GitHub discussion board:
The syntax is in .ini-style:
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#creating-and-parsing
"If data is a string or sequence of lines, it is first split into .ini-style sections (using the split_sections() utility function) and the section names are used as group names."
Click commands implemented with IClick interface do not require entry in entry_points anymore as they are executed through the new ckan command instead of paster which required that you tell paster about them via entry_points.
You can just remove whole entry if you want to support only CKAN 2.9.
I'm using RTD + Sphinx for my project ( redgrease = https://github.com/lyngon/redgrease ) and it seems like the syntax highlighting of code-blocks isn't working on the readthedocs.io page.
It only displays black text in a box.
E.g. see list item 3 at:
https://redgrease.readthedocs.io/en/latest/intro.html#intro-redgrease
The syntax highlighting works fine when I build locally (with sphinx-build) as well as in VS Code using the reStructuredText plugin.
Working (local)
Not working (readthedocs.io)
The code blocks are all indented (as they appear inside lists), similar to this:
#. :ref:`Server-side Redis commands <red_commands>`.
Allowing for ... blah blah ...
It is ... yada yada ...
.. code-block:: python
:emphasize-lines: 8, 11, 13
import redgrease
import redgrease.utils
# ... moar codes ..
What might be going on?
Do i need some extension or add some config option?
I don't have much trickery going on in the 'conf.py' nor '.readthedocs.yml'.
(see repo)
The reason was painfully simple.
I had by mistake pinned a really old version of 'sphinx-rtd-theme' in my 'requirements.txt' file.
I had pinned version 0.1.5 instead of the latest 0.5.1
My local env simply had a more recent version.
Doh! 🤦
I am writing my first package to be shared on the pypi database...
It took me a lot of fiddling to get everything to package correctly, but I finally did.
I have a structure like this.
---dist
---package.egg-info
---MANIFEST.in
---setup.py
---package/
---__init__.py
---file.py
---info.txt
---templates/
---template.html
now in my dist folder when I extract the tar.gz file I see everything. but when I run a pip install package then I only get the egg and the init.py and file.py files and not the other text files and template files.
Why is this?
Setup.py added...:
setup(name='django-g-recaptcha',
version='0.1.2',
description='Django view decorator to validate google recaptcha forms',
url='https://bitbucket.org/deltaskelta/django-g-recaptcha-validate/overview',
author='Jeff Willette',
author_email='jrwillette88#gmail.com',
keywords = ['django', 'recaptcha', 'catpcha'],
packages = ['g_recaptcha',],
)
Add include_package_data = True to setup() arguments:
setup(name='django-g-recaptcha',
version='0.1.2',
description='Django view decorator to validate google recaptcha forms',
url='https://bitbucket.org/deltaskelta/django-g-recaptcha-validate/overview',
author='Jeff Willette',
author_email='jrwillette88#gmail.com',
keywords = ['django', 'recaptcha', 'catpcha'],
packages = ['g_recaptcha',],
include_package_data = True
)
This should help, however I suggest to also use package_data along with your MANIFEST.in. And also you might want to add a setting specifying, that your package is intended to be used with Django.
See https://pythonhosted.org/setuptools/setuptools.html for more information.
I discoverd entry_points of setuptools:
http://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins
quote: setuptools supports creating libraries that “plug in” to extensible applications and frameworks, by letting you register “entry points” in your project that can be imported by the application or framework.
But I have not seen a project using them.
Are there examples of projects which use them?
If not, why are they not used?
There are loads of examples. Any project that defines console scripts uses them, for example. A quick search on GitHub gives you plenty to browse through.
I'll focus on one specific example (one that is not on GitHub): Babel.
Babel uses both entry_points for both console scripts and to define extension points for translatable text extraction. See their setup.py source:
if have_setuptools:
extra_arguments = dict(
zip_safe = False,
test_suite = 'babel.tests.suite',
tests_require = ['pytz'],
entry_points = """
[console_scripts]
pybabel = babel.messages.frontend:main
[distutils.commands]
compile_catalog = babel.messages.frontend:compile_catalog
extract_messages = babel.messages.frontend:extract_messages
init_catalog = babel.messages.frontend:init_catalog
update_catalog = babel.messages.frontend:update_catalog
[distutils.setup_keywords]
message_extractors = babel.messages.frontend:check_message_extractors
[babel.checkers]
num_plurals = babel.messages.checkers:num_plurals
python_format = babel.messages.checkers:python_format
[babel.extractors]
ignore = babel.messages.extract:extract_nothing
python = babel.messages.extract:extract_python
javascript = babel.messages.extract:extract_javascript
""",
)
Tools like pip and zc.buildout use the console_scripts entry point to create commandline scripts (one called pybabel, running the main() callable in the babel.messages.frontend module).
The distutils.commands entry points defines additional commands you can use when running setup.py; these can be used in your own projects to invoke Babel command-line utilities right from your setup script.
Last, but not least, it registers its own checkers and extractors. The babel.extractors entry point is loaded by the babel.messages.extract.extract function, using the setuptools pkg_resources module, giving access to all installed Python projects that registered that entry point. The following code looks for a specific extractor in those entries:
try:
from pkg_resources import working_set
except ImportError:
pass
else:
for entry_point in working_set.iter_entry_points(GROUP_NAME,
method):
func = entry_point.load(require=True)
break
This lets any project register additional extractors; simply add an entry point in your setup.py and Babel can make use of it.
Sentry is a good example. Sentry's author even created a django package named Logan to convert standard django management commands to console scripts.