Commit Graph

137 Commits

Author SHA1 Message Date
David Dalcino
7ebd6aa34e Use sha256 hashes only from trusted mirrors
To keep this commit small, `hashurl` was removed from QtPackage, and
`get_hash` constructs the hash url based on the url of the 7z archive
to download. I think that in the future, QtArchive and QtPackage could
be refactored to construct this url more appropriately. However, this
would be a complicated change that doesn't belong in this commit.
2022-03-06 17:36:32 -08:00
Hiroshi Miura
eaf5a46e48 Merge pull request #459 from ddalcino/fix-archives-flag
Restrict effect of `--archives` flag to base and debug_info modules
2022-01-26 14:21:47 +09:00
Hiroshi Miura
9b66f03718 Accept Update.xml that use comma without space as delimiter
resolve #475

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2022-01-12 22:24:16 +09:00
David Dalcino
9c706a270c Fix implementation of --archives flag 2021-12-05 11:53:38 -08:00
David Dalcino
078154c0db refactor QtArchives base pkg name accessors
This adds an accessor function, `QtArchives._base_package_names`,
that returns a list of all possible PackageUpdate.Name properties
for the base package

This also renames `QtArchives._base_target_package_name` to
`_base_module_name`, so that its meaning is more clear in context
and not so easy to confuse with the new function.
2021-12-05 11:53:35 -08:00
David Dalcino
022373683b Allow SrcDocExamplesArchives to omit base
This change allows for the future implementation of a `--noarchives`
flag for the `install-src/doc/example` commands.
I don't know if end users will need this or not, but I need this to
determine whether or not archive filtration works properly.
This property is tested in `tests/test_archive.py` at
`test_archives_weird_module_7z_name()`.
2021-12-05 11:53:31 -08:00
David Dalcino
cfc241002d Fix suggestions for src/doc/ex missing modules 2021-11-23 12:17:03 -08:00
David Dalcino
621cd7a6c0 Fix implementation of aqt tool
This modifies `aqt tool` to allow `-` characters in tool versions, so
that `aqt tool` can pass the same unit tests that `install-tool` can.
This makes it less like the `aqt tool` from v1.2.5, but it should work
better with more tools with different version formats.
2021-10-30 19:23:35 -07:00
David Dalcino
38a125ee6b Clarify meaning and scope of all_archives
This is a code-readability improvement. Every time I read this code,
I get tripped up by the `if not all_archives:` line, and I have to hunt
for all uses of `all_archives` to see what it means and what it does.

This change moves the assignment next to its usage, so its meaning and
scope are immediately clear, and no hunting is necessary. This also
gives it a less ambiguous name.

This change will likely make the reader wonder if this variable is
needed at all; the conditional `if subarchives is not None:` would
probably work just as well. I would tend to agree.
However, I am leaving this variable in because the variable name
documents what the code is doing and why.

I recognize that the value of this change is very subjective, and I am
happy to revert this if necessary.
2021-10-20 19:53:09 -07:00
David Dalcino
46fc2aaf9f Cause --noarchives to omit the base Qt module 2021-10-20 19:32:36 -07:00
David Dalcino
c5b89f6170 fail on mismatched tool versions
This recreates the legacy behavior, where `aqt tool` would fail to
install a tool variant when the version in the xml file does not match
the version requested in cli arguments.

This also recreates a bug where `aqt tool` cannot install tools that
do not have a valid semantic version.
2021-09-30 19:15:32 -07:00
David Dalcino
8c7d50d9f0 Simplify help message 2021-09-20 13:01:50 -07:00
David Dalcino
a5bb2553ce Add improved error messages for missing archives 2021-09-20 12:46:47 -07:00
David Dalcino
1a918c35c5 Merge remote-tracking branch 'upstream/master' into specify-version-by-simplespec 2021-09-09 08:26:10 -07:00
David Dalcino
5a1aedb480 Add functions to determine extensions
This moves the logic for determining extensions out of the QtArchive
class so that it is available elsewhere and does not need to be
duplicated.
2021-09-07 14:27:51 -07:00
David Dalcino
88c30d90d0 Raise exceptions from existing exceptions 2021-09-02 09:57:34 -07:00
David Dalcino
7fa9dff9ea Don't duplicate error messages in QtArchives 2021-09-01 12:37:54 -07:00
David Dalcino
c9c1388027 Merge remote-tracking branch 'upstream/master' into fail-on-missing-modules
# Conflicts:
#	aqt/archives.py
#	tests/test_archives.py
2021-08-25 09:49:59 -07:00
David Dalcino
e1c7bd0c1b Cause ToolArchive failure when variant is missing
This allows test_tools_variants to pass.
2021-08-24 10:10:31 -07:00
David Dalcino
ba86bbbb48 Allow empty version string
The interface for ToolArchives says that `version_str` is optional,
but when you try to use it with the default value, the QtArchives
constructor raises a ValueError exception. This change substitutes
the dummy value used by the Cli.run_install_tool for version_str, when
version_str is empty.
2021-08-24 10:06:07 -07:00
David Dalcino
9b29055797 Implement check for missing modules 2021-08-23 10:57:27 -07:00
David Dalcino
499fdb020f Use posixpath.join to compose urls
This makes sure that all urls composed in QtArchive are put together
properly, using posixpath.join. #287 did this in a few places, but not
all.
2021-08-23 10:57:25 -07:00
David Dalcino
847bd420a3 Add type hints to QtArchives
This is meant to make the QtArchives class more readable, so the types
of each data member are absolutely clear.
2021-08-23 10:57:24 -07:00
David Dalcino
5fa7d22cbe Add name of PackageUpdate to QtPackage
This adds the "Name" property from the "PackageUpdate" element from
"Updates.xml" to the QtPackage objects. This is intended to make
testing easier: if the "Name" property is missing, there's no way to
find out which PackageUpdate the 7z archive came from after it has
been added to the QtArchive.

In the case of ToolArchive contents, the `QtPackage.pkg_update_name`
is redundant, because the "Name" property is already saved as
`QtPackage.name`. The `QtPackage.name` property is being used in two
different ways in two different places, probably because of different
naming conventions.
2021-08-23 10:57:22 -07:00
David Dalcino
c7993c1031 Make addons. prefix optional for Qt6+ 2021-08-17 15:22:45 -07:00
David Dalcino
a0e002de75 Allow QtArchives to recognize Qt 5.9.0 2021-08-11 11:29:09 -07:00
Hiroshi Miura
c99ec5372b Coding style update by Black/isort
Change to max line length to 125

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-08-02 13:50:00 +09:00
Hiroshi Miura
0c346d77c8 Merge branch 'master' into topic-tool-latest 2021-07-15 14:10:09 +09:00
Hiroshi Miura
0d7c3eecb8 Merge pull request #316 from miurahr/patch-refactoring-installer
Refactoring call_instaler/installer
2021-07-15 09:49:10 +09:00
Hiroshi Miura
62d8ed3b55 Rename to get_packages
- It is problematic name that QtArchive.get_archives returns List[QtPackage]

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-15 09:32:26 +09:00
Hiroshi Miura
f1b8b5a2c3 Refactoring call_instaler/installer
- Introduce `run_installer` that consume `List[QtArchives]` data
  to be same structure as `show_list` and `ToolData` data class.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-15 08:33:50 +09:00
Hiroshi Miura
1721a21390 Drop unused class
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-15 08:32:04 +09:00
Hiroshi Miura
ab823596dc Utilize dataclasses (#313)
* Utilize dataclasses

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* PEP8

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-15 08:08:53 +09:00
Hiroshi Miura
a5bb6b7e96 Introduce metadata package (#305)
* Introduce metadata module

that has Versions and ListCommand class

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Introduce custom Version class

A Version class override semantic_version.Version class
that accept qt versions and tools versions

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* PEP8/Black

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Improve test assertion

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Move ArchiveId class to metadata module

And Improve imports

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Refactoring Version class

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Refactoring Table class

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Refactoring Table class(wip)

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix output format of `list tools` command

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* list: Improve print output

avoid str.join()

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-13 00:10:36 +09:00
Hiroshi Miura
534bfc6add Make ListCommand iterable
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-11 11:06:48 +09:00
Hiroshi Miura
9cb3e880ae wip: fix error
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-11 10:42:27 +09:00
Hiroshi Miura
3d9ef1ac6b Update dummy version handling
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-11 10:29:29 +09:00
David Dalcino
10d4ec02d5 Add tool-long-listing to ListCommand
This change adds the ability to list all the 'tool variant names'
alongside the version and release date of the tool.

When using the `aqt list tools` feature, I often find that I need more
information than the tool provides. I often need to know the release
date and the version for each tool, and I can't get that information
without looking up the Updates.xml file. This feature enables me to skip
that part.
2021-07-09 19:05:08 -07:00
Hiroshi Miura
358687d7e5 Merge branch 'master' into topic-tool-latest 2021-07-10 09:29:22 +09:00
David Dalcino
7a2e7faf53 Allow ListCommand to choose tool by version
This adds the function `ListCommand.fetch_tool_by_simple_spec`. This
allows the caller to specify a SimpleSpec and the name of a tool, and
the function will return the Updates.xml record for the specified tool
with the largest version number that satisfies the SimpleSpec. This is
meant to allow users to install tools without specifying an explicit
version number.

This also adds some test code to validate the complicated parts of this
code.

This also extends `helper.xml_to_modules`, so that a caller can
automatically get all tags in an XML element without explicitly
specifying them.
2021-07-09 17:02:50 -07:00
Hiroshi Miura
e8b849fa58 Drop duplicated members 2021-07-10 01:02:35 +09:00
Hiroshi Miura
905d9c2f5f wip
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-10 00:59:01 +09:00
Hiroshi Miura
62c7075aeb Accept target argument 2021-07-09 23:53:41 +09:00
David Dalcino
eb9908d4a8 Fix ToolArchives.__str__()
This change prevents an AttributeError from being raised when `ToolArchive.__str__()` is called.

Neither `ToolArchives` nor the parent class `QtArchives` contains the data member `version_str`, yet it is referenced in the `__str__` method. This change replaces it with the correct data member, `QtArchives.version`.
2021-07-07 17:51:45 -07:00
David Dalcino
860d297b2d Validate version strings more consistently 2021-07-06 12:16:58 -07:00
Hiroshi Miura
f007ad8e7b Quick hack to install latest version of tool
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-06 18:15:21 +09:00
Julien Marrec
91f33da898 Minor changes: use posixpath.join, add __repr__/__str__, some type hints, and some mypy issues (#287)
* Avoid calling functions with positional args: use names in case you reorder, Some type hints + __repr__ and __str__

* Use posixpath.join

* mypy issue: logger is sometimes passed.

* mypy: rename the Settings class to SettingsClass

```
aqt/helper.py:333: error: Cannot assign to a type
aqt/helper.py:333: error: Incompatible types in assignment (expression has type "Settings", variable has type "Type[Settings]")
```

* Reduce indenting by avoiding unnecessary except.else

* more calling by named arguments
2021-07-06 12:13:35 +09:00
David Dalcino
705c6225e2 Add capability to list tools (#235)
* Add html scraping capability to helper.py

The function scrape_html_for_folders() reads an html file at
`https://download.qt.io/online/qtsdkrepository/<os>/<target>/` and
extracts a list of all the folders within that directory.
It separates the folders by category, so that 'tools' are not
mixed in with 'qt5' or 'qt6'.

This commit also adds a function that prints the available folders,
allowing the caller to filter the output by category.

* Add interface for accessing scrape_html_for_folders

I'm sure this isn't exactly what is needed, and that this functionality
should probably be folded into `aqt list`, but it does demonstrate that
aqt can list all the tools available at downloads.qt.io by scraping html.

This allows you to type `aqt list2 tools linux desktop`, and get a list
of all the tools on the server.
There are more options; type `aqt list2 -h` to see them all.

* Add failing tests for `aqt list`

* Add passing implementation of `aqt list`

* Remove old implementation of `aqt list`

This removes `Cli.run_list_old`, as well as any commented-out code in
installer.py that was related to the old implementation of `run_list`.

This also restores some code that was commented out erroneously.

* Fix misuse of semantic_version

In an earlier commit, I used the parameter `partial=True` for the
preview builds of Qt, since they do not include a patch number. I did
not recognize this as a misuse of semantic_version until I ran the tox
linter. `partial` is meant for 'partial specification', as in, 'this
program requires version 6.2, and the patch is unimportant`.

This change removes the `partial=True` parameter, adds a `0` for the
patch number, and uses a format string to print preview versions without
the patch.

* Use semantic version in interfaces instead of str

This updates all functions that accept a Qt version as a string, so that
they now accept a semantic version object instead. This forces the
caller to do some input validation, and moves the responsibility of
string-to-version conversions out of functions where it does not belong.

* Improve `aqt list` interface as discussed

This adds several new options to `aqt list`, and renames the ambiguous
`packages` to `modules`. New options include the ability to list
targets, extensions, and architectures for a particular (host, target,
Qt version) tuple. The goal is to provide sufficient information to the
user, such that the user can use all the other features of aqt without
having to look them up somewhere else.

* Cleanup `targets` dictionary

* Add `list architectures` feature

* Add tests for `list architectures` feature

* Add documentation for new list feature.

* Fix url bugs related to BASE_URL change

* Add stub for `list --extensions`

* Implement `list --extensions`

* Cleanup imports

* Add basic tests of `aqt list` to azure pipeline

* Fix failed merge with upstream

* Simplify string-to-version code

An earlier commit introduced `cli_2_semantic_version`, which calls
`get_semantic_version_with_dots`, which will never be called by any
other code. I think that this should really just be one function, and
splitting it in two is just needlessly complex.

* Revert dd41e653 - changes to azure-pipelines.yml

* CI: change test case for list command

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Update MANIFEST

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix errors reported by flake8

This commit fixes some unused imports, missing imports, and formatting
errors.

* Run isort

* Add three more build jobs to azure pipelines

This adds three more combinations of `qt version/host/target` to the
`aqt list` command tests on the azure pipelines. This is pretty far from
exhaustive, but I think it's worth it to add these: they execute
slightly different code paths than the standard `linux/desktop`
variants. I don't want to add a whole lot more than this; `aqt list` is
slower than I'd like it to be, and I don't want to waste CI time.

* Fix bug where empty extensions returns success

Prior to this commit, if you ran `aqt list` to list possible extensions,
it could print a blank line and return 0. This is because the
get_extensions_for_version function was accepting empty strings as a
valid extension, and returning a list consisting of one empty string.
This commit filters out those empty strings.

* Attempt to fix ci bug when listing android exts

Android extensions for Qt6 follow different rules than Qt5; this
attempts to account for that.

* remove invalid ArchiveId objects from tests

* Add author

* Use Python for test logic instead of bash

* Remove 'build accelbubble' step from 'list' test

This commit attempts to separate the 'build accelbubble example' test
from the 'aqt list' test.

In this case, the test for `aqt list qt5 linux android` was running the
"build accelbubble example" test in addition to the intended test. If
the "build accelbubble example" test fails, then it looks like the `aqt
list` test failed, until you look to see why it failed.

* Remove dead code

* Accept `latest` keyword instead of qt version

This commit modifies the interface of `aqt list`, so that the flags
`--modules`, `--extensions`, and `--arch` will accept either a Qt
version or the word `latest`. If the user specifies a version of Qt,
the command works as before. If the user specifies `--modules latest`,
`aqt list` will determine the latest version of Qt, given the filters
specified, and return the modules for that version.

This commit removes the flag `--latest-modules`, because that flag is no
longer necessary. The `latest` keyword serves the same function, and it
works for the `--extensions`, and `--arch` flags as well. This prevents
the need for flags such as `--latest-extensions` and `--latest-arch`,
which otherwise would have been necessary to provide this functionality
to the other list features.

* remove unused import

* Update azure pipeline to reflect `latest` feature

* WIP refactor helper methods into ListCommand

* Refactor helper methods into ListCommand

This PR adds many helper methods to helper.py that are closely related
to each other, and which are only useful to the ListCommand object. This
commit moves the majority of these into the ListCommand object, so that
they don't confuse future readers who are looking for something else.

* Fix imports after merge

* Fix unused import

* Add test and impl for list tool modules

This adds code that parses an 'Updates.xml' file for the names of tool
modules, which a user can use to install tools. This does not have any
cli-facing code yet, since the current interface does not make sense for
this purpose.

* Add CLI command to list tool variant names

This exposes `ListCommand.fetch_tool_modules` to the CLI.
Accordingly, it adds a test to the Azure Pipelines for every `aqt list`
job, and it adds documentation to docs/cli.rst.

Since this feature is meant to print values you can feed into the `aqt
tool` command, the documentation for the `aqt tool` command was changed
as well.

* Use monkeypatch for http_fetcher

This removes the http_fetcher parameter for ListCommand in favor of
monkeypatching.

* Remove dataclasses

Dataclasses were new in Python 3.7, and don't exist in the minimum
supported Python 3.6.

* black

* Fix ci test for `aqt list tools --tool`

* Add default timeout to request_http_with_failover

* fix monkeypatched http fetcher

* Fix 'aqt list tools' command on Azure Pipeline

Currently, the `tools_qt3dstudio_runtime_240` appears to be the only
tool available on all host/target combinations, so we will check that
one in Azure Pipelines.

* Move helper classes specific to ListCommand into ListCommand

* Fix use of new global Settings object

* Fix sphinx docstring syntax

* Swap `request_http_with_failover` for `getUrl`

* Add additional follow-up suggestion on error

* Fix exceptions import

* Prevent repeated 'suggested follow up' actions

This change uses exclusive branches to prevent `aqt list` from repeating
the same/similar recommended actions.

* Fix bugs related to updated getUrl error messages

* run black

* docs: add auto section link label extension

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* docs: add more list command examples

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix typo in docs

* remove duplicate `semantic_version`

* Add expected outputs and arch example to docs

This change adds some expected output to the documentation. For any
user who is confused about what the documentation means when it
mentions `tools` and `modules`, and is unsure which is which, this
change should help that user figure that out.

This also adds an example for listing architectures.

* Remove `logger` from `getUrl` parameter list

* helper: getLogger("aqt.helper") in helper functions

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Use `pretty_print` instead of `str()` for output

* test_list.py use pretty_print instead of str

* fix Versions constructor

* black

Co-authored-by: Hiroshi Miura <miurahr@linux.com>
2021-07-06 07:58:18 +09:00
Julien Marrec
4069b623e1 Hotfix #281 2021-06-29 22:00:29 +02:00
Julien Marrec
a277ecf4a1 Fix #280 - wrong base path in run_list 2021-06-25 14:00:04 +02:00