setuptool and setup.cfg : how declare data_files? - setuptools

The new approach to setup a Python package is to use a setup.cfg file.
But, it's impossible to find how I can add a data_files parameters.
How I can do it?

Use package_data instead of data_files. For example if you wanted all the xml files in mypkg/templates, this would work in setup.cfg:
[options.package_data]
mypkg/templates =
*.xml
See also: Data Files Support

Related

'project.urls' Not be recognized in PyPi

I have the following in my setup.cfg file:
[project.urls]
"Documentation" = "https://pysui.readthedocs.io"
"Bug Reports" = "https://github.com/FrankC01/pysui/issues"
My build executes without error and twine check and twine upload work without a hitch. However, the extra links do not show up in PyPi?
I think that format works only with the pyproject.toml as described at https://packaging.python.org/en/latest/tutorials/packaging-projects/#configuring-metadata . Note, the above describes how it works when using pypa's build for building, other packaging tools use their own ways to define this information.
If you prefer to use setup.cfg, you could try adding the project_urls under [metadata] like this:
[metadata]
project_urls =
Documentation = https://pysui.readthedocs.io
Bug Reports = https://github.com/FrankC01/pysui/issues
One more tip: you can check the PKG-INFO file in the created tar archive to see that the information was added correctly:
Project-URL: Documentation, https://pysui.readthedocs.io
Project-URL: Bug Reports, https://github.com/FrankC01/pysui/issues

asciidoc, doctoolchain, target github readme.adoc - how to export asciidoc file containing includes into ONE file without include?

GitHub supports asciidoc readme files, but it looks like "include" is not supported.
I want to use doctoolchain which can render and export to html and pdf (and maybe into other formats). This tool works great.
I could use raw.githack.com to show the generated html file from the GitHub repository.
But I think it would be a good idea to have the result also as one (1) readme.adoc file.
How to export into one (1) asciidoc file, which I could use as it is as readme file so that github will render it and show? Best would be to use doctoolchain, when this tool will render my documentation it could also generate the one-file-asciidoc-documentation.
I think internally asciidoctor collects and merge all these "include" files. So maybe this file is already available in any place? The doctoolchain build folder contains only the target files.
You are right there is a long dicussion why includeis not supported by github.
You can achieve your goal with doctoolChain and pandoc(https://pandoc.org/). Following steps are required:
configure your docDir/Config.groovy
inputFiles should have docbook defined
inputFiles = [[file: 'yourfile', formats['docbook']]]
run the doctoolchain task generateDocbook - it creates ???.xml file somewhere in docDir/build
generate from the generated docbook again an asciidoctor file - `pandoc <FILENAME_OF_GENERATED_DOCBOOK.XML> -f docbook -t asciidoctor -o <FILENAME_OF_ASCIIDOCTOR_WHICH_HAS_EVERYTHING>
make sure it runs automatically and you commit it regulary
now you are ready
This script can be used to resolve includes and to generate one (1) output file:
https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/scripts/asciidoc-coalescer.rb
some information about the script and possible next steps you can read here:
AsciiDoc Backend (AsciiDoc 2 AsciiDoc) for preprocessing
to use it, ruby and asciidoc must be installed:
asciidoctor.org/#installation

How to change the tutorial folder in Orange?

The default orange tutorial folder is the following:
..\Canopy32\User\Lib\site-packages\Orange\OrangeCanvas\application\tutorials\
What if I want to change this location? Or add another folder?
Also would it be possible to achieve this by simply having a configuration file inside OrangeWidget folder?
Help please,
Many thanks.
You cannot change the default location of tutorials, but you can add additional tutorial folders using entry point in setup.py.
First, you need to create a python package containing schema (ows) files. Then you need to add an entry point in the setup.py pointing to the location of the package you have created.
If the package with custom tutorials can be imported using import my_tutorials, your entry_point will look like this:
ENTRY_POINTS = {
'orange.widgets.tutorials': (
'my_tutorials = my_tutorials',
),
}
I have created a sample add-on that registers additional tutorials. It is available on github:
https://github.com/astaric/orange-custom-tutorials-example
If you download the code and run python setup.py install, you will see a new entry in the tutorials.

Marking files as config files in CPack

When creating RPM packages: How do I tell CPack to treat a file as config file so it won't get overridden when updating the RPM?
The %config directive is used in rpm-spec for that case. Is there something like this in CPack?
As of now, files specified with an absolute path will get marked with %config, files with a relative path are marked as 'normal' files.
A quick look at what appears to be the CPack documentation doesn't show me anything that looks like it is directly relevant or helpful here.
However, if you are using a new enough version of CMake (2.8.1+ it looks like) or apply the patch yourself it looks like you can manually specify the spec file to build by using CPACK_RPM_USER_BINARY_SPECFILE.

cmake find_path/find_library failed check

I'm using CMake 2.8.2 version. The project is using lots of external files and custom libraries (unavailable through find_package) and there is a long cascade of elements like the one below:
find_path(XXX_INCLUDE_DIR XXX.h /XXX/include)
if (XXX_INCLUDE_DIR)
message(STATUS "Includes (XXX) found in ${XXX_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Includes (XXX) not found")
endif()
There is over 20 things like this in the script - it doesn't look good. According to the documentation, unfortunately, neither find_path nor find_library have a REQUIRED option which would do the job here (just like it does with find_package - if not found, the script stops). Do you have an idea how can I shorten the CMake script code? Something like
find_path(XXX_INCLUDE_DIR XXX.h /XXX/include REQUIED)
or something similar would be great.
Put them in your custom FindXXX.cmake modules. Read the docs and look at FindPNG.cmake for an example. Put them into <project>/cmake/FindXXX.cmake (or similar), and then add the directory containing these files to the CMAKE_MODULE_PATH and use find_package(), e.g.
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
find_package(XXX REQUIRED)
You probably want to use either a macro or a function.