CN111045701A - Version switching method and device and version switching device - Google Patents

Version switching method and device and version switching device Download PDF

Info

Publication number
CN111045701A
CN111045701A CN201910625768.0A CN201910625768A CN111045701A CN 111045701 A CN111045701 A CN 111045701A CN 201910625768 A CN201910625768 A CN 201910625768A CN 111045701 A CN111045701 A CN 111045701A
Authority
CN
China
Prior art keywords
version
python
bazel
environment
path
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910625768.0A
Other languages
Chinese (zh)
Other versions
CN111045701B (en
Inventor
陈璐
王一帆
李艺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huakong Tsingjiao Information Technology Beijing Co Ltd
Original Assignee
Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huakong Tsingjiao Information Technology Beijing Co Ltd filed Critical Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority to CN201910625768.0A priority Critical patent/CN111045701B/en
Publication of CN111045701A publication Critical patent/CN111045701A/en
Application granted granted Critical
Publication of CN111045701B publication Critical patent/CN111045701B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44536Selecting among different versions

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The embodiment of the invention provides a version switching method and device and a version switching device. The method comprises the following steps: traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version; deleting the first version of the dependent library file cached in the Bazel environment; updating the default Python version of the Bazel environment from the first version to the second version. The embodiment of the invention can reduce the development cost of the Python project and improve the upgrading efficiency of the Python version.

Description

Version switching method and device and version switching device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for switching versions, and an apparatus for switching versions.
Background
Bazel is a building tool, i.e. a tool that can run compilation and testing to assemble software, can support multiple development languages, such as Java, C + +, Python, etc., and can be built for different platforms.
In a specific application, there may be multiple versions of a development language, for example, for Python language, the currently more common versions include Python2.7 and Python 3.6. The Python project constructed under the Bazel compilation framework sometimes needs to be upgraded to Python3.6 version of the Python project developed using the Python2.7 version due to business requirements.
However, because the syntax difference between the two versions of Python2.7 and Python3.6 is large, it is difficult to directly switch the versions, but if the Python project is reconstructed using the language of the Python3.6 version, the development cost is high, and the version upgrade efficiency is low.
Disclosure of Invention
Embodiments of the present invention provide a version switching method and apparatus, and an apparatus for switching versions, which can reduce the development cost of a Python project and improve the upgrade efficiency of a Python version.
In order to solve the above problem, an embodiment of the present invention discloses a version switching method, where the method includes:
traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version;
deleting the first version of the dependent library file cached in the Bazel environment;
updating the default Python version of the Bazel environment from the first version to the second version.
On the other hand, the embodiment of the invention discloses a version switching device, which comprises:
the syntax modification module is used for traversing a root directory of a Python item to be switched in a Bazel environment, and modifying the Python syntax of a first version in all Python item files under the root directory into the Python syntax of a second version;
the dependence deleting module is used for deleting the dependence library file of the first version cached in the Bazel environment;
a version update module for updating the default Python version of the Bazel environment from the first version to the second version.
In yet another aspect, an embodiment of the present invention discloses an apparatus for version switching, including a memory, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs including instructions for:
traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version;
deleting the first version of the dependent library file cached in the Bazel environment;
updating the default Python version of the Bazel environment from the first version to the second version.
In yet another aspect, an embodiment of the present invention discloses a machine-readable medium having stored thereon instructions, which, when executed by one or more processors, cause an apparatus to perform a version switching method as described in one or more of the preceding.
The embodiment of the invention has the following advantages:
according to the embodiment of the invention, through traversing the root directory of the Python item to be switched in the Bazel environment, the Python grammar of the first version in all the Python item files in the root directory is modified into the Python grammar of the second version, the dependent library file of the first version cached in the Bazel environment is deleted, and the default Python version of the Bazel environment is updated from the first version to the second version, so that the Python language version of the Python item can be automatically switched in one key mode in the Bazel environment, the redevelopment cost can be reduced, and the upgrading efficiency of the Python version can be improved. In addition, the embodiment of the invention can also avoid the occurrence of program error report caused by the fact that the version of the dependent library is not adaptive after the Python version is switched.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a flowchart illustrating the steps of an embodiment of a version switching method of the present invention;
FIG. 2 is a block diagram of a version switching apparatus according to an embodiment of the present invention;
FIG. 3 is a block diagram of an apparatus 800 for version switching of the present invention; and
fig. 4 is a schematic diagram of a server in some embodiments of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Method embodiment
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a version switching method according to the present invention is shown, which may specifically include the following steps:
step 101, traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version;
102, deleting the first version of the dependent library file cached in the Bazel environment;
step 103, updating the default Python version of the Bazel environment from the first version to the second version.
The embodiment of the invention can be used for automatically switching the Python language version of the Python project in the Bazel environment. For example, the Python project developed by the Python2.7 language version can be automatically switched to the Python3.6 language version, so that the cost of redevelopment can be reduced.
In a specific application, because there is a difference in syntax between Python languages of different versions, in the process of switching the Python versions, the embodiment of the present invention first modifies the syntax of the Python item to be switched, and specifically, in a Bazel environment, the root directory of the Python item to be switched may be traversed in the item managed by the Bazel environment, and the Python syntax of the first version in all Python item files in the root directory is modified into the Python syntax of the second version. Wherein, the first version refers to the current version (such as Python2.7) before the version switching is performed, and the second version refers to the target version (such as Python3.6) for the version switching.
In the embodiment of the present invention, in order to improve the efficiency and accuracy of syntax modification, a Python syntax transformation tool may be used to modify the first version of Python syntax in the Python project file into the second version of Python syntax. For example, taking the first version as Python2.7 and the second version as Python3.6 as examples, a 2to3Python syntax transformation tool may be used for syntax transformation, specifically, the Python item file of the Python2.7 version may be used as an input of the 2to3Python syntax transformation tool, and the output is the Python item file of the Python3.6 version.
In a specific application, the Bazel environment adds relevant dependencies in the project WORKSPACE WORKSPACE, and downloads corresponding dependent library files according to the Python version currently used by the Bazel environment. However, in a Bazel environment, only when a Python project is constructed, the dependent library file is downloaded and stored in the cache (cache), and when the Python project is compiled or run each time later, the dependent library file in the cache is directly used as long as the dependent library file is checked to be downloaded in the cache. Due to the above dependent library caching mechanism of the Bazel environment, after the syntax of the Python item to be switched is converted from the first version to the second version, the dependent library file corresponding to the first version, which is downloaded when the Python item to be switched is constructed, is still stored in the cache, so that in the process of running the Python item in the Bazel environment, the situation that the version of the dependent library is not adapted, which may cause a program error may occur.
In order to solve the problem of the non-adaptation of the dependent library version, in the embodiment of the present invention, after the syntax modification is completed, the dependent library file of the first version cached in the Bazel environment is automatically deleted, and the default Python version of the Bazel environment is updated from the first version to the second version.
In an optional embodiment of the present invention, the deleting the first version of the dependent library file cached in the Bazel environment may specifically include:
step S11, in the Bazel environment, inquiring the cache path of the first version of the dependent library file in the Bazel environment;
step S12, emptying the cache file under the cache path, where the cache file includes: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
In order to delete the first version of the dependent library file cached in the Bazel environment, so that the Bazel environment can download the second version of the dependent library file, in the embodiment of the present invention, in the Bazel environment, a cache path of the first version of the dependent library file is queried, taking an operating system where the Bazel environment is located as an ubuntu operating system as an example, assuming that a cache path of the first version of the dependent library file in the Bazel environment is: if yes, then emptying the cache file under the cache path, wherein the cache file under the cache path specifically comprises: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
It is understood that the ubuntu os is only an application example of the present invention, and the type of the operating system in which the Bazel environment is located is not limited in the embodiment of the present invention, and may also include windows, MacOSX, and other operating systems.
Specifically, in the embodiment of the present invention, under the root directory { root _ dir } of the Python item to be switched, a "base info" instruction may be executed, so as to obtain the cache path { base _ cache _ library }: output _ base }/external of the dependent library file of the first version under the current Bazel environment. All cache files in the { bank _ cache _ library } directory may be cleared by executing the clear instruction "rm-r { bank _ cache _ library }".
In an alternative embodiment of the present invention, at least two different versions of Python language files are stored in the Bazel environment. For example, in the Bazel environment, a Python language file of the Python2.7 version, a Python language file of the Python3.6 version, a Python language file of the Python4.x version, and the like may be installed, and a default Python version of the Bazel environment may be set, for example, the default Python version of the Bazel environment is set to Python2.7, and the Bazel environment compiles the Python item according to the syntax rule of the Python2.7 version.
Specifically, Python language files of different versions can be installed in different paths, and a default Python version of the Bazel environment can be set by setting a Python language file path corresponding to the default Python version of the operating system in which the Bazel environment is located.
In an optional embodiment of the present invention, the updating the default Python version of the Bazel environment from the first version to the second version may specifically include:
step S21, in the Bazel environment, inquiring a first path for storing a first version of Python language file and a second path for storing a second version of Python language file;
step S22, setting the default Python version of the Bazel environment to point to the second path, where the priority of the second path is higher than the priority of the first path.
Specifically, in a Bazel environment, by executing the "while Python" instruction, the first path { Python _ path } storing the first version of Python language file may be queried, and executing the "while Python 3" instruction, the second path { Python3_ path } storing the second version of Python language file may be queried.
Assuming that the default Python version of the current Bazel environment points to the first path, the embodiment of the present invention may update the default Python version of the Bazel environment from the first version to the second version by setting the default path of the default Python version of the Bazel environment to point to the second path and setting the priority of the second path { Python3_ path } to be higher than the priority of the first path { Python _ path }. For example, by executing the "update-alternates- -install { Python _ path } { Python2_ path } 1" and "update-alternates- -install { Python _ path } { Python3_ path } 2" instructions, it is possible to set the priority of the Bazel environment to point to the second path higher than the priority to point to the first path, where the priority of the first path { Python2_ path } is 1, the priority of the second path { Python3_ path } is 2, and the Bazel environment will use the Python version with the higher priority, i.e., the second version of the { Python3_ path } path.
In an optional embodiment of the invention, after updating the default Python version of the Bazel environment from the first version to the second version, the method may further comprise:
step S31, checking whether a dependent library file exists in the cache of the Bazel environment;
and step S32, if the dependent library file does not exist in the cache, downloading the dependent library file corresponding to the default Python version according to the default Python version of the Bazel environment.
After the dependent library file of the first version cached in the Bazel environment is cleared, because the fact that the dependent library file does not exist in the cache of the Bazel environment is checked, the dependent library file corresponding to the default Python version can be downloaded according to the default Python version of the Bazel environment, and because the default Python version of the Bazel environment is updated to the second version from the first version, the dependent library file corresponding to the second version can be automatically downloaded by the Bazel environment, so that the version of the dependent library file is automatically adapted after the version is switched, and the situation that a program is not adapted due to the dependent library version and has error is avoided.
Optionally, in the embodiment of the present invention, each step in the version switching process may be automatically executed by a script program, so as to simplify the operation process of the version switching. For example, a script program according to an embodiment of the present invention may specifically be as follows:
update-alternatives--install`which python``which python2`1
update-alternatives--install`which python``which python3`2
cd{root_dir}
2to3./-w–n
output_base=$(bazel info|grep'output_base')
rm-r${output_base#:}
wherein the "update-indicators- -install 'while Python' while Python2 '1' update-indicators- -install 'while Python' while Python3 '2' instruction is used to update the default Python version 'while Python' of Bazel environment from the current first version 'while Python 2' to the second version 'while Python 3'. The "cd { root _ dir }" instruction is used for querying the root directory of the Python item to be switched currently. The "2 to 3./-w-n" instruction is used to modify the Python syntax of all Python item files under the root directory { root _ dir } from a first version to a second version. The "output _ base ═ instruction is used for querying a cache path of the first version of the dependent library file in the Bazel environment, and the" rm-r $ { output _ base #: } "instruction is used for emptying the cache file under the cache path, including constructing an intermediate file generated by the Python project to be converted and the first version of the dependent library file.
In a specific application, the script program is executed under the root directory of the Python item to be switched, so that the Python version switching of the Python item to be switched can be realized. It should be understood that the above description uses python2.7 as the first version and python3.6 as the second version, which is only an application example of the present invention, and the embodiments of the present invention do not limit the first version and the second version. In addition, the second version may be higher than the first version or lower than the first version, for example, the Python item of the Python3.6 version may be switched to the Python2.7 version in the embodiment of the present invention. In addition, the embodiment of the present invention does not limit the execution sequence of each instruction in the script program, for example, the syntax may be modified first and then the dependent library file is removed, or the syntax may be modified first and then the dependent library file is removed.
To sum up, in the embodiment of the present invention, by traversing the root directory of the Python item to be switched in the Bazel environment, modifying the Python syntax of the first version in all the Python item files in the root directory into the Python syntax of the second version, deleting the dependent library file of the first version cached in the Bazel environment, and updating the default Python version of the Bazel environment from the first version to the second version, it is possible to implement one-click automatic switching of the Python language versions of the Python items in the Bazel environment, which not only can reduce the cost of redevelopment, but also can improve the upgrade efficiency of the Python versions. In addition, the embodiment of the invention can also avoid the occurrence of program error report caused by the fact that the version of the dependent library is not adaptive after the Python version is switched.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Device embodiment
Referring to fig. 2, a block diagram of a version switching apparatus according to an embodiment of the present invention is shown, where the apparatus may specifically include:
a syntax modification module 201, configured to traverse a root directory of a Python item to be switched in a Bazel environment, and modify a Python syntax of a first version in all Python item files in the root directory into a Python syntax of a second version;
a dependency deletion module 202, configured to delete the first version of the dependent library file cached in the Bazel environment;
a version update module 203, configured to update the default Python version of the Bazel environment from the first version to the second version.
Optionally, the dependency deletion module 202 may specifically include:
the first query submodule is used for querying a cache path of the first version of the dependent library file in the Bazel environment;
a cache emptying submodule, configured to empty the cache file in the cache path, where the cache file includes: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
Optionally, the version updating module 203 may specifically include:
a second query submodule, configured to query, in the Bazel environment, a first path storing a first version of a Python language file and a second path storing a second version of the Python language file;
and the path updating submodule is used for setting the default Python version of the Bazel environment to point to the second path, and the priority of the second path is higher than that of the first path.
Optionally, the apparatus may further include:
the dependency query module is used for checking whether a dependency library file exists in the cache of the Bazel environment;
and the dependent downloading module is used for downloading the dependent library file corresponding to the default Python version according to the default Python version of the Bazel environment if the dependent library file does not exist in the cache.
Optionally, at least two different versions of Python language files are stored in the Bazel environment.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
An embodiment of the present invention provides an apparatus for version switching, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by one or more processors include instructions for: traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version; deleting the first version of the dependent library file cached in the Bazel environment; updating the default Python version of the Bazel environment from the first version to the second version.
Fig. 3 is a block diagram illustrating an apparatus 800 for version switching according to an example embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 3, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice information processing mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Fig. 4 is a schematic diagram of a server in some embodiments of the invention. The server 1900, which may vary widely in configuration or performance, may include one or more Central Processing Units (CPUs) 1922 (e.g., one or more processors) and memory 1932, one or more storage media 1930 (e.g., one or more mass storage devices) storing applications 1942 or data 1944. Memory 1932 and storage medium 1930 can be, among other things, transient or persistent storage. The program stored in the storage medium 1930 may include one or more modules (not shown), each of which may include a series of instructions operating on a server. Still further, a central processor 1922 may be provided in communication with the storage medium 1930 to execute a series of instruction operations in the storage medium 1930 on the server 1900.
The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input-output interfaces 1958, one or more keyboards 1956, and/or one or more operating systems 1941, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform the version switching method shown in fig. 1.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform a version switching method, the method comprising: traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version; deleting the first version of the dependent library file cached in the Bazel environment; updating the default Python version of the Bazel environment from the first version to the second version.
The embodiment of the invention discloses A1 and a version switching method, which comprises the following steps:
traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version;
deleting the first version of the dependent library file cached in the Bazel environment;
updating the default Python version of the Bazel environment from the first version to the second version.
A2, the deleting the first version of the dependent library file cached in the Bazel environment according to the method of A1, comprising:
in the Bazel environment, inquiring the cache path of the first version of the dependent library file in the Bazel environment;
clearing the cache file under the cache path, wherein the cache file comprises: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
A3, the updating the default Python version of the Bazel environment from the first version to the second version according to the method of A1, comprising:
in the Bazel environment, inquiring a first path for storing a first version of Python language file and a second path for storing a second version of Python language file;
and setting the default Python version of the Bazel environment to point to the second path, wherein the priority of the second path is higher than that of the first path.
A4, according to the method of A1, after updating the default Python version of the Bazel environment from the first version to the second version, the method further comprising:
checking whether a dependent library file exists in a cache of the Bazel environment;
and if the dependent library file does not exist in the cache, downloading the dependent library file corresponding to the default Python version according to the default Python version of the Bazel environment.
A5, storing at least two different versions of Python language files in the Bazel environment according to the method of any one of a1 to a 4.
The embodiment of the invention discloses B6 and a version switching device, which comprises:
the syntax modification module is used for traversing a root directory of a Python item to be switched in a Bazel environment, and modifying the Python syntax of a first version in all Python item files under the root directory into the Python syntax of a second version;
the dependence deleting module is used for deleting the dependence library file of the first version cached in the Bazel environment;
a version update module for updating the default Python version of the Bazel environment from the first version to the second version.
B7, the apparatus of B6, the dependency deletion module comprising:
the first query submodule is used for querying a cache path of the first version of the dependent library file in the Bazel environment;
a cache emptying submodule, configured to empty the cache file in the cache path, where the cache file includes: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
B8, the apparatus of B6, the version update module comprising:
a second query submodule, configured to query, in the Bazel environment, a first path storing a first version of a Python language file and a second path storing a second version of the Python language file;
and the path updating submodule is used for setting the default Python version of the Bazel environment to point to the second path, and the priority of the second path is higher than that of the first path.
B9, the apparatus of B6, the apparatus further comprising:
the dependency query module is used for checking whether a dependency library file exists in the cache of the Bazel environment;
and the dependent downloading module is used for downloading the dependent library file corresponding to the default Python version according to the default Python version of the Bazel environment if the dependent library file does not exist in the cache.
B10, the apparatus according to any one of B6 to B9, wherein at least two different versions of Python language files are stored in the Bazel environment.
The embodiment of the invention discloses C11, a device for version switching, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by the one or more processors comprise instructions for:
traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version;
deleting the first version of the dependent library file cached in the Bazel environment;
updating the default Python version of the Bazel environment from the first version to the second version.
C12, the apparatus of C11, the deleting the first version of the dependent library file cached in the Bazel environment, comprising:
in the Bazel environment, inquiring the cache path of the first version of the dependent library file in the Bazel environment;
clearing the cache file under the cache path, wherein the cache file comprises: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
C13, the updating the default Python version of the Bazel environment from the first version to the second version according to the apparatus of C11, comprising:
in the Bazel environment, inquiring a first path for storing a first version of Python language file and a second path for storing a second version of Python language file;
and setting the default Python version of the Bazel environment to point to the second path, wherein the priority of the second path is higher than that of the first path.
C14, the device of C11, the device also configured to execute the one or more programs by one or more processors including instructions for:
checking whether a dependent library file exists in a cache of the Bazel environment;
and if the dependent library file does not exist in the cache, downloading the dependent library file corresponding to the default Python version according to the default Python version of the Bazel environment.
C15, the apparatus according to any one of C11 to C14, wherein at least two different versions of Python language files are stored in the Bazel environment.
Embodiments of the present invention disclose D16, a machine-readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a version switching method as described in one or more of a 1-a 5.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
The foregoing describes in detail a version switching method, a version switching device, and a device for switching versions provided by the present invention, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the descriptions of the foregoing examples are only used to help understand the method and the core ideas of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method of version switching, the method comprising:
traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version;
deleting the first version of the dependent library file cached in the Bazel environment;
updating the default Python version of the Bazel environment from the first version to the second version.
2. The method of claim 1, wherein the deleting the first version of the dependent library file cached in the Bazel environment comprises:
in the Bazel environment, inquiring the cache path of the first version of the dependent library file in the Bazel environment;
clearing the cache file under the cache path, wherein the cache file comprises: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
3. The method of claim 1, wherein the updating the default Python version of the Bazel environment from the first version to the second version comprises:
in the Bazel environment, inquiring a first path for storing a first version of Python language file and a second path for storing a second version of Python language file;
and setting the default Python version of the Bazel environment to point to the second path, wherein the priority of the second path is higher than that of the first path.
4. The method of claim 1, wherein after updating the default Python version of the Bazel environment from the first version to the second version, the method further comprises:
checking whether a dependent library file exists in a cache of the Bazel environment;
and if the dependent library file does not exist in the cache, downloading the dependent library file corresponding to the default Python version according to the default Python version of the Bazel environment.
5. The method according to any one of claims 1 to 4, wherein at least two different versions of Python language files are stored in the Bazel environment.
6. A version switching apparatus, characterized in that the apparatus comprises:
the syntax modification module is used for traversing a root directory of a Python item to be switched in a Bazel environment, and modifying the Python syntax of a first version in all Python item files under the root directory into the Python syntax of a second version;
the dependence deleting module is used for deleting the dependence library file of the first version cached in the Bazel environment;
a version update module for updating the default Python version of the Bazel environment from the first version to the second version.
7. The apparatus of claim 6, wherein the dependency deletion module comprises:
the first query submodule is used for querying a cache path of the first version of the dependent library file in the Bazel environment;
a cache emptying submodule, configured to empty the cache file in the cache path, where the cache file includes: and constructing an intermediate file generated by the Python project to be switched and the dependent library file of the first version.
8. The apparatus of claim 6, wherein the version update module comprises:
a second query submodule, configured to query, in the Bazel environment, a first path storing a first version of a Python language file and a second path storing a second version of the Python language file;
and the path updating submodule is used for setting the default Python version of the Bazel environment to point to the second path, and the priority of the second path is higher than that of the first path.
9. An apparatus for version switching, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs comprising instructions for:
traversing a root directory of a Python item to be switched in a Bazel environment, and modifying Python syntax of a first version in all Python item files under the root directory into Python syntax of a second version;
deleting the first version of the dependent library file cached in the Bazel environment;
updating the default Python version of the Bazel environment from the first version to the second version.
10. A machine-readable medium having stored thereon instructions, which when executed by one or more processors, cause an apparatus to perform the version switching method as claimed in one or more of claims 1 to 5.
CN201910625768.0A 2019-07-11 2019-07-11 Version switching method and device for version switching Active CN111045701B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910625768.0A CN111045701B (en) 2019-07-11 2019-07-11 Version switching method and device for version switching

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910625768.0A CN111045701B (en) 2019-07-11 2019-07-11 Version switching method and device for version switching

Publications (2)

Publication Number Publication Date
CN111045701A true CN111045701A (en) 2020-04-21
CN111045701B CN111045701B (en) 2024-06-11

Family

ID=70231691

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910625768.0A Active CN111045701B (en) 2019-07-11 2019-07-11 Version switching method and device for version switching

Country Status (1)

Country Link
CN (1) CN111045701B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111930411A (en) * 2020-09-30 2020-11-13 腾讯科技(深圳)有限公司 Code upgrading method and device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130104115A1 (en) * 2011-10-21 2013-04-25 International Business Machines Corporation Systems and methods for upgrading a version of software
CN108197633A (en) * 2017-11-24 2018-06-22 百年金海科技有限公司 Deep learning image classification based on TensorFlow is with applying dispositions method
CN109634840A (en) * 2018-10-25 2019-04-16 平安科技(深圳)有限公司 Method for testing software, device, equipment and storage medium
CN109670299A (en) * 2018-12-29 2019-04-23 深圳点猫科技有限公司 A kind of method and electronic equipment creating Python sandbox environment
CN109683954A (en) * 2018-12-29 2019-04-26 北京小米移动软件有限公司 The library lib integrated approach, device and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130104115A1 (en) * 2011-10-21 2013-04-25 International Business Machines Corporation Systems and methods for upgrading a version of software
CN108197633A (en) * 2017-11-24 2018-06-22 百年金海科技有限公司 Deep learning image classification based on TensorFlow is with applying dispositions method
CN109634840A (en) * 2018-10-25 2019-04-16 平安科技(深圳)有限公司 Method for testing software, device, equipment and storage medium
CN109670299A (en) * 2018-12-29 2019-04-23 深圳点猫科技有限公司 A kind of method and electronic equipment creating Python sandbox environment
CN109683954A (en) * 2018-12-29 2019-04-26 北京小米移动软件有限公司 The library lib integrated approach, device and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111930411A (en) * 2020-09-30 2020-11-13 腾讯科技(深圳)有限公司 Code upgrading method and device, computer equipment and storage medium
CN111930411B (en) * 2020-09-30 2020-12-29 腾讯科技(深圳)有限公司 Code upgrading method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN111045701B (en) 2024-06-11

Similar Documents

Publication Publication Date Title
CN109032606B (en) Native application compiling method and device and terminal
CN110858173B (en) Data processing method and device for data processing
CN111221559B (en) Application updating method, device, storage medium, terminal and server
EP3282371A1 (en) Data clearing method and apparatus, computer program and recording medium
CN107357613B (en) Application updating method and device and computer readable storage medium
CN106406956B (en) Application program installation method and device
CN111045701B (en) Version switching method and device for version switching
CN104462469A (en) Updating method and updating device for website static files
CN109522286B (en) Processing method and device of file system
CN107861666B (en) Desktop application installation method and device
CN107168731B (en) System update control method and device
CN108549570B (en) User interface updating method and device
CN111597106A (en) Point burying management method and device
CN111767063A (en) Resource updating method, device and equipment for application program
CN117076005B (en) Application running method and device, electronic equipment and storage medium
CN112214252A (en) Information expansion method and device and electronic equipment
CN115357277A (en) Hot update method, device, electronic apparatus, storage medium and program product
CN117492823B (en) Code acquisition method, device, electronic equipment and readable storage medium
CN116126320B (en) Data processing method and device, electronic equipment and storage medium
CN114020694B (en) Header file address acquisition method and device, electronic equipment and storage medium
CN110659081B (en) File processing method and device for program object and electronic equipment
CN113360341B (en) Front-end application maintenance and loading method and device
CN116400925A (en) Data processing method and device, electronic equipment and storage medium
CN110311968B (en) Method and device for loading file in streaming mode and intelligent equipment
CN110377312B (en) Software upgrading method, device and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant