Commit Graph

77 Commits

Author SHA1 Message Date
Stephen Finucane 457a89ffda Add support for PEP-660
As with PEP-517 support, this is simply a shim over the setuptools
implementation added in setuptools v64.0.0 [1].

[1] https://github.com/pypa/setuptools/pull/3488

Change-Id: I32f974db37e364cf634b050b40bf0820dce0a3a3
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-11-01 12:53:18 -07:00
Jay Faulkner d03d617c09 Replace imp with importlib.machinery
The imp was removed in Python 3.12 [1]. This commit replaces
get_suffixes() method call with _SUFFIXES array from
importlib.machinery.

This was imported from https://github.com/openstack/pbr/pull/22
on behalf of the Gentoo maintainer who proposed it.

Co-Authored-By: Petr Vaněk <arkamar@atlas.cz>
Change-Id: Icf00beee255aba3da2b81d9dc5b1f8130bbcd869
2023-06-02 11:46:31 -07:00
Clark Boylan ee04b62de2 Use _ instead of - in setup.cfg directives
Setuptools deprecated -'s at some point and they result in a bunch of
warnings in failed tests. This is distracting and eventually is likely
to create real errors. Go ahead and fix them now.

Change-Id: If3594269495ae1f3cefffd4c4f38d87af5c7fdfe
2023-05-31 13:25:23 -07:00
Chris Dohmen 0aecbea81b Fix symbol identification in multiline message
* Fix an issue where a multiline message with leading spaces would cause
  invalid symbol identification.
* Add unit-tests around multiple symbols in a single line

Sem-Ver: bugfix
Change-Id: Id799c2fd368d9df38a5c01fc2071283aecef67c6
2022-08-05 10:08:09 -04:00
Chris Dohmen 3793d87deb Allow leading spaces when determining symbols
Update the logic that checks for sem-ver to strip out leading spaces.
This helps solve an issue during automated squashes appending a tab
character to the start of each line in a commit message.

Closes-Bug: #1977479
Change-Id: I6f56500c366fd9610d98507f01e8af21862e4421
2022-06-03 09:21:25 -04:00
Jeremy Stanley 949c47c979 Avoid recursive calls into SetupTools entrypoint
Add a check in pbr.core.pbr() to make sure it hasn't already run,
and return immediately if it has. This replaces the earlier attempt
at loop-busting by setting the entrypoint to None in the dist, in
order to support PEP 517 builds without setup_requires.

Also test that pbr.json is now included in the dist tree, in order
to avoid future regressions.

Change-Id: I407ae88ab8de4b61f94034b3d79a2ca7f7d79d16
2022-02-04 23:36:13 +00:00
Ben Greiner 397b6fcdf9 remove explicit mock
The explicit mock package is not required if you can use unittest.mock
from python >= 3.3

Change-Id: I1e3a764b38be66b994d790768bc5eb9be4237444
2022-01-21 10:44:41 +01:00
Clark Boylan de0c717b17 Allow PEP517 without setup_requires
When using PBR PEP517 support without setup_requires were were
infinitely recursing because Distribution.finalize_options calls pbr()
and pbr() calls Distribution.finalize_options. With a setup_requires
this doesn't seem to happen because something is resetting dist.pbr's
value from True (callable) to None (not callable) after the initial
pbr() call and before further recursion can occur.

Explicitly enforce this behavior in pbr() via an explicit update of
dist.pbr to None to avoid calling pbr() more than once resulting in the
unwanted loop.

Change-Id: I1f2b4d34e587389f7e11b99d000e14477cf5091b
2021-11-12 09:16:04 -08:00
Clark Boylan d21c2caf1d Clarify the need for setup.py with PEP517
There was a misunderstanding that PBRs PEP517 build hooks meant we no
longer needed a setup.py. But it turns out the setuptools build_meta
hooks that we wrap call out to setup.py. This means PBR will continue to
need to be used in conjunction with a setup.py.

This is better for backward compatibiltiy anyway so not a huge loss.

Document this more properly and update the test to reflect it.

Change-Id: If4320da1e89a5c765e0bfe56b724364f9cba34f3
2021-11-08 08:56:18 -08:00
Monty Taylor 09ee153410 Add a PEP517 interface
pep517 defines a new module method of specifying build backends.
To allow pbr to exist in this world, we should define the interface
that's needed. For this to be used, one will put:

  [build-system]
  requires = ["pbr>=5.7.0", "setuptools>=36.6.0", "wheel"]
  build-backend = "pbr.build"

Into pyproject.toml - and the pep517 interface will be used.

This doesn't really change anything else - it just makes us support this.
So by itself this commit isn't SUPER helpful. But maybe let's take baby
steps with something this prone to strife, yeah?

After this we can start teasing some things apart and doing our
own things directly.

Co-Authored-By: Clark Boylan <clark.boylan@gmail.com>
Change-Id: I293f59b5074a38c78adffe580de2f1533bb01ce7
2021-11-03 10:05:32 -07:00
Clark Boylan 8c0d5c3141 PBR package testing improvements
We simplify virtualenv setup for PBR package installation testing by
switching to a simple file path for the PBR installation rather than a
full url with egg specifier. The egg specifer isn't necessary and
neither is the url and simpler is easier to understand.

We also add the verbose flag to the pip installations of tools into that
virtualenv to better understand problems when they occur.

Finally we add the option to skip writing package files if their
contents are empty. This allows us to ensure that we can omit certain
files which will be useful for the next change.

Change-Id: I1f081d29d62c905c1bb1abee5402b0990c83e948
2021-11-03 10:01:43 -07:00
Sorin Sbarnea 45e0cc2bbc Prevent test failure due to use of setpref
This fixes a bug that prevented successful test gpg key creation on
some machines.

gpg: invalid item '(setpref)' in preference string

Bug: #1627102
Change-Id: I848e2c0972c3def9e67ff954eb17c560e474e8cf
2021-04-01 09:13:46 +01:00
Stephen Finucane 73c11c6267 Add support for virtualenv 20.x
virtualenv is undergoing a rewrite and has changed how the programmatic
API works [1]. Switch to the "new way".

While we're here, we also need to get Python 2.7 tests passing again.
That requires dropping support for upper-constraints and using our own,
limited local constraints based on supported Python versions. We also
need to migrate integration tests since those run with Python 3 now.
Update the scenarios for pip/setuptools in integration testing
similarly. Finally clean up the installation of all devstack repos as
requirements are managed different now. Instead of worrying about
syncing them we use constraints.

[1] https://github.com/pypa/virtualenv/issues/1585#issuecomment-585228492

Change-Id: I493e88985d2c4d09612fea4d20d8ffa20043a0cb
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Depends-On: https://review.opendev.org/739014
2020-08-05 15:01:15 -07:00
Stephen Finucane dfe67959e6 trivial: Use 'open' context manager
It's a little nicer to look at.

Change-Id: If5bc9b7e3927fe3203ba9adadaa1185c4a1cc7ed
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-08-27 16:57:23 +01:00
Stephen Finucane 57d7c53739 Update to latest hacking
Change-Id: If73238a39d0934c6f577fc52132fcbc63e8eb25f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-08-27 16:57:23 +01:00
Stephen Finucane fa0dd5652d Mark strings as raw
Resolves the following deprecation warning:

  DeprecationWarning: invalid escape sequence \.

Change-Id: If0bc30e646a3bb35c02dc73cc31fb146b3ecd6b5
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-08-27 16:57:23 +01:00
Zuul f3b9a8919f Merge "Fix parsing on egg names with dashes from git URLs" 2019-07-18 11:16:30 +00:00
Hervé Beraud 4627305b8a Fix parsing on egg names with dashes from git URLs
repository urls for non editables end up in the `install_requires`
list causing setup to fail. In this commit, all usable external urls get
inserted into the `dependency_links` list with the corresponding egg fragments
parsed into package names and versions (maintaining dashes if any) and added to
`install_requires` list.

Introduce parsing by using urlparse to extract properly the url
fragment.

Change-Id: If19576869fdf38e1768190c2d9c33f32504f7c54
Closes-Bug: #1373623
2019-06-26 16:55:13 +02:00
Martin Domke de739bb080 Allow git-tags to be SemVer compliant
This fix allows it to use git-tags with a pre-release suffix that
follows the SemVer specification (e.g. 1.2.3-rc1).

Change-Id: Ie2e3c0e4145a105aff0a35c8dc6ec2a0cc1fc04e
2019-05-24 13:22:45 +00:00
Zuul 7909c7afd3 Merge "Ignore --find-links in requirements file" 2019-01-22 21:04:45 +00:00
Ben Nemec bc4193b183 Ignore --find-links in requirements file
We already skip things like --index-url, but --find-links can also
be present and also shouldn't be included in install_requires.

This also fixes some issues with the existing unit test for this
filtering.

Change-Id: Ie8eca8c19e955d52722feaa71d5843ccd74b0da0
Closes-Bug: 1716808
2019-01-22 17:19:24 +00:00
Zuul 32bfe7808f Merge "packaging: Remove support for pyN requirement files" 2018-10-06 21:14:59 +00:00
Stephen Finucane f14a3b2b73 Support wheel 0.32.0+
Wheel 0.32.0 removed the 'wheel install' command [1] and, subsequently,
the 'wheel.install' module [2]. It also made 'WheelFile' a subclass of
'zipfile.ZipFile' rather than a wrapper [2] and deprecated the '[wheel]'
section of 'setup.cfg' in favour of '[bdist_wheel]'. Handle these
changes.

[1] https://github.com/pypa/wheel/commit/353217fb4
[2] https://github.com/pypa/wheel/commit/89492505b

Change-Id: I2903089a07bdd2dc96437b9f65f2d2bba2741707
2018-10-04 10:52:05 +01:00
Wei Tie bca35333bc Support subdirectory in the url
Pip supports git+https://foo.com/zipball#egg=bar&subdirectory=baz
when setup.py is not at the root directory of the project [1]. This
commit keeps pbr function in this case.

[1] https://pip.pypa.io/en/latest/reference/pip_install/#vcs-support

Change-Id: I70dac755caacc89859a8646c090b69800401bbc0
Closes-Bug: 1786306
Signed-off-by: Wei Tie <nuaafe@gmail.com>
2018-08-23 10:46:56 -07:00
Stephen Finucane 8ea9d9262d packaging: Remove support for pyN requirement files
Change-Id: I7f915ecdc819bc4d3c6811949f12bdadb108a1ab
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2018-07-23 11:04:39 +01:00
Doug Hellmann 37a1ce7f85 update parse test to use reliable comparison
Different versions of setuptools seem to produce
different representations of the version specifiers,
so use pkg_resources to parse the values again
and then compare the resulting objects so we
aren't tripped up by rendering differences.

Change-Id: Ic67cc936208dbd96b6d811c6aa284fd87df5b118
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Closes-Bug: #1758877
2018-03-26 12:39:28 +00:00
Stephen Finucane 9be181e8e6 deprecations: Deprecate support for '-py{N}' requirements
This has been marked as deprecated for a long time in the docs but
we've done nothing to indicate this from a code perspective. Fix this.

Change-Id: I916bf16773a2a2cffa3c352d5dba52e3fbc298c2
Fixes-Bug: #431529
2018-01-09 14:31:01 +00:00
Stephen Finucane 6c8455c8c5 tests: Increase coverage of requirements parsing
This is mostly an exercise in refactoring, moving tests into a single
test case. An additional test is added, however, verifying that default
requirement files are indeed used if nothing else is provided.

Change-Id: I8dc6cc8c50f1280f24731480501fab61fc401809
2017-12-06 11:34:25 +00:00
Stephen Finucane ec210af0f5 trivial: Move packaging tests to test_packaging
There's a little bit of duplication going on here. Resolve this by
moving tests that predominantly focus on FILE to tests/test_FILE.

Change-Id: I29355155853e543d017db00c936bcdc88c1c97ad
2017-12-06 11:32:44 +00:00
Matthew Montgomery 2a0f2e589c Ignore index URL lines in requirements.txt files
Currently if an index is specified by either -i, --index-url or
--extra-index-url, the following error may be encountered when
setup is run.

Invalid requirement, parse error at "u'-i https'"

This patch ignores those lines in a requirements.txt file durning
parsing.

Closes-Bug: #1394999

Change-Id: Ie03f54ca7a7edad7a26fa1721f7b26532b65e760
2017-05-18 08:51:35 -05:00
Gage Hugo 3cc5af104e Add Changelog build handling for invalid chars
This change adds new handling when building a Changelog file
for specific characters that cause documentation building
warnings/errors to be emitted when sphinx tries to generate
a Changelog html page. The changes include:

- Escaping any '*' in a commit, which sphinx will interpret as the
  start of a new line and throw a warning.
- Escaping any '_' in a commit, which in certain cases, sphinx will
  interpret as an invalid link and create an error.
- Escaping any '`' in a commit, which in certain cases will
  cause sphinx to interpet as a literal, and throw a warning.

After this change, any entries in the changelog that contain
the above "invalid" syntax no longer generate sphinx
warnings/errors and the offending entries now generate correctly.

Change-Id: I672ef4c56486e59a384849a4b182d11129726ae9
2017-03-27 11:37:24 -05:00
Jenkins e5d8a78507 Merge "Fix pypy soabi tests" 2016-11-17 20:05:35 +00:00
Sachi King a432bc2930 Don't ignore data-files
We're currently ignoring data-files, and it looks like the problem
would sometimes be present starting with 2796f9, 0.5.7, and always be present
from 04984a, 0.5.15.

This normalises all config keys from - to _ as soon as we read the
config, which means future access and modification does not need to
concern itself with the possibility of the key being a '-' instead '_'.

This should make it more difficult for code accessing/modifying values
in the config to clobber user set values or be unaware of them, like
in the case of the files hook.

As well, support download-url, but properly expose it as download_url.

Co-Authored-By: Julien Danjou <julien@danjou.info>
Change-Id: I062774c706b8f7339dda46689a226b80ae6ac277
2016-08-26 14:28:38 +10:00
Sachi King d529e2b2a2 Fix pypy soabi tests
Xenial PyPy adds multiarch to the compiled c library, so if PyPy reports
multiarch we add it to the soabi string.

If the installed PyPy is not configured for multiarch, the multiarch
config variable will not exist and `arch` will be None, in which case we
should only update the string if multiarch exists.

Change-Id: Idcd3af4878d5b66c6770f96e7235a7d2f848df81
2016-07-18 18:09:36 +10:00
weiweigu 3438c2b8ad Fix argument order for assertEqual to (expected, observed)
assertEqual expects that the arguments provided to it should be
(expected, observed). If a particluar order is kept as a convention,
then it helps to provide a cleaner message to the developer if Unit
Tests fail. The following patch fixes this issue.

TrivialFix
Closes-Bug: #1259292

Change-Id: I03c414a763b2d51210aaec362405912f29850e36
2016-07-12 12:29:24 +08:00
Sachi King b87e4c0824 Fix soabi tests with pypy
Change-Id: I9f20fad6487463ee85278d17bd79740ae337bfd7
2016-04-07 09:39:00 +10:00
Julien Danjou 9b5f422c34 package: fix wrong catch in email parsing
email.MessageError exception does not exist, so if an error occur, the
code block will fail completely. Fix the path to the correct class.

Co-Authored-By: Ian Cordasco <graffatcolmingov@gmail.com>
Change-Id: Ic4e69405ca6346191da66a86f0b7aa5b3b75bed6
2016-04-01 17:41:06 -05:00
Steve Kowalik b4d21581e2 Do not convert git tags when searching history
Currently, when the sem-ver processing is searching the git history,
it stores the canonical version and uses that as the tag, which is
fine if the project uses the canonical version as a tag. Instead,
return the original tag so that history can be correctly checked.

Change-Id: I1b83fc3dc3dd287ae3b23fd4cba07fdfdd673a7f
Closes-Bug: 1561254
2016-03-24 12:54:44 +11:00
Ian Cordasco 139110c89b Include wsgi_scripts in generated wheels
Downstream consumers, such as OpenStack Ansible, generate wheels for all
packages (including services). More and more services are moving to use
the wsgi_scripts entry-points provided and handled by pbr. Unfortunately,
these scripts are not generated during wheel creation unless we force
them to be generated because Setuptools and Distutils will only generate
console_scripts entry-points.

This also fixes the C extension on Python 3 because it was previously
broken.

Change-Id: Icecc8474028436e8b2fb752d576204d9439fb0e7
Closes-bug: #1542383
2016-03-22 16:44:49 -05:00
Sachi King 7898882fa5 Handle markers to support sdist on pip < 6
Old versions of pip do not properly evaluate blank envmarkers such as
':python_version>=2.7', so as long as we are not creating a bdist_wheel
we evaluate these immediately to support these old installations

Change-Id: I94a5f9bccd658a2529a727d99f5a2b79e6b00aa8
Closes-Bug: 1502692
2015-12-17 10:59:00 +11:00
Robert Collins d92f3a736e Remove redundant testscenarios glue.
discover can correctly handle packages these days, so we can load and
apply just once.

Change-Id: I8bedf6d15b0aaf3e45c2a47098ffe24240192193
2015-10-07 14:51:23 +13:00
Sachi King daa905cad4 Strip comments present in setup.cfg
When processing setup.cfg strip trailing comments from lines as this is
unsupported by setuptools.

Change-Id: I7712c07552b50830549644a6ff4167b90d897125
Closes-bug: 1494330
2015-09-14 18:26:11 +10:00
Davanum Srinivas 1e05037c2a Strip comments in requirements files
Since we don't strip comments from end of the requirements like:
requests-kerberos>=0.6;python_version=='2.7' # MIT

The currnet code ends up failing with a:
"Invalid environment marker"

We should strip the comments out before processing.

Closes-Bug: #1487835
Change-Id: I75d2e83a5f60f93e1c38d53fb4f0a29ba35120b1
2015-08-23 21:54:15 -04:00
Florian Wilhelm c3fc63c64f Fix retrieval of commit data and most recent tag.
git._iter_log_online() returns None in some cases for instance
when SKIP_WRITE_GIT_CHANGELOG is set to true. This is fixed by
returning an empty list in _iter_log_online.

Also the check if a changelog based on git should be written
was moved from git._iter_log_online to git.write_git_changelog
which makes more sense since some functions were calling
git._iter_log_online to get the changelog for other reasons than
writing it.

Additionally a unittest was added to check that setting the
environment variable SKIP_WRITE_GIT_CHANGELOG to true does not
break anything when retrieving the git version.

Change-Id: Ib12df23ab25b290dd394f9cb1456b8d5da57306a
Closes-Bug: 1467440
2015-08-03 14:44:11 +02:00
Robert Collins 89402a7177 Export ChangeLog and AUTHORS in install
readthedocs uses 'setup.py install' to prepare trees for doc creation,
but ChangeLog is not currently created there, and doing so would be
nice. This won't affect develop invocations AFAICT, and even if it
did, the overheads are ~10% of the time to run 0 tests in Nova today -
e.g. quite tolerable.

Change-Id: I7bc18fc9ca2dbe852598cc79b2ad6273fc53557d
2015-07-29 06:19:40 +12:00
Monty Taylor 61a3a1ecdf Wrap env markers in parens
If there are boolean conditions in the env marker, the existing join
causes the extra tag to only be applied to the first of them, causing
carnage.

Change-Id: I7b735befae76b330f923276e1c48ef23816774d4
2015-07-10 21:24:35 +00:00
Sachi King 1ccd6cd090 Fix test case to be runnable with gnupg 2.1
In gnupg 2.1 %no-ask-passphrase is a no-op.  As a result gpg attempts to
prompt for a passphrase and as the shell is not interactive it fails.

To allow gnupg 2.1 to create passphrase-less keys we enable two options
new to gnupg 2.1.

%no-protection
%transient-key

Change-Id: If687ff005cf968133fc1fa12b1259a127c464e5b
2015-06-05 16:39:35 +10:00
James Polley 2b29c4fc2b Teach pbr to read extras and env markers
This adds support for reading extras from setup.cfg.

It also adds support for handling environment markers, both in the
extras section and in install_requires and in requirements.txt.

Change-Id: I6fd8276012e65f82934df9c374613b1ce6856b5a
2015-05-15 21:31:21 +10:00
Robert Collins cfd8ab2dec Parallelise integration tests.
This involves moving the inner loop to python because
existing-tooling.

Change-Id: Iaad811a0248a3f700e655bd8be656d183deead93
2015-05-02 09:05:54 +12:00
Robert Collins a67e2c346c Issue #1450210: Preversioning rc tag handling
We were generating versions lower than the last tag when preversioning
was in use and pre-release versions had been tagged.

Also attempt to run the script without devstack.

Change-Id: If984939003ae7c513ee76b52c6808db0c1766050
Closes-Bug: #1450210
2015-04-30 11:26:00 +12:00